Skip to content

Commit

Permalink
EVP_PKEY_paramgen_init: fix return check
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#17030)
  • Loading branch information
PeiweiHu authored and t8m committed Nov 16, 2021
1 parent e2e5e72 commit 6e0b05f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/dhparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ int dhparam_main(int argc, char **argv)
"Generating %s parameters, %d bit long %sprime\n",
alg, num, dsaparam ? "" : "safe ");

if (!EVP_PKEY_paramgen_init(ctx)) {
if (EVP_PKEY_paramgen_init(ctx) <= 0) {
BIO_printf(bio_err,
"Error, unable to initialise %s parameters\n",
alg);
Expand Down
4 changes: 2 additions & 2 deletions test/acvp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static EVP_PKEY *dsa_paramgen(int L, int N)
EVP_PKEY *param_key = NULL;

if (!TEST_ptr(paramgen_ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL))
|| !TEST_true(EVP_PKEY_paramgen_init(paramgen_ctx))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(paramgen_ctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(paramgen_ctx, L))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(paramgen_ctx, N))
|| !TEST_true(EVP_PKEY_paramgen(paramgen_ctx, &param_key)))
Expand Down Expand Up @@ -416,7 +416,7 @@ static int dsa_paramgen_test(int id)
const struct dsa_paramgen_st *tst = &dsa_paramgen_data[id];

if (!TEST_ptr(paramgen_ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL))
|| !TEST_true(EVP_PKEY_paramgen_init(paramgen_ctx))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(paramgen_ctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(paramgen_ctx, tst->L))
|| !TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_q_bits(paramgen_ctx, tst->N))
|| !TEST_true(EVP_PKEY_paramgen(paramgen_ctx, &param_key))
Expand Down
2 changes: 1 addition & 1 deletion test/evp_extra_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ static int test_EC_keygen_with_enc(int idx)

/* Create key parameters */
if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, "EC", NULL))
|| !TEST_true(EVP_PKEY_paramgen_init(pctx))
|| !TEST_int_gt(EVP_PKEY_paramgen_init(pctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_group_name(pctx, "P-256"))
|| !TEST_true(EVP_PKEY_CTX_set_ec_param_enc(pctx, enc))
|| !TEST_true(EVP_PKEY_paramgen(pctx, &params))
Expand Down

0 comments on commit 6e0b05f

Please sign in to comment.