diff options
author | Matt Caswell <matt@openssl.org> | 2020-04-07 11:10:02 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-04-09 16:10:00 +0100 |
commit | 5435044fd6007f8a649f8fc75a043221931d4bf1 (patch) | |
tree | 1418352b258f90206d4b12f28b787ef607a4ff70 /crypto | |
parent | bbe3ed06d7bed1bed75d4816665539c959741d2d (diff) |
Enable Ed25519 signing/verifying to use the libctx
Ed25519 needs to fetch a digest and so needs to use the correct libctx.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11496)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ec/curve25519.c | 10 | ||||
-rw-r--r-- | crypto/ec/ecx_meth.c | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/crypto/ec/curve25519.c b/crypto/ec/curve25519.c index 024f7fe169..8db6cdb16d 100644 --- a/crypto/ec/curve25519.c +++ b/crypto/ec/curve25519.c @@ -5438,13 +5438,14 @@ static void sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, } int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t public_key[32], const uint8_t private_key[32]) + const uint8_t public_key[32], const uint8_t private_key[32], + OPENSSL_CTX *libctx, const char *propq) { uint8_t az[SHA512_DIGEST_LENGTH]; uint8_t nonce[SHA512_DIGEST_LENGTH]; ge_p3 R; uint8_t hram[SHA512_DIGEST_LENGTH]; - EVP_MD *sha512 = EVP_MD_fetch(NULL, SN_sha512, NULL); + EVP_MD *sha512 = EVP_MD_fetch(libctx, SN_sha512, propq); EVP_MD_CTX *hash_ctx = EVP_MD_CTX_new(); unsigned int sz; int res = 0; @@ -5493,7 +5494,8 @@ err: static const char allzeroes[15]; int ED25519_verify(const uint8_t *message, size_t message_len, - const uint8_t signature[64], const uint8_t public_key[32]) + const uint8_t signature[64], const uint8_t public_key[32], + OPENSSL_CTX *libctx, const char *propq) { int i; ge_p3 A; @@ -5548,7 +5550,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len, fe_neg(A.X, A.X); fe_neg(A.T, A.T); - sha512 = EVP_MD_fetch(NULL, SN_sha512, NULL); + sha512 = EVP_MD_fetch(libctx, SN_sha512, propq); if (sha512 == NULL) return 0; hash_ctx = EVP_MD_CTX_new(); diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c index 750a51c3f2..03d6a7af83 100644 --- a/crypto/ec/ecx_meth.c +++ b/crypto/ec/ecx_meth.c @@ -837,7 +837,8 @@ static int pkey_ecd_digestsign25519(EVP_MD_CTX *ctx, unsigned char *sig, return 0; } - if (ED25519_sign(sig, tbs, tbslen, edkey->pubkey, edkey->privkey) == 0) + if (ED25519_sign(sig, tbs, tbslen, edkey->pubkey, edkey->privkey, NULL, + NULL) == 0) return 0; *siglen = ED25519_SIGSIZE; return 1; @@ -878,7 +879,7 @@ static int pkey_ecd_digestverify25519(EVP_MD_CTX *ctx, const unsigned char *sig, if (siglen != ED25519_SIGSIZE) return 0; - return ED25519_verify(tbs, tbslen, sig, edkey->pubkey); + return ED25519_verify(tbs, tbslen, sig, edkey->pubkey, NULL, NULL); } static int pkey_ecd_digestverify448(EVP_MD_CTX *ctx, const unsigned char *sig, |