mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 11:14:36 +00:00
prov: asym ciphers take an extra init() params argument
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14383)
This commit is contained in:
parent
c4c422e0cc
commit
cbdeb04c90
@ -91,7 +91,8 @@ static void *rsa_newctx(void *provctx)
|
||||
return prsactx;
|
||||
}
|
||||
|
||||
static int rsa_init(void *vprsactx, void *vrsa, int operation)
|
||||
static int rsa_init(void *vprsactx, void *vrsa, const OSSL_PARAM params[],
|
||||
int operation)
|
||||
{
|
||||
PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
|
||||
|
||||
@ -116,17 +117,19 @@ static int rsa_init(void *vprsactx, void *vrsa, int operation)
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return rsa_set_ctx_params(prsactx, params);
|
||||
}
|
||||
|
||||
static int rsa_encrypt_init(void *vprsactx, void *vrsa)
|
||||
static int rsa_encrypt_init(void *vprsactx, void *vrsa,
|
||||
const OSSL_PARAM params[])
|
||||
{
|
||||
return rsa_init(vprsactx, vrsa, EVP_PKEY_OP_ENCRYPT);
|
||||
return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_ENCRYPT);
|
||||
}
|
||||
|
||||
static int rsa_decrypt_init(void *vprsactx, void *vrsa)
|
||||
static int rsa_decrypt_init(void *vprsactx, void *vrsa,
|
||||
const OSSL_PARAM params[])
|
||||
{
|
||||
return rsa_init(vprsactx, vrsa, EVP_PKEY_OP_DECRYPT);
|
||||
return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_DECRYPT);
|
||||
}
|
||||
|
||||
static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen,
|
||||
@ -329,7 +332,7 @@ static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
|
||||
PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
|
||||
OSSL_PARAM *p;
|
||||
|
||||
if (prsactx == NULL || params == NULL)
|
||||
if (prsactx == NULL)
|
||||
return 0;
|
||||
|
||||
p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_PAD_MODE);
|
||||
@ -422,8 +425,10 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
|
||||
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
|
||||
char *str = mdname;
|
||||
|
||||
if (prsactx == NULL || params == NULL)
|
||||
if (prsactx == NULL)
|
||||
return 0;
|
||||
if (params == NULL)
|
||||
return 1;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST);
|
||||
if (p != NULL) {
|
||||
|
@ -56,7 +56,7 @@ static void *sm2_newctx(void *provctx)
|
||||
return psm2ctx;
|
||||
}
|
||||
|
||||
static int sm2_init(void *vpsm2ctx, void *vkey)
|
||||
static int sm2_init(void *vpsm2ctx, void *vkey, const OSSL_PARAM params[])
|
||||
{
|
||||
PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
|
||||
|
||||
@ -65,7 +65,7 @@ static int sm2_init(void *vpsm2ctx, void *vkey)
|
||||
EC_KEY_free(psm2ctx->key);
|
||||
psm2ctx->key = vkey;
|
||||
|
||||
return 1;
|
||||
return sm2_set_ctx_params(psm2ctx, params);
|
||||
}
|
||||
|
||||
static const EVP_MD *sm2_get_md(PROV_SM2_CTX *psm2ctx)
|
||||
@ -156,7 +156,7 @@ static int sm2_get_ctx_params(void *vpsm2ctx, OSSL_PARAM *params)
|
||||
PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
|
||||
OSSL_PARAM *p;
|
||||
|
||||
if (vpsm2ctx == NULL || params == NULL)
|
||||
if (vpsm2ctx == NULL)
|
||||
return 0;
|
||||
|
||||
p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_DIGEST);
|
||||
@ -186,8 +186,10 @@ static int sm2_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[])
|
||||
{
|
||||
PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
|
||||
|
||||
if (psm2ctx == NULL || params == NULL)
|
||||
if (psm2ctx == NULL)
|
||||
return 0;
|
||||
if (params == NULL)
|
||||
return 1;
|
||||
|
||||
if (!ossl_prov_digest_load_from_params(&psm2ctx->md, params,
|
||||
psm2ctx->libctx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user