diff options
author | asomers <asomers@FreeBSD.org> | 2016-11-22 20:28:17 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-11-22 20:28:17 +0000 |
commit | 88e93daae771bcd26c329f87f9f443c02e47c7e4 (patch) | |
tree | e6721be614ef89478cfcbe059422f36ce59a3371 /sys/crypto/sha2 | |
parent | 25a075724c584e1686b323f7a28f493e9d4b2c96 (diff) | |
download | FreeBSD-src-88e93daae771bcd26c329f87f9f443c02e47c7e4.zip FreeBSD-src-88e93daae771bcd26c329f87f9f443c02e47c7e4.tar.gz |
MFC r307584
Fix C++ includability of crypto headers with static array sizes
C99 allows array function parameters to use the static keyword for their
sizes. This tells the compiler that the parameter will have at least the
specified size, and calling code will fail to compile if that guarantee is
not met. However, this syntax is not legal in C++.
This commit reverts r300824, which worked around the problem for
sys/sys/md5.h only, and introduces a new macro: min_size(). min_size(x) can
be used in headers as a static array size, but will still compile in C++
mode.
Diffstat (limited to 'sys/crypto/sha2')
-rw-r--r-- | sys/crypto/sha2/sha256.h | 3 | ||||
-rw-r--r-- | sys/crypto/sha2/sha384.h | 3 | ||||
-rw-r--r-- | sys/crypto/sha2/sha512.h | 3 | ||||
-rw-r--r-- | sys/crypto/sha2/sha512t.h | 6 |
4 files changed, 10 insertions, 5 deletions
diff --git a/sys/crypto/sha2/sha256.h b/sys/crypto/sha2/sha256.h index 17aae7d..ca67cae 100644 --- a/sys/crypto/sha2/sha256.h +++ b/sys/crypto/sha2/sha256.h @@ -78,7 +78,8 @@ __BEGIN_DECLS void SHA256_Init(SHA256_CTX *); void SHA256_Update(SHA256_CTX *, const void *, size_t); -void SHA256_Final(unsigned char [static SHA256_DIGEST_LENGTH], SHA256_CTX *); +void SHA256_Final(unsigned char [__min_size(SHA256_DIGEST_LENGTH)], + SHA256_CTX *); #ifndef _KERNEL char *SHA256_End(SHA256_CTX *, char *); char *SHA256_Data(const void *, unsigned int, char *); diff --git a/sys/crypto/sha2/sha384.h b/sys/crypto/sha2/sha384.h index 63dd948..2f21ee7 100644 --- a/sys/crypto/sha2/sha384.h +++ b/sys/crypto/sha2/sha384.h @@ -74,7 +74,8 @@ __BEGIN_DECLS void SHA384_Init(SHA384_CTX *); void SHA384_Update(SHA384_CTX *, const void *, size_t); -void SHA384_Final(unsigned char [static SHA384_DIGEST_LENGTH], SHA384_CTX *); +void SHA384_Final(unsigned char [__min_size(SHA384_DIGEST_LENGTH)], + SHA384_CTX *); #ifndef _KERNEL char *SHA384_End(SHA384_CTX *, char *); char *SHA384_Data(const void *, unsigned int, char *); diff --git a/sys/crypto/sha2/sha512.h b/sys/crypto/sha2/sha512.h index b008aea..174f11f 100644 --- a/sys/crypto/sha2/sha512.h +++ b/sys/crypto/sha2/sha512.h @@ -77,7 +77,8 @@ __BEGIN_DECLS void SHA512_Init(SHA512_CTX *); void SHA512_Update(SHA512_CTX *, const void *, size_t); -void SHA512_Final(unsigned char [static SHA512_DIGEST_LENGTH], SHA512_CTX *); +void SHA512_Final(unsigned char [__min_size(SHA512_DIGEST_LENGTH)], + SHA512_CTX *); #ifndef _KERNEL char *SHA512_End(SHA512_CTX *, char *); char *SHA512_Data(const void *, unsigned int, char *); diff --git a/sys/crypto/sha2/sha512t.h b/sys/crypto/sha2/sha512t.h index 3f0c921..d5da5f0 100644 --- a/sys/crypto/sha2/sha512t.h +++ b/sys/crypto/sha2/sha512t.h @@ -103,7 +103,8 @@ __BEGIN_DECLS void SHA512_224_Init(SHA512_CTX *); void SHA512_224_Update(SHA512_CTX *, const void *, size_t); -void SHA512_224_Final(unsigned char [static SHA512_224_DIGEST_LENGTH], SHA512_CTX *); +void SHA512_224_Final(unsigned char [__min_size(SHA512_224_DIGEST_LENGTH)], + SHA512_CTX *); #ifndef _KERNEL char *SHA512_224_End(SHA512_CTX *, char *); char *SHA512_224_Data(const void *, unsigned int, char *); @@ -112,7 +113,8 @@ char *SHA512_224_FileChunk(const char *, char *, off_t, off_t); #endif void SHA512_256_Init(SHA512_CTX *); void SHA512_256_Update(SHA512_CTX *, const void *, size_t); -void SHA512_256_Final(unsigned char [static SHA512_256_DIGEST_LENGTH], SHA512_CTX *); +void SHA512_256_Final(unsigned char [__min_size(SHA512_256_DIGEST_LENGTH)], + SHA512_CTX *); #ifndef _KERNEL char *SHA512_256_End(SHA512_CTX *, char *); char *SHA512_256_Data(const void *, unsigned int, char *); |