Skip to content

Commit

Permalink
ffc/ffc_params_generate.c: Add the check for the EVP_MD_get_size()
Browse files Browse the repository at this point in the history
Add the check for the EVP_MD_get_size() to avoid invalid negative numbers.

Fixes: 4f2271d ("Add ACVP fips module tests")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23970)
  • Loading branch information
JiangJias authored and t8m committed Apr 9, 2024
1 parent f5fde94 commit 309c7ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/ffc/ffc_params_generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ int ossl_ffc_params_FIPS186_2_gen_verify(OSSL_LIB_CTX *libctx,
BIGNUM *r0, *test, *tmp, *g = NULL, *q = NULL, *p = NULL;
BN_MONT_CTX *mont = NULL;
EVP_MD *md = NULL;
int md_size;
size_t qsize;
int n = 0, m = 0;
int counter = 0, pcounter = 0, use_random_seed;
Expand Down Expand Up @@ -842,8 +843,11 @@ int ossl_ffc_params_FIPS186_2_gen_verify(OSSL_LIB_CTX *libctx,
}
if (md == NULL)
goto err;
md_size = EVP_MD_get_size(md);
if (md_size <= 0)
goto err;
if (N == 0)
N = EVP_MD_get_size(md) * 8;
N = md_size * 8;
qsize = N >> 3;

/*
Expand Down

0 comments on commit 309c7ff

Please sign in to comment.