summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha/sha.h
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/sha.h
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/sha.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h
index e1de79f4f4..f87203d912 100644
--- a/src/lib/libcrypto/sha/sha.h
+++ b/src/lib/libcrypto/sha/sha.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha.h,v 1.22 2023/07/08 07:08:11 jsing Exp $ */ 1/* $OpenBSD: sha.h,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 *
@@ -102,6 +102,7 @@ int SHA1_Update(SHA_CTX *c, const void *data, size_t len)
102 __attribute__ ((__bounded__(__buffer__, 2, 3))); 102 __attribute__ ((__bounded__(__buffer__, 2, 3)));
103int SHA1_Final(unsigned char *md, SHA_CTX *c); 103int SHA1_Final(unsigned char *md, SHA_CTX *c);
104unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) 104unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
105 __attribute__ ((__nonnull__(3)))
105 __attribute__ ((__bounded__(__buffer__, 1, 2))); 106 __attribute__ ((__bounded__(__buffer__, 1, 2)));
106void SHA1_Transform(SHA_CTX *c, const unsigned char *data); 107void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
107#endif 108#endif
@@ -125,12 +126,14 @@ int SHA224_Update(SHA256_CTX *c, const void *data, size_t len)
125 __attribute__ ((__bounded__(__buffer__, 2, 3))); 126 __attribute__ ((__bounded__(__buffer__, 2, 3)));
126int SHA224_Final(unsigned char *md, SHA256_CTX *c); 127int SHA224_Final(unsigned char *md, SHA256_CTX *c);
127unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md) 128unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md)
129 __attribute__ ((__nonnull__(3)))
128 __attribute__ ((__bounded__(__buffer__, 1, 2))); 130 __attribute__ ((__bounded__(__buffer__, 1, 2)));
129int SHA256_Init(SHA256_CTX *c); 131int SHA256_Init(SHA256_CTX *c);
130int SHA256_Update(SHA256_CTX *c, const void *data, size_t len) 132int SHA256_Update(SHA256_CTX *c, const void *data, size_t len)
131 __attribute__ ((__bounded__(__buffer__, 2, 3))); 133 __attribute__ ((__bounded__(__buffer__, 2, 3)));
132int SHA256_Final(unsigned char *md, SHA256_CTX *c); 134int SHA256_Final(unsigned char *md, SHA256_CTX *c);
133unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md) 135unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md)
136 __attribute__ ((__nonnull__(3)))
134 __attribute__ ((__bounded__(__buffer__, 1, 2))); 137 __attribute__ ((__bounded__(__buffer__, 1, 2)));
135void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); 138void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
136#endif 139#endif
@@ -172,12 +175,14 @@ int SHA384_Update(SHA512_CTX *c, const void *data, size_t len)
172 __attribute__ ((__bounded__(__buffer__, 2, 3))); 175 __attribute__ ((__bounded__(__buffer__, 2, 3)));
173int SHA384_Final(unsigned char *md, SHA512_CTX *c); 176int SHA384_Final(unsigned char *md, SHA512_CTX *c);
174unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md) 177unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md)
178 __attribute__ ((__nonnull__(3)))
175 __attribute__ ((__bounded__(__buffer__, 1, 2))); 179 __attribute__ ((__bounded__(__buffer__, 1, 2)));
176int SHA512_Init(SHA512_CTX *c); 180int SHA512_Init(SHA512_CTX *c);
177int SHA512_Update(SHA512_CTX *c, const void *data, size_t len) 181int SHA512_Update(SHA512_CTX *c, const void *data, size_t len)
178 __attribute__ ((__bounded__(__buffer__, 2, 3))); 182 __attribute__ ((__bounded__(__buffer__, 2, 3)));
179int SHA512_Final(unsigned char *md, SHA512_CTX *c); 183int SHA512_Final(unsigned char *md, SHA512_CTX *c);
180unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md) 184unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md)
185 __attribute__ ((__nonnull__(3)))
181 __attribute__ ((__bounded__(__buffer__, 1, 2))); 186 __attribute__ ((__bounded__(__buffer__, 1, 2)));
182void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); 187void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
183#endif 188#endif