From f3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 1 Jun 2024 07:36:17 +0000 Subject: Remove support for static buffers in HMAC/digests HMAC() and the one-step digests used to support passing a NULL buffer and would return the digest in a static buffer. This design is firmly from the nineties, not thread safe and it saves callers a single line. The few ports that used to rely this were fixed with patches sent to non-hostile (and non-dead) upstreams. It's early enough in the release cycle that remaining uses hidden from the compiler should be caught, at least the ones that matter. There won't be that many since BoringSSL removed this feature in 2017. https://boringssl-review.googlesource.com/14528 Add non-null attributes to the headers and add a few missing bounded attributes. ok beck jsing --- src/lib/libcrypto/whrlpool/whirlpool.c | 5 +---- src/lib/libcrypto/whrlpool/whrlpool.h | 9 ++++++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/lib/libcrypto/whrlpool') diff --git a/src/lib/libcrypto/whrlpool/whirlpool.c b/src/lib/libcrypto/whrlpool/whirlpool.c index e1e0f7a899..80e147c3b5 100644 --- a/src/lib/libcrypto/whrlpool/whirlpool.c +++ b/src/lib/libcrypto/whrlpool/whirlpool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: whirlpool.c,v 1.2 2024/03/30 03:45:47 joshua Exp $ */ +/* $OpenBSD: whirlpool.c,v 1.3 2024/06/01 07:36:17 tb Exp $ */ /** * The Whirlpool hashing function. * @@ -846,10 +846,7 @@ unsigned char * WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md) { WHIRLPOOL_CTX ctx; - static unsigned char m[WHIRLPOOL_DIGEST_LENGTH]; - if (md == NULL) - md = m; WHIRLPOOL_Init(&ctx); WHIRLPOOL_Update(&ctx, inp, bytes); WHIRLPOOL_Final(md, &ctx); diff --git a/src/lib/libcrypto/whrlpool/whrlpool.h b/src/lib/libcrypto/whrlpool/whrlpool.h index 875d34f7d3..1b4fac1993 100644 --- a/src/lib/libcrypto/whrlpool/whrlpool.h +++ b/src/lib/libcrypto/whrlpool/whrlpool.h @@ -1,4 +1,4 @@ -/* $OpenBSD: whrlpool.h,v 1.5 2014/07/10 22:45:58 jsing Exp $ */ +/* $OpenBSD: whrlpool.h,v 1.6 2024/06/01 07:36:17 tb Exp $ */ #include @@ -28,10 +28,13 @@ typedef struct { #ifndef OPENSSL_NO_WHIRLPOOL int WHIRLPOOL_Init (WHIRLPOOL_CTX *c); -int WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *inp,size_t bytes); +int WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *inp,size_t bytes) + __attribute__ ((__bounded__(__buffer__, 2, 3))); void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *inp,size_t bits); int WHIRLPOOL_Final (unsigned char *md,WHIRLPOOL_CTX *c); -unsigned char *WHIRLPOOL(const void *inp,size_t bytes,unsigned char *md); +unsigned char *WHIRLPOOL(const void *inp,size_t bytes,unsigned char *md) + __attribute__ ((__nonnull__(3))) + __attribute__ ((__bounded__(__buffer__, 1, 2))); #endif #ifdef __cplusplus -- cgit v1.2.3-55-g6feb