summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-03-05 08:22:56 +1000
committerTomas Mraz <tomas@openssl.org>2021-03-22 15:40:04 +0100
commite72dbd8e13cbf5a16faaa6c911af5507593dd836 (patch)
treeec450d9fef6ba2223cfc36ee1865512254f9dd23 /crypto/ec
parentc781eb1c63c243cb64dbe3066a43dc172aaab3b8 (diff)
Fix usages of const EVP_MD.
Partially fixes #13837 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14474)
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ecx_meth.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c
index d476af0e3c..d68189036b 100644
--- a/crypto/ec/ecx_meth.c
+++ b/crypto/ec/ecx_meth.c
@@ -991,6 +991,8 @@ static int s390x_pkey_ecd_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
ctx->propquery);
unsigned char *privkey = NULL, *pubkey;
unsigned int sz;
+ EVP_MD *md = NULL;
+ int rv;
if (key == NULL) {
ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE);
@@ -1008,7 +1010,13 @@ static int s390x_pkey_ecd_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
if (RAND_priv_bytes_ex(ctx->libctx, privkey, ED25519_KEYLEN) <= 0)
goto err;
- if (!EVP_Digest(privkey, 32, buff, &sz, EVP_sha512(), NULL))
+ md = EVP_MD_fetch(ctx->libctx, "SHA512", ctx->propquery);
+ if (md == NULL)
+ goto err;
+
+ rv = EVP_Digest(privkey, 32, buff, &sz, md, NULL);
+ EVP_MD_free(md);
+ if (!rv)
goto err;
buff[0] &= 248;
@@ -1049,6 +1057,8 @@ static int s390x_pkey_ecd_keygen448(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
ctx->propquery);
unsigned char *privkey = NULL, *pubkey;
EVP_MD_CTX *hashctx = NULL;
+ EVP_MD *md = NULL;
+ int rv;
if (key == NULL) {
ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE);
@@ -1069,8 +1079,16 @@ static int s390x_pkey_ecd_keygen448(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
hashctx = EVP_MD_CTX_new();
if (hashctx == NULL)
goto err;
- if (EVP_DigestInit_ex(hashctx, EVP_shake256(), NULL) != 1)
+
+ md = EVP_MD_fetch(ctx->libctx, "SHAKE256", ctx->propquery);
+ if (md == NULL)
+ goto err;
+
+ rv = EVP_DigestInit_ex(hashctx, md, NULL);
+ EVP_MD_free(md);
+ if (rv != 1)
goto err;
+
if (EVP_DigestUpdate(hashctx, privkey, 57) != 1)
goto err;
if (EVP_DigestFinalXOF(hashctx, buff, sizeof(buff)) != 1)