diff options
author | Pauli <paul.dale@oracle.com> | 2020-07-16 11:15:42 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-07-18 16:54:53 +1000 |
commit | a85c9021252e4ab53a15b46e773808864a63d3d1 (patch) | |
tree | 830a69b8304609cf1c2339e78275354fa63c3688 /crypto/evp/mac_lib.c | |
parent | 3fc164e8d18dcdef57d297956debf8d966e7fbef (diff) |
mac: always pass a non-NULL output size pointer to providers.
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)
Diffstat (limited to 'crypto/evp/mac_lib.c')
-rw-r--r-- | crypto/evp/mac_lib.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index b7bfe8921f..a5c1b44666 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -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; } /* |