summaryrefslogtreecommitdiffstats
path: root/crypto/evp/pmeth_lib.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2006-04-11 13:28:52 +0000
committerDr. Stephen Henson <steve@openssl.org>2006-04-11 13:28:52 +0000
commitf5cda4cbb17c908ceef33f4f52d94e8e04b7c1ab (patch)
tree851abcd3b7178040056cbb1ce397bbc526774041 /crypto/evp/pmeth_lib.c
parentf9a6348a537290f65fd76d945419a4c9bafff012 (diff)
Initial keygen support.
Diffstat (limited to 'crypto/evp/pmeth_lib.c')
-rw-r--r--crypto/evp/pmeth_lib.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 26a55048ca..3c8d0a6e4f 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -101,20 +101,25 @@ const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type, ENGINE *e)
return *ret;
}
-EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey)
+static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
{
EVP_PKEY_CTX *ret;
const EVP_PKEY_METHOD *pmeth;
- if (!pkey || !pkey->ameth)
- return NULL;
- pmeth = EVP_PKEY_meth_find(pkey->ameth->pkey_id, NULL);
+ if (id == -1)
+ {
+ if (!pkey || !pkey->ameth)
+ return NULL;
+ id = pkey->ameth->pkey_id;
+ }
+ pmeth = EVP_PKEY_meth_find(id, e);
if (pmeth == NULL)
return NULL;
ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
ret->pmeth = pmeth;
ret->operation = EVP_PKEY_OP_UNDEFINED;
- CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
ret->pkey = pkey;
+ if (pkey)
+ CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
ret->data = NULL;
if (pmeth->init)
@@ -129,6 +134,16 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey)
return ret;
}
+EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e)
+ {
+ return int_ctx_new(pkey, e, -1);
+ }
+
+EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e)
+ {
+ return int_ctx_new(NULL, e, id);
+ }
+
void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
{
if (ctx->pmeth && ctx->pmeth->cleanup)
@@ -191,3 +206,23 @@ int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx,
}
return ctx->pmeth->ctrl_str(ctx, name, value);
}
+
+void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data)
+ {
+ ctx->data = data;
+ }
+
+void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx)
+ {
+ return ctx->data;
+ }
+
+void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data)
+ {
+ ctx->app_data = data;
+ }
+
+void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx)
+ {
+ return ctx->app_data;
+ }