summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-01-13 08:54:47 +0100
committerRichard Levitte <levitte@openssl.org>2020-01-23 17:59:12 +0100
commit8baa49aeac0d51504b8bcd0fd5c750c17af6fe62 (patch)
treecf05030901522aa9c0cfc0b7aeff1a4cf865abe6 /providers
parentead0d2347a348f0916d6d25818d16d702f1d1156 (diff)
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)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/keymgmt/dsa_kmgmt.c5
-rw-r--r--providers/implementations/keymgmt/rsa_kmgmt.c26
2 files changed, 31 insertions, 0 deletions
diff --git a/providers/implementations/keymgmt/dsa_kmgmt.c b/providers/implementations/keymgmt/dsa_kmgmt.c
index c2c3c2221a..5a53a439d9 100644
--- a/providers/implementations/keymgmt/dsa_kmgmt.c
+++ b/providers/implementations/keymgmt/dsa_kmgmt.c
@@ -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;
}
diff --git a/providers/implementations/keymgmt/rsa_kmgmt.c b/providers/implementations/keymgmt/rsa_kmgmt.c
index a1f81041b8..54e4c540d9 100644
--- a/providers/implementations/keymgmt/rsa_kmgmt.c
+++ b/providers/implementations/keymgmt/rsa_kmgmt.c
@@ -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;
}