]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
mac: always pass a non-NULL output size pointer to providers.
authorPauli <paul.dale@oracle.com>
Thu, 16 Jul 2020 01:15:42 +0000 (11:15 +1000)
committerPauli <paul.dale@oracle.com>
Sat, 18 Jul 2020 06:54:53 +0000 (16:54 +1000)
The backend code varies for the different MACs and sometimes sets the output
length, sometimes checks the return pointer and sometimes neither.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12458)

crypto/evp/mac_lib.c

index b7bfe8921fcacbbac45ace170ee4feaa5f97c7f0..a5c1b44666ddc38b2b47f6b0feda8626ab130cdf 100644 (file)
@@ -120,15 +120,14 @@ int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen)
 int EVP_MAC_final(EVP_MAC_CTX *ctx,
                   unsigned char *out, size_t *outl, size_t outsize)
 {
-    int l = EVP_MAC_size(ctx);
+    size_t l = EVP_MAC_size(ctx);
+    int res = 1;
 
-    if (l < 0)
-        return 0;
+    if (out != NULL)
+        res = ctx->meth->final(ctx->data, out, &l, outsize);
     if (outl != NULL)
         *outl = l;
-    if (out == NULL)
-        return 1;
-    return ctx->meth->final(ctx->data, out, outl, outsize);
+    return res;
 }
 
 /*