Skip to content

Commit

Permalink
Fix the erroneous checks of EVP_PKEY_CTX_set_group_name
Browse files Browse the repository at this point in the history
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #18399)

(cherry picked from commit 56876ae)
  • Loading branch information
PeiweiHu authored and t8m committed Jun 2, 2022
1 parent bce02f9 commit ad8d425
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crypto/cms/cms_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval,
if (pctx == NULL || EVP_PKEY_paramgen_init(pctx) <= 0)
goto err;
if (OBJ_obj2txt(groupname, sizeof(groupname), poid, 0) <= 0
|| !EVP_PKEY_CTX_set_group_name(pctx, groupname)) {
|| EVP_PKEY_CTX_set_group_name(pctx, groupname) <= 0) {
ERR_raise(ERR_LIB_CMS, CMS_R_DECODE_ERROR);
goto err;
}
Expand Down
4 changes: 2 additions & 2 deletions ssl/s3_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4709,7 +4709,7 @@ EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id)
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
goto err;
}
if (!EVP_PKEY_CTX_set_group_name(pctx, ginf->realname)) {
if (EVP_PKEY_CTX_set_group_name(pctx, ginf->realname) <= 0) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
goto err;
}
Expand Down Expand Up @@ -4743,7 +4743,7 @@ EVP_PKEY *ssl_generate_param_group(SSL *s, uint16_t id)
goto err;
if (EVP_PKEY_paramgen_init(pctx) <= 0)
goto err;
if (!EVP_PKEY_CTX_set_group_name(pctx, ginf->realname)) {
if (EVP_PKEY_CTX_set_group_name(pctx, ginf->realname) <= 0) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
goto err;
}
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 @@ -1759,7 +1759,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_int_gt(EVP_PKEY_paramgen_init(pctx), 0)
|| !TEST_true(EVP_PKEY_CTX_set_group_name(pctx, "P-256"))
|| !TEST_int_gt(EVP_PKEY_CTX_set_group_name(pctx, "P-256"), 0)
|| !TEST_true(EVP_PKEY_CTX_set_ec_param_enc(pctx, enc))
|| !TEST_true(EVP_PKEY_paramgen(pctx, &params))
|| !TEST_ptr(params))
Expand Down

0 comments on commit ad8d425

Please sign in to comment.