siphash: Fail finalization on uninitialized siphash context
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)
diff --git a/crypto/siphash/siphash.c b/crypto/siphash/siphash.c
index 7584255..bb4c392 100644
--- a/crypto/siphash/siphash.c
+++ b/crypto/siphash/siphash.c
@@ -204,7 +204,7 @@
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) {