]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix provider compatibility check crash in evp_test
authorTomas Mraz <tomas@openssl.org>
Mon, 11 Dec 2023 14:19:47 +0000 (15:19 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 19 Dec 2023 12:22:13 +0000 (13:22 +0100)
EVP_MAC_CTX_get_mac_size() cannot be called on older
unfixed versions before EVP_MAC_init().

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/23008)

test/evp_test.c

index 90ff676a62a132fa7a02128ef9e7e4495dce7e2a..885a99dd16cd3e5a040b0ecd5d0b1df58c6f03d7 100644 (file)
@@ -1427,7 +1427,7 @@ static int mac_test_run_mac(EVP_TEST *t)
     EVP_MAC_CTX *ctx = NULL;
     unsigned char *got = NULL;
     size_t got_len = 0, size = 0;
-    size_t size_before_init, size_after_init, size_val = 0;
+    size_t size_before_init = 0, size_after_init, size_val = 0;
     int i, block_size = -1, output_size = -1;
     OSSL_PARAM params[21], sizes[3], *psizes = sizes;
     size_t params_n = 0;
@@ -1535,7 +1535,8 @@ static int mac_test_run_mac(EVP_TEST *t)
         t->err = "MAC_CREATE_ERROR";
         goto err;
     }
-    size_before_init = EVP_MAC_CTX_get_mac_size(ctx);
+    if (fips_provider_version_gt(libctx, 3, 1, 4))
+        size_before_init = EVP_MAC_CTX_get_mac_size(ctx);
     if (!EVP_MAC_init(ctx, expected->key, expected->key_len, params)) {
         t->err = "MAC_INIT_ERROR";
         goto err;