]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
siphash: Fail finalization on uninitialized siphash context
authorTomas Mraz <tomas@openssl.org>
Thu, 21 Apr 2022 15:07:40 +0000 (17:07 +0200)
committerTomas Mraz <tomas@openssl.org>
Wed, 27 Apr 2022 08:04:53 +0000 (10:04 +0200)
Fixes #18140

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18142)

crypto/siphash/siphash.c

index 7584255709d6bfaecd1cf73646c7a8ce7480f9fd..bb4c3925af93ccf5e3e02ece48945f74aa936324 100644 (file)
@@ -204,7 +204,7 @@ int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen)
     uint64_t v2 = ctx->v2;
     uint64_t v3 = ctx->v3;
 
-    if (outlen != (size_t)ctx->hash_size)
+    if (ctx->crounds == 0 || outlen == 0 || outlen != (size_t)ctx->hash_size)
         return 0;
 
     switch (ctx->len) {