summaryrefslogtreecommitdiffstats
path: root/crypto/evp/mac_lib.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-08-05 15:26:48 +1000
committerPauli <paul.dale@oracle.com>2020-08-07 08:07:07 +1000
commit5f6a0b2ff055cf3ad09a1d49a4b95b13e1106b35 (patch)
treedcf50d5c3e37b6a2ca3a18dac9e44bab58a910ed /crypto/evp/mac_lib.c
parent992492f5e82e0cf9b24acc14ea90ce8afd4c447a (diff)
mac: add some consistency to setting the XXX_final output length.
The various MACs were all over the place with respects to what they did with the output length in the final call. Now they all unconditionally set the output length and the EVP layer handles the possibility of a NULL pointer. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12582)
Diffstat (limited to 'crypto/evp/mac_lib.c')
-rw-r--r--crypto/evp/mac_lib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c
index a5c1b44666..2198c46680 100644
--- a/crypto/evp/mac_lib.c
+++ b/crypto/evp/mac_lib.c
@@ -120,11 +120,13 @@ 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)
{
- size_t l = EVP_MAC_size(ctx);
+ size_t l;
int res = 1;
if (out != NULL)
res = ctx->meth->final(ctx->data, out, &l, outsize);
+ else
+ l = EVP_MAC_size(ctx);
if (outl != NULL)
*outl = l;
return res;