EC: Remove one error record that shadows another
authorRichard Levitte <levitte@openssl.org>
Sun, 30 Aug 2020 09:46:45 +0000 (11:46 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 3 Sep 2020 15:48:33 +0000 (17:48 +0200)
In EC_GROUP_new_from_params(), ERR_R_EC_LIB was reported if
group_new_from_name() returned NULL.  However, this shadows a possible
EC_R_INVALID_CURVE, making that harder to detect, which happens to be
important to do in test/evp_test.c.

This also extends key_unsupported() in test/evp_test.c to check for
this error alongside the check for EC_R_UNKNOWN_GROUP.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)

crypto/ec/ec_lib.c
test/evp_test.c

index d9298f62d0a7d0d0d933e0db1afeb525a31b230a..d7752e953f66a0d17f2c4a94829d6722deb6564c 100644 (file)
@@ -1552,8 +1552,6 @@ EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[],
         group = group_new_from_name(ptmp, libctx, propq);
         if (group != NULL)
             EC_GROUP_set_asn1_flag(group, encoding_flag);
-        else
-            ECerr(0, ERR_R_EC_LIB);
         return group;
     }
     bnctx = BN_CTX_new_ex(libctx);
index d5ec08c469ea27e306e55652411104d5d3660fe7..52e1dd2e51b304e2ddd1739b106b3674d546648b 100644 (file)
@@ -3268,7 +3268,8 @@ static int key_unsupported(void)
      * disabled).
      */
     if (ERR_GET_LIB(err) == ERR_LIB_EC
-        && ERR_GET_REASON(err) == EC_R_UNKNOWN_GROUP) {
+        && (ERR_GET_REASON(err) == EC_R_UNKNOWN_GROUP
+            || ERR_GET_REASON(err) == EC_R_INVALID_CURVE)) {
         ERR_clear_error();
         return 1;
     }