diff --git a/crypto/ecdsa/ecdsa.c b/crypto/ecdsa/ecdsa.c index 8ce23db7..70cb1189 100644 --- a/crypto/ecdsa/ecdsa.c +++ b/crypto/ecdsa/ecdsa.c @@ -79,10 +79,6 @@ int ECDSA_verify(int type, const uint8_t *digest, size_t digest_len, int ret = 0; uint8_t *der = NULL; - if (eckey->ecdsa_meth && eckey->ecdsa_meth->verify) { - return eckey->ecdsa_meth->verify(digest, digest_len, sig, sig_len, eckey); - } - /* Decode the ECDSA signature. */ s = ECDSA_SIG_from_bytes(sig, sig_len); if (s == NULL) { @@ -148,11 +144,6 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len, const EC_GROUP *group; const EC_POINT *pub_key; - if (eckey->ecdsa_meth && eckey->ecdsa_meth->verify) { - OPENSSL_PUT_ERROR(ECDSA, ECDSA_R_NOT_IMPLEMENTED); - return 0; - } - /* check input values */ if ((group = EC_KEY_get0_group(eckey)) == NULL || (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || diff --git a/crypto/rsa/internal.h b/crypto/rsa/internal.h index 687146f0..ae8cdb7c 100644 --- a/crypto/rsa/internal.h +++ b/crypto/rsa/internal.h @@ -77,9 +77,6 @@ int rsa_default_sign_raw(RSA *rsa, size_t *out_len, uint8_t *out, int padding); int rsa_default_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding); -int rsa_default_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, size_t in_len, - int padding); int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, size_t len); int rsa_default_multi_prime_keygen(RSA *rsa, int bits, int num_primes, diff --git a/crypto/rsa/rsa.c b/crypto/rsa/rsa.c index 0b298930..1d932c04 100644 --- a/crypto/rsa/rsa.c +++ b/crypto/rsa/rsa.c @@ -258,16 +258,6 @@ int RSA_private_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, return out_len; } -int RSA_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, - const uint8_t *in, size_t in_len, int padding) { - if (rsa->meth->verify_raw) { - return rsa->meth->verify_raw(rsa, out_len, out, max_out, in, in_len, padding); - } - - return rsa_default_verify_raw(rsa, out_len, out, max_out, in, in_len, - padding); -} - int RSA_public_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int padding) { size_t out_len; @@ -473,6 +463,11 @@ finish: int RSA_verify(int hash_nid, const uint8_t *msg, size_t msg_len, const uint8_t *sig, size_t sig_len, RSA *rsa) { + if (rsa->n == NULL || rsa->e == NULL) { + OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); + return 0; + } + const size_t rsa_size = RSA_size(rsa); uint8_t *buf = NULL; int ret = 0; @@ -480,10 +475,6 @@ int RSA_verify(int hash_nid, const uint8_t *msg, size_t msg_len, size_t signed_msg_len, len; int signed_msg_is_alloced = 0; - if (rsa->meth->verify) { - return rsa->meth->verify(hash_nid, msg, msg_len, sig, sig_len, rsa); - } - if (sig_len != rsa_size) { OPENSSL_PUT_ERROR(RSA, RSA_R_WRONG_SIGNATURE_LENGTH); return 0; diff --git a/crypto/rsa/rsa_impl.c b/crypto/rsa/rsa_impl.c index af55c1da..c9158958 100644 --- a/crypto/rsa/rsa_impl.c +++ b/crypto/rsa/rsa_impl.c @@ -426,9 +426,13 @@ err: static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); -int rsa_default_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out, - size_t max_out, const uint8_t *in, size_t in_len, - int padding) { +int RSA_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, + const uint8_t *in, size_t in_len, int padding) { + if (rsa->n == NULL || rsa->e == NULL) { + OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); + return 0; + } + const unsigned rsa_size = RSA_size(rsa); BIGNUM *f, *result; int ret = 0; diff --git a/include/openssl/ec_key.h b/include/openssl/ec_key.h index c4b74a2a..63554a78 100644 --- a/include/openssl/ec_key.h +++ b/include/openssl/ec_key.h @@ -248,7 +248,7 @@ struct ecdsa_method_st { int (*sign)(const uint8_t *digest, size_t digest_len, uint8_t *sig, unsigned int *sig_len, EC_KEY *eckey); - /* verify matches the arguments and behaviour of |ECDSA_verify|. */ + /* Ignored. Set this to NULL. */ int (*verify)(const uint8_t *digest, size_t digest_len, const uint8_t *sig, size_t sig_len, EC_KEY *eckey); diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index 19325aae..ea42525c 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -509,6 +509,7 @@ struct rsa_meth_st { int (*sign)(int type, const uint8_t *m, unsigned int m_length, uint8_t *sigret, unsigned int *siglen, const RSA *rsa); + /* Ignored. Set this to NULL. */ int (*verify)(int dtype, const uint8_t *m, unsigned int m_length, const uint8_t *sigbuf, unsigned int siglen, const RSA *rsa); @@ -521,6 +522,7 @@ struct rsa_meth_st { int (*decrypt)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding); + /* Ignored. Set this to NULL. */ int (*verify_raw)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding);