mirror of
https://github.com/openssl/openssl.git
synced 2024-12-05 07:54:47 +08:00
Include EVP_PKEY argument in EVP_PKEY_CTX_new(). This avoids the
need for a separate EVP_PKEY parameter in the other operation initialization routines.
This commit is contained in:
parent
f733a5ef0e
commit
cd7638980a
@ -906,7 +906,7 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
|
||||
|
||||
const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type, ENGINE *e);
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_new(int ktype, ENGINE *e);
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey);
|
||||
void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
|
||||
int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
|
||||
int cmd, int p1, void *p2);
|
||||
|
@ -266,39 +266,37 @@ struct evp_pkey_method_st
|
||||
int (*init)(EVP_PKEY_CTX *ctx);
|
||||
|
||||
int (*paramgen_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*paramgen)(EVP_PKEY *key, EVP_PKEY_CTX *ctx);
|
||||
int (*paramgen)(EVP_PKEY_CTX *ctx);
|
||||
|
||||
int (*keygen_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*keygen)(EVP_PKEY *key, EVP_PKEY_CTX *ctx);
|
||||
int (*keygen)(EVP_PKEY_CTX *ctx);
|
||||
|
||||
int (*sign_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
int (*sign_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, int *siglen,
|
||||
unsigned char *tbs, int tbslen);
|
||||
|
||||
int (*verify_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
int (*verify_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*verify)(EVP_PKEY_CTX *ctx, unsigned char *sig, int siglen,
|
||||
unsigned char *tbs, int tbslen);
|
||||
|
||||
int (*verify_recover_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
int (*verify_recover_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*verify_recover)(EVP_PKEY_CTX *ctx,
|
||||
unsigned char *rout, int *routlen,
|
||||
unsigned char *sig, int siglen);
|
||||
|
||||
int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx,
|
||||
EVP_PKEY *pkey);
|
||||
int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
|
||||
int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, int *siglen,
|
||||
EVP_MD_CTX *mctx);
|
||||
|
||||
int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx,
|
||||
EVP_PKEY *pkey);
|
||||
int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
|
||||
int (*verifyctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, int siglen,
|
||||
EVP_MD_CTX *mctx);
|
||||
|
||||
int (*encrypt_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
int (*encrypt_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen,
|
||||
unsigned char *in, int inlen);
|
||||
|
||||
int (*decrypt_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
int (*decrypt_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen,
|
||||
unsigned char *in, int inlen);
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
int ret;
|
||||
if (!ctx || !ctx->pmeth || !ctx->pmeth->sign_init)
|
||||
@ -73,7 +73,7 @@ int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
return -2;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_SIGN;
|
||||
ret = ctx->pmeth->sign_init(ctx, pkey);
|
||||
ret = ctx->pmeth->sign_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return ret;
|
||||
@ -97,7 +97,7 @@ int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
|
||||
return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
|
||||
}
|
||||
|
||||
int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
int ret;
|
||||
if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_init)
|
||||
@ -107,7 +107,7 @@ int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
return -2;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_VERIFY;
|
||||
ret = ctx->pmeth->verify_init(ctx, pkey);
|
||||
ret = ctx->pmeth->verify_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return ret;
|
||||
@ -131,7 +131,7 @@ int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
|
||||
return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
|
||||
}
|
||||
|
||||
int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
int ret;
|
||||
if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover_init)
|
||||
@ -141,7 +141,7 @@ int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
return -2;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_VERIFYRECOVER;
|
||||
ret = ctx->pmeth->verify_recover_init(ctx, pkey);
|
||||
ret = ctx->pmeth->verify_recover_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return ret;
|
||||
@ -165,7 +165,7 @@ int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
|
||||
return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
|
||||
}
|
||||
|
||||
int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
int ret;
|
||||
if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt_init)
|
||||
@ -175,7 +175,7 @@ int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
return -2;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_ENCRYPT;
|
||||
ret = ctx->pmeth->encrypt_init(ctx, pkey);
|
||||
ret = ctx->pmeth->encrypt_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return ret;
|
||||
@ -199,7 +199,7 @@ int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
|
||||
return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
|
||||
}
|
||||
|
||||
int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
int ret;
|
||||
if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt_init)
|
||||
@ -209,7 +209,7 @@ int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
return -2;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_DECRYPT;
|
||||
ret = ctx->pmeth->decrypt_init(ctx, pkey);
|
||||
ret = ctx->pmeth->decrypt_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return ret;
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include <openssl/objects.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include "asn1_locl.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
STACK *app_pkey_methods = NULL;
|
||||
@ -100,17 +101,20 @@ const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type, ENGINE *e)
|
||||
return *ret;
|
||||
}
|
||||
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_new(int ktype, ENGINE *e)
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey)
|
||||
{
|
||||
EVP_PKEY_CTX *ret;
|
||||
const EVP_PKEY_METHOD *pmeth;
|
||||
pmeth = EVP_PKEY_meth_find(ktype, e);
|
||||
if (!pkey || !pkey->ameth)
|
||||
return NULL;
|
||||
pmeth = EVP_PKEY_meth_find(pkey->ameth->pkey_id, NULL);
|
||||
if (pmeth == NULL)
|
||||
return NULL;
|
||||
ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
|
||||
ret->pmeth = pmeth;
|
||||
ret->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
ret->pkey = NULL;
|
||||
CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
|
||||
ret->pkey = pkey;
|
||||
ret->data = NULL;
|
||||
|
||||
if (pmeth->init)
|
||||
|
Loading…
Reference in New Issue
Block a user