Skip to content

Commit

Permalink
Check input length to pkey_rsa_verify()
Browse files Browse the repository at this point in the history
Reviewed-by: Rich Salz <[email protected]>
(Merged from openssl#2065)
  • Loading branch information
snhenson committed Dec 9, 2016
1 parent 6c0e1e2 commit 71bbc79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions crypto/rsa/rsa_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static ERR_STRING_DATA RSA_str_functs[] = {
{ERR_FUNC(RSA_F_PKEY_RSA_CTRL), "pkey_rsa_ctrl"},
{ERR_FUNC(RSA_F_PKEY_RSA_CTRL_STR), "pkey_rsa_ctrl_str"},
{ERR_FUNC(RSA_F_PKEY_RSA_SIGN), "pkey_rsa_sign"},
{ERR_FUNC(RSA_F_PKEY_RSA_VERIFY), "pkey_rsa_verify"},
{ERR_FUNC(RSA_F_PKEY_RSA_VERIFYRECOVER), "pkey_rsa_verifyrecover"},
{ERR_FUNC(RSA_F_RSA_ALGOR_TO_MD), "rsa_algor_to_md"},
{ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "rsa_builtin_keygen"},
Expand Down
4 changes: 4 additions & 0 deletions crypto/rsa/rsa_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,
if (rctx->pad_mode == RSA_PKCS1_PADDING)
return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,
sig, siglen, rsa);
if (tbslen != (size_t)EVP_MD_size(rctx->md)) {
RSAerr(RSA_F_PKEY_RSA_VERIFY, RSA_R_INVALID_DIGEST_LENGTH);
return -1;
}
if (rctx->pad_mode == RSA_X931_PADDING) {
if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0)
return 0;
Expand Down
1 change: 1 addition & 0 deletions include/openssl/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ int ERR_load_RSA_strings(void);
# define RSA_F_PKEY_RSA_CTRL 143
# define RSA_F_PKEY_RSA_CTRL_STR 144
# define RSA_F_PKEY_RSA_SIGN 142
# define RSA_F_PKEY_RSA_VERIFY 149
# define RSA_F_PKEY_RSA_VERIFYRECOVER 141
# define RSA_F_RSA_ALGOR_TO_MD 156
# define RSA_F_RSA_BUILTIN_KEYGEN 129
Expand Down

0 comments on commit 71bbc79

Please sign in to comment.