summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha/sha256.c
diff options
context:
space:
mode:
authortb <>2024-06-01 07:36:17 +0000
committertb <>2024-06-01 07:36:17 +0000
commitf3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4 (patch)
treed92a9fa364845580193b9ab3f5f391408342fa26 /src/lib/libcrypto/sha/sha256.c
parentaee2754cfbb89d3dff4c3a521fb027d0c6967bc9 (diff)
downloadopenbsd-f3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4.tar.gz
openbsd-f3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4.tar.bz2
openbsd-f3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4.zip
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
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/sha/sha256.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c
index d18e8d219d..ab00c17878 100644
--- a/src/lib/libcrypto/sha/sha256.c
+++ b/src/lib/libcrypto/sha/sha256.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha256.c,v 1.31 2024/03/28 04:23:02 jsing Exp $ */ 1/* $OpenBSD: sha256.c,v 1.32 2024/06/01 07:36:16 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -317,10 +317,6 @@ unsigned char *
317SHA224(const unsigned char *d, size_t n, unsigned char *md) 317SHA224(const unsigned char *d, size_t n, unsigned char *md)
318{ 318{
319 SHA256_CTX c; 319 SHA256_CTX c;
320 static unsigned char m[SHA224_DIGEST_LENGTH];
321
322 if (md == NULL)
323 md = m;
324 320
325 SHA224_Init(&c); 321 SHA224_Init(&c);
326 SHA256_Update(&c, d, n); 322 SHA256_Update(&c, d, n);
@@ -479,10 +475,6 @@ unsigned char *
479SHA256(const unsigned char *d, size_t n, unsigned char *md) 475SHA256(const unsigned char *d, size_t n, unsigned char *md)
480{ 476{
481 SHA256_CTX c; 477 SHA256_CTX c;
482 static unsigned char m[SHA256_DIGEST_LENGTH];
483
484 if (md == NULL)
485 md = m;
486 478
487 SHA256_Init(&c); 479 SHA256_Init(&c);
488 SHA256_Update(&c, d, n); 480 SHA256_Update(&c, d, n);