Fix the erroneous checks of EVP_PKEY_CTX_set_group_name
authorPeiwei Hu <jlu.hpw@foxmail.com>
Tue, 24 May 2022 15:27:49 +0000 (23:27 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 2 Jun 2022 09:09:33 +0000 (11:09 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

(cherry picked from commit 56876ae952b96b4a83266f6b2ec1393f599015d6)

crypto/cms/cms_ec.c
ssl/s3_lib.c
test/evp_extra_test.c

index b07af92bad8b8fbc8438b913322d9c1eca5f572c..fad750c791af5281bfb354dd1db389513fc24ce1 100644 (file)
@@ -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;
         }
index e4eee647df0da9f38f8859b376ab367509a7b6f6..f530c5066d6baab2d6193a25fd629de480c499fd 100644 (file)
@@ -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;
     }
@@ -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;
     }
index 4eca37214d9c11add6e81812b34638f7269b80ad..ade3cb29f153c3dd43260ea10ea18da3b400d354 100644 (file)
@@ -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))