summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md5
diff options
context:
space:
mode:
authortb <>2024-06-01 07:36:17 +0000
committertb <>2024-06-01 07:36:17 +0000
commit0cd26255605cab2a8643bb8585c4148069240e3c (patch)
treed92a9fa364845580193b9ab3f5f391408342fa26 /src/lib/libcrypto/md5
parent31276a6e8ec689c1b9317a14b7e50282982b2150 (diff)
downloadopenbsd-0cd26255605cab2a8643bb8585c4148069240e3c.tar.gz
openbsd-0cd26255605cab2a8643bb8585c4148069240e3c.tar.bz2
openbsd-0cd26255605cab2a8643bb8585c4148069240e3c.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 'src/lib/libcrypto/md5')
-rw-r--r--src/lib/libcrypto/md5/md5.c5
-rw-r--r--src/lib/libcrypto/md5/md5.h3
2 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c
index 35d1ac9144..744c66f005 100644
--- a/src/lib/libcrypto/md5/md5.c
+++ b/src/lib/libcrypto/md5/md5.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: md5.c,v 1.22 2024/03/28 08:00:08 jsing Exp $ */ 1/* $OpenBSD: md5.c,v 1.23 2024/06/01 07:36:16 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -371,10 +371,7 @@ unsigned char *
371MD5(const unsigned char *d, size_t n, unsigned char *md) 371MD5(const unsigned char *d, size_t n, unsigned char *md)
372{ 372{
373 MD5_CTX c; 373 MD5_CTX c;
374 static unsigned char m[MD5_DIGEST_LENGTH];
375 374
376 if (md == NULL)
377 md = m;
378 if (!MD5_Init(&c)) 375 if (!MD5_Init(&c))
379 return NULL; 376 return NULL;
380 MD5_Update(&c, d, n); 377 MD5_Update(&c, d, n);
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index d248c93a85..9191ff2131 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: md5.h,v 1.21 2023/07/08 06:50:38 jsing Exp $ */ 1/* $OpenBSD: md5.h,v 1.22 2024/06/01 07:36:16 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -98,6 +98,7 @@ int MD5_Update(MD5_CTX *c, const void *data, size_t len)
98 __attribute__ ((__bounded__(__buffer__, 2, 3))); 98 __attribute__ ((__bounded__(__buffer__, 2, 3)));
99int MD5_Final(unsigned char *md, MD5_CTX *c); 99int MD5_Final(unsigned char *md, MD5_CTX *c);
100unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) 100unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
101 __attribute__ ((__nonnull__(3)))
101 __attribute__ ((__bounded__(__buffer__, 1, 2))); 102 __attribute__ ((__bounded__(__buffer__, 1, 2)));
102void MD5_Transform(MD5_CTX *c, const unsigned char *b); 103void MD5_Transform(MD5_CTX *c, const unsigned char *b);
103#ifdef __cplusplus 104#ifdef __cplusplus