Fix evp_extra_test to not assume that HMAC is legacy
authorMatt Caswell <matt@openssl.org>
Fri, 7 Aug 2020 16:20:18 +0000 (17:20 +0100)
committerPauli <paul.dale@oracle.com>
Sat, 29 Aug 2020 07:40:09 +0000 (17:40 +1000)
evp_extra_test had a test that checks whether an EVP_PKEY_CTX can still
be created for HMAC even though there are no providers loaded because it
is a legacy algorithm. However after the earlier commits this is no longer
the case. We swap the check to a different legacy algorithm (SM2).
Hopefully before too long there will be no legacy algorithms left and the
test can be deleted.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12637)

test/evp_extra_test.c

index 4da65a2400d669aa15908c57c10e5ff3aaa08557..de5158fe13f9dd4b976bdce4b592dd5491d715a1 100644 (file)
@@ -1760,15 +1760,17 @@ static int test_pkey_ctx_fail_without_provider(int tst)
     if (!TEST_ptr(nullprov))
         goto err;
 
-    pctx = EVP_PKEY_CTX_new_from_name(tmpctx, tst == 0 ? "RSA" : "HMAC", "");
+    pctx = EVP_PKEY_CTX_new_from_name(tmpctx, tst == 0 ? "RSA" : "SM2", "");
 
     /* RSA is not available via any provider so we expect this to fail */
     if (tst == 0 && !TEST_ptr_null(pctx))
         goto err;
 
     /*
-     * HMAC is always available because it is implemented via legacy codepaths
+     * SM2 is always available because it is implemented via legacy codepaths
      * and not in a provider at all. We expect this to pass.
+     * TODO(3.0): This can be removed once there are no more algorithms
+     * available via legacy codepaths
      */
     if (tst == 1 && !TEST_ptr(pctx))
         goto err;