mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
Add answers for EVP_PKEY_get_default_digest_name() in RSA and DSA keymgmt
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10824)
This commit is contained in:
parent
ead0d2347a
commit
8baa49aeac
@ -24,6 +24,8 @@ static OSSL_OP_keymgmt_importkey_fn dsa_importkey;
|
||||
static OSSL_OP_keymgmt_exportkey_fn dsa_exportkey;
|
||||
static OSSL_OP_keymgmt_get_key_params_fn dsa_get_key_params;
|
||||
|
||||
#define DSA_DEFAULT_MD "SHA256"
|
||||
|
||||
static int params_to_domparams(DSA *dsa, const OSSL_PARAM params[])
|
||||
{
|
||||
const OSSL_PARAM *param_p, *param_q, *param_g;
|
||||
@ -211,6 +213,9 @@ static ossl_inline int dsa_get_dpk_params(void *key, OSSL_PARAM params[])
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
|
||||
&& !OSSL_PARAM_set_int(p, DSA_size(dsa)))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
|
||||
&& !OSSL_PARAM_set_utf8_string(p, DSA_DEFAULT_MD))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/types.h>
|
||||
#include "internal/param_build.h"
|
||||
@ -22,6 +24,8 @@ static OSSL_OP_keymgmt_importkey_fn rsa_importkey;
|
||||
static OSSL_OP_keymgmt_exportkey_fn rsa_exportkey;
|
||||
static OSSL_OP_keymgmt_get_key_params_fn rsa_get_key_params;
|
||||
|
||||
#define RSA_DEFAULT_MD "SHA256"
|
||||
|
||||
DEFINE_STACK_OF(BIGNUM)
|
||||
DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM)
|
||||
|
||||
@ -259,6 +263,28 @@ static int rsa_get_key_params(void *key, OSSL_PARAM params[])
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
|
||||
&& !OSSL_PARAM_set_int(p, RSA_size(rsa)))
|
||||
return 0;
|
||||
|
||||
# if 0 /* PSS support pending */
|
||||
if ((p = OSSL_PARAM_locate(params,
|
||||
OSSL_PKEY_PARAM_MANDATORY_DIGEST)) != NULL
|
||||
&& RSA_get0_pss_params(rsa) != NULL) {
|
||||
const EVP_MD *md, *mgf1md;
|
||||
int min_saltlen;
|
||||
|
||||
if (!rsa_pss_get_param(RSA_get0_pss_params(rsa),
|
||||
&md, &mgf1md, &min_saltlen)) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if (!OSSL_PARAM_set_utf8_string(p, EVP_MD_name(md)))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
|
||||
&& RSA_get0_pss_params(rsa) == NULL)
|
||||
if (!OSSL_PARAM_set_utf8_string(p, RSA_DEFAULT_MD))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user