diff options
author | tb <> | 2024-06-01 07:36:17 +0000 |
---|---|---|
committer | tb <> | 2024-06-01 07:36:17 +0000 |
commit | f3bc6c83f92ef9b23bfc523ef1b24bfa27e1f6e4 (patch) | |
tree | d92a9fa364845580193b9ab3f5f391408342fa26 /src/lib/libcrypto/sha/sha.h | |
parent | aee2754cfbb89d3dff4c3a521fb027d0c6967bc9 (diff) | |
download | openbsd-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.h | 7 |
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))); |
103 | int SHA1_Final(unsigned char *md, SHA_CTX *c); | 103 | int SHA1_Final(unsigned char *md, SHA_CTX *c); |
104 | unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) | 104 | unsigned 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))); |
106 | void SHA1_Transform(SHA_CTX *c, const unsigned char *data); | 107 | void 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))); |
126 | int SHA224_Final(unsigned char *md, SHA256_CTX *c); | 127 | int SHA224_Final(unsigned char *md, SHA256_CTX *c); |
127 | unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md) | 128 | unsigned 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))); |
129 | int SHA256_Init(SHA256_CTX *c); | 131 | int SHA256_Init(SHA256_CTX *c); |
130 | int SHA256_Update(SHA256_CTX *c, const void *data, size_t len) | 132 | int SHA256_Update(SHA256_CTX *c, const void *data, size_t len) |
131 | __attribute__ ((__bounded__(__buffer__, 2, 3))); | 133 | __attribute__ ((__bounded__(__buffer__, 2, 3))); |
132 | int SHA256_Final(unsigned char *md, SHA256_CTX *c); | 134 | int SHA256_Final(unsigned char *md, SHA256_CTX *c); |
133 | unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md) | 135 | unsigned 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))); |
135 | void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); | 138 | void 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))); |
173 | int SHA384_Final(unsigned char *md, SHA512_CTX *c); | 176 | int SHA384_Final(unsigned char *md, SHA512_CTX *c); |
174 | unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md) | 177 | unsigned 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))); |
176 | int SHA512_Init(SHA512_CTX *c); | 180 | int SHA512_Init(SHA512_CTX *c); |
177 | int SHA512_Update(SHA512_CTX *c, const void *data, size_t len) | 181 | int SHA512_Update(SHA512_CTX *c, const void *data, size_t len) |
178 | __attribute__ ((__bounded__(__buffer__, 2, 3))); | 182 | __attribute__ ((__bounded__(__buffer__, 2, 3))); |
179 | int SHA512_Final(unsigned char *md, SHA512_CTX *c); | 183 | int SHA512_Final(unsigned char *md, SHA512_CTX *c); |
180 | unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md) | 184 | unsigned 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))); |
182 | void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); | 187 | void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); |
183 | #endif | 188 | #endif |