Rename 'md' output parameter to 'out' and add bounds. We usually name output parameters 'out'. (Someone made a C++ templating change in Chromium which messed up const-ness, saw the compile error, and thought it was in MD5_Final.) Also tag the parameters with the sizes. Sadly, there's a bit of goofiness around SHA224_Final/SHA256_Final and SHA384_Final/SHA512_Final, but they're just documentation anyway. (Though it does touch on the mess that is sha->md_len which would be nice to clear through somehow.) Change-Id: I1918b7eecfe13f13b217d01d4414ac2358802354 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35484 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/fipsmodule/digest/md32_common.h b/crypto/fipsmodule/digest/md32_common.h index a0c3665..07d39d9 100644 --- a/crypto/fipsmodule/digest/md32_common.h +++ b/crypto/fipsmodule/digest/md32_common.h
@@ -223,12 +223,12 @@ } -void HASH_TRANSFORM(HASH_CTX *c, const uint8_t *data) { +void HASH_TRANSFORM(HASH_CTX *c, const uint8_t data[HASH_CBLOCK]) { HASH_BLOCK_DATA_ORDER(c->h, data, 1); } -int HASH_FINAL(uint8_t *md, HASH_CTX *c) { +int HASH_FINAL(uint8_t out[HASH_DIGEST_LENGTH], HASH_CTX *c) { // |c->data| always has room for at least one byte. A full block would have // been consumed. size_t n = c->num; @@ -258,7 +258,7 @@ c->num = 0; OPENSSL_memset(c->data, 0, HASH_CBLOCK); - HASH_MAKE_STRING(c, md); + HASH_MAKE_STRING(c, out); return 1; }
diff --git a/crypto/fipsmodule/md4/md4.c b/crypto/fipsmodule/md4/md4.c index f0c1dcd..cc2a631 100644 --- a/crypto/fipsmodule/md4/md4.c +++ b/crypto/fipsmodule/md4/md4.c
@@ -62,7 +62,7 @@ #include "../../internal.h" -uint8_t *MD4(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *MD4(const uint8_t *data, size_t len, uint8_t out[MD4_DIGEST_LENGTH]) { MD4_CTX ctx; MD4_Init(&ctx); MD4_Update(&ctx, data, len); @@ -88,6 +88,7 @@ #define HASH_CTX MD4_CTX #define HASH_CBLOCK 64 +#define HASH_DIGEST_LENGTH 16 #define HASH_UPDATE MD4_Update #define HASH_TRANSFORM MD4_Transform #define HASH_FINAL MD4_Final @@ -238,6 +239,7 @@ #undef DATA_ORDER_IS_LITTLE_ENDIAN #undef HASH_CTX #undef HASH_CBLOCK +#undef HASH_DIGEST_LENGTH #undef HASH_UPDATE #undef HASH_TRANSFORM #undef HASH_FINAL
diff --git a/crypto/fipsmodule/md5/md5.c b/crypto/fipsmodule/md5/md5.c index 66c65a6..a48d704 100644 --- a/crypto/fipsmodule/md5/md5.c +++ b/crypto/fipsmodule/md5/md5.c
@@ -64,7 +64,7 @@ #include "../../internal.h" -uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *MD5(const uint8_t *data, size_t len, uint8_t out[MD5_DIGEST_LENGTH]) { MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, data, len); @@ -94,6 +94,7 @@ #define HASH_CTX MD5_CTX #define HASH_CBLOCK 64 +#define HASH_DIGEST_LENGTH 16 #define HASH_UPDATE MD5_Update #define HASH_TRANSFORM MD5_Transform #define HASH_FINAL MD5_Final @@ -281,6 +282,7 @@ #undef DATA_ORDER_IS_LITTLE_ENDIAN #undef HASH_CTX #undef HASH_CBLOCK +#undef HASH_DIGEST_LENGTH #undef HASH_UPDATE #undef HASH_TRANSFORM #undef HASH_FINAL
diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index a3b771a..cc1243b 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c
@@ -74,7 +74,7 @@ return 1; } -uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) { SHA_CTX ctx; SHA1_Init(&ctx); SHA1_Update(&ctx, data, len); @@ -87,6 +87,7 @@ #define HASH_CTX SHA_CTX #define HASH_CBLOCK 64 +#define HASH_DIGEST_LENGTH 20 #define HASH_MAKE_STRING(c, s) \ do { \ uint32_t ll; \ @@ -343,6 +344,7 @@ #undef DATA_ORDER_IS_BIG_ENDIAN #undef HASH_CTX #undef HASH_CBLOCK +#undef HASH_DIGEST_LENGTH #undef HASH_MAKE_STRING #undef HASH_UPDATE #undef HASH_TRANSFORM
diff --git a/crypto/fipsmodule/sha/sha256.c b/crypto/fipsmodule/sha/sha256.c index 92a5295..0e42446 100644 --- a/crypto/fipsmodule/sha/sha256.c +++ b/crypto/fipsmodule/sha/sha256.c
@@ -92,7 +92,8 @@ return 1; } -uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *SHA224(const uint8_t *data, size_t len, + uint8_t out[SHA224_DIGEST_LENGTH]) { SHA256_CTX ctx; SHA224_Init(&ctx); SHA224_Update(&ctx, data, len); @@ -101,7 +102,8 @@ return out; } -uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *SHA256(const uint8_t *data, size_t len, + uint8_t out[SHA256_DIGEST_LENGTH]) { SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, data, len); @@ -114,14 +116,17 @@ return SHA256_Update(ctx, data, len); } -int SHA224_Final(uint8_t *md, SHA256_CTX *ctx) { - return SHA256_Final(md, ctx); +int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx) { + // SHA224_Init sets |ctx->md_len| to |SHA224_DIGEST_LENGTH|, so this has a + // smaller output. + return SHA256_Final(out, ctx); } #define DATA_ORDER_IS_BIG_ENDIAN #define HASH_CTX SHA256_CTX #define HASH_CBLOCK 64 +#define HASH_DIGEST_LENGTH 32 // Note that FIPS180-2 discusses "Truncation of the Hash Function Output." // default: case below covers for it. It's not clear however if it's permitted @@ -319,6 +324,7 @@ #undef DATA_ORDER_IS_BIG_ENDIAN #undef HASH_CTX #undef HASH_CBLOCK +#undef HASH_DIGEST_LENGTH #undef HASH_MAKE_STRING #undef HASH_UPDATE #undef HASH_TRANSFORM
diff --git a/crypto/fipsmodule/sha/sha512.c b/crypto/fipsmodule/sha/sha512.c index f96cfbd..848f3b6 100644 --- a/crypto/fipsmodule/sha/sha512.c +++ b/crypto/fipsmodule/sha/sha512.c
@@ -105,7 +105,8 @@ return 1; } -uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *SHA384(const uint8_t *data, size_t len, + uint8_t out[SHA384_DIGEST_LENGTH]) { SHA512_CTX ctx; SHA384_Init(&ctx); SHA384_Update(&ctx, data, len); @@ -114,7 +115,8 @@ return out; } -uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out) { +uint8_t *SHA512(const uint8_t *data, size_t len, + uint8_t out[SHA512_DIGEST_LENGTH]) { SHA512_CTX ctx; SHA512_Init(&ctx); SHA512_Update(&ctx, data, len); @@ -129,15 +131,17 @@ #endif -int SHA384_Final(uint8_t *md, SHA512_CTX *sha) { - return SHA512_Final(md, sha); +int SHA384_Final(uint8_t out[SHA384_DIGEST_LENGTH], SHA512_CTX *sha) { + // |SHA384_Init| sets |sha->md_len| to |SHA384_DIGEST_LENGTH|, so this has a + // |smaller output. + return SHA512_Final(out, sha); } int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len) { return SHA512_Update(sha, data, len); } -void SHA512_Transform(SHA512_CTX *c, const uint8_t *block) { +void SHA512_Transform(SHA512_CTX *c, const uint8_t block[SHA512_CBLOCK]) { sha512_block_data_order(c->h, block, 1); } @@ -189,7 +193,7 @@ return 1; } -int SHA512_Final(uint8_t *md, SHA512_CTX *sha) { +int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH], SHA512_CTX *sha) { uint8_t *p = sha->p; size_t n = sha->num; @@ -221,7 +225,7 @@ sha512_block_data_order(sha->h, p, 1); - if (md == NULL) { + if (out == NULL) { // TODO(davidben): This NULL check is absent in other low-level hash 'final' // functions and is one of the few places one can fail. return 0; @@ -233,28 +237,28 @@ for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) { uint64_t t = sha->h[n]; - *(md++) = (uint8_t)(t >> 56); - *(md++) = (uint8_t)(t >> 48); - *(md++) = (uint8_t)(t >> 40); - *(md++) = (uint8_t)(t >> 32); - *(md++) = (uint8_t)(t >> 24); - *(md++) = (uint8_t)(t >> 16); - *(md++) = (uint8_t)(t >> 8); - *(md++) = (uint8_t)(t); + *(out++) = (uint8_t)(t >> 56); + *(out++) = (uint8_t)(t >> 48); + *(out++) = (uint8_t)(t >> 40); + *(out++) = (uint8_t)(t >> 32); + *(out++) = (uint8_t)(t >> 24); + *(out++) = (uint8_t)(t >> 16); + *(out++) = (uint8_t)(t >> 8); + *(out++) = (uint8_t)(t); } break; case SHA512_DIGEST_LENGTH: for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) { uint64_t t = sha->h[n]; - *(md++) = (uint8_t)(t >> 56); - *(md++) = (uint8_t)(t >> 48); - *(md++) = (uint8_t)(t >> 40); - *(md++) = (uint8_t)(t >> 32); - *(md++) = (uint8_t)(t >> 24); - *(md++) = (uint8_t)(t >> 16); - *(md++) = (uint8_t)(t >> 8); - *(md++) = (uint8_t)(t); + *(out++) = (uint8_t)(t >> 56); + *(out++) = (uint8_t)(t >> 48); + *(out++) = (uint8_t)(t >> 40); + *(out++) = (uint8_t)(t >> 32); + *(out++) = (uint8_t)(t >> 24); + *(out++) = (uint8_t)(t >> 16); + *(out++) = (uint8_t)(t >> 8); + *(out++) = (uint8_t)(t); } break; // ... as well as make sure md_len is not abused.
diff --git a/decrepit/ripemd/internal.h b/decrepit/ripemd/internal.h index fe172ca..089be15 100644 --- a/decrepit/ripemd/internal.h +++ b/decrepit/ripemd/internal.h
@@ -54,8 +54,8 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ -#ifndef OPENSSL_HEADER_BN_INTERNAL_H -#define OPENSSL_HEADER_BN_INTERNAL_H +#ifndef OPENSSL_HEADER_RIPEMD_INTERNAL_H +#define OPENSSL_HEADER_RIPEMD_INTERNAL_H #include <openssl/base.h> @@ -72,6 +72,7 @@ #define HASH_LONG uint32_t #define HASH_CTX RIPEMD160_CTX #define HASH_CBLOCK RIPEMD160_CBLOCK +#define HASH_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH #define HASH_UPDATE RIPEMD160_Update #define HASH_TRANSFORM RIPEMD160_Transform #define HASH_FINAL RIPEMD160_Final @@ -490,4 +491,4 @@ } // extern C #endif -#endif // OPENSSL_HEADER_BN_INTERNAL_H +#endif // OPENSSL_HEADER_RIPEMD_INTERNAL_H
diff --git a/decrepit/ripemd/ripemd.c b/decrepit/ripemd/ripemd.c index 275d439..17b3fdf 100644 --- a/decrepit/ripemd/ripemd.c +++ b/decrepit/ripemd/ripemd.c
@@ -311,7 +311,8 @@ #undef X } -uint8_t *RIPEMD160(const uint8_t *data, size_t len, unsigned char *out) { +uint8_t *RIPEMD160(const uint8_t *data, size_t len, + uint8_t out[RIPEMD160_DIGEST_LENGTH]) { RIPEMD160_CTX ctx; if (!RIPEMD160_Init(&ctx)) {
diff --git a/include/openssl/md4.h b/include/openssl/md4.h index 52b88ca..b213bc6 100644 --- a/include/openssl/md4.h +++ b/include/openssl/md4.h
@@ -79,17 +79,19 @@ OPENSSL_EXPORT int MD4_Update(MD4_CTX *md4, const void *data, size_t len); // MD4_Final adds the final padding to |md4| and writes the resulting digest to -// |md|, which must have at least |MD4_DIGEST_LENGTH| bytes of space. It +// |out|, which must have at least |MD4_DIGEST_LENGTH| bytes of space. It // returns one. -OPENSSL_EXPORT int MD4_Final(uint8_t *md, MD4_CTX *md4); +OPENSSL_EXPORT int MD4_Final(uint8_t out[MD4_DIGEST_LENGTH], MD4_CTX *md4); // MD4 writes the digest of |len| bytes from |data| to |out| and returns |out|. // There must be at least |MD4_DIGEST_LENGTH| bytes of space in |out|. -OPENSSL_EXPORT uint8_t *MD4(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *MD4(const uint8_t *data, size_t len, + uint8_t out[MD4_DIGEST_LENGTH]); // MD4_Transform is a low-level function that performs a single, MD4 block // transformation using the state from |md4| and 64 bytes from |block|. -OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4, const uint8_t *block); +OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4, + const uint8_t block[MD4_CBLOCK]); struct md4_state_st { uint32_t h[4];
diff --git a/include/openssl/md5.h b/include/openssl/md5.h index de6027f..5486512 100644 --- a/include/openssl/md5.h +++ b/include/openssl/md5.h
@@ -80,17 +80,19 @@ OPENSSL_EXPORT int MD5_Update(MD5_CTX *md5, const void *data, size_t len); // MD5_Final adds the final padding to |md5| and writes the resulting digest to -// |md|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It +// |out|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It // returns one. -OPENSSL_EXPORT int MD5_Final(uint8_t *md, MD5_CTX *md5); +OPENSSL_EXPORT int MD5_Final(uint8_t out[MD5_DIGEST_LENGTH], MD5_CTX *md5); // MD5 writes the digest of |len| bytes from |data| to |out| and returns |out|. // There must be at least |MD5_DIGEST_LENGTH| bytes of space in |out|. -OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, + uint8_t out[MD5_DIGEST_LENGTH]); // MD5_Transform is a low-level function that performs a single, MD5 block // transformation using the state from |md5| and 64 bytes from |block|. -OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, const uint8_t *block); +OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, + const uint8_t block[MD5_CBLOCK]); struct md5_state_st { uint32_t h[4];
diff --git a/include/openssl/ripemd.h b/include/openssl/ripemd.h index fb0b50c..d859b1f 100644 --- a/include/openssl/ripemd.h +++ b/include/openssl/ripemd.h
@@ -83,21 +83,22 @@ size_t len); // RIPEMD160_Final adds the final padding to |ctx| and writes the resulting -// digest to |md|, which must have at least |RIPEMD160_DIGEST_LENGTH| bytes of +// digest to |out|, which must have at least |RIPEMD160_DIGEST_LENGTH| bytes of // space. It returns one. -OPENSSL_EXPORT int RIPEMD160_Final(uint8_t *md, RIPEMD160_CTX *ctx); +OPENSSL_EXPORT int RIPEMD160_Final(uint8_t out[RIPEMD160_DIGEST_LENGTH], + RIPEMD160_CTX *ctx); // RIPEMD160 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |RIPEMD160_DIGEST_LENGTH| bytes of space in // |out|. OPENSSL_EXPORT uint8_t *RIPEMD160(const uint8_t *data, size_t len, - uint8_t *out); + uint8_t out[RIPEMD160_DIGEST_LENGTH]); // RIPEMD160_Transform is a low-level function that performs a single, // RIPEMD160 block transformation using the state from |ctx| and 64 bytes from // |block|. OPENSSL_EXPORT void RIPEMD160_Transform(RIPEMD160_CTX *ctx, - const uint8_t *block); + const uint8_t block[RIPEMD160_CBLOCK]); #if defined(__cplusplus)
diff --git a/include/openssl/sha.h b/include/openssl/sha.h index c9b327d..b163e6a 100644 --- a/include/openssl/sha.h +++ b/include/openssl/sha.h
@@ -79,20 +79,22 @@ // SHA1_Update adds |len| bytes from |data| to |sha| and returns one. OPENSSL_EXPORT int SHA1_Update(SHA_CTX *sha, const void *data, size_t len); -// SHA1_Final adds the final padding to |sha| and writes the resulting digest -// to |md|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It +// SHA1_Final adds the final padding to |sha| and writes the resulting digest to +// |out|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It // returns one. -OPENSSL_EXPORT int SHA1_Final(uint8_t *md, SHA_CTX *sha); +OPENSSL_EXPORT int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *sha); // SHA1 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |SHA_DIGEST_LENGTH| bytes of space in // |out|. -OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, + uint8_t out[SHA_DIGEST_LENGTH]); // SHA1_Transform is a low-level function that performs a single, SHA-1 block // transformation using the state from |sha| and |SHA_CBLOCK| bytes from // |block|. -OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha, const uint8_t *block); +OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha, + const uint8_t block[SHA_CBLOCK]); struct sha_state_st { #if defined(OPENSSL_WINDOWS) @@ -132,14 +134,16 @@ OPENSSL_EXPORT int SHA224_Update(SHA256_CTX *sha, const void *data, size_t len); // SHA224_Final adds the final padding to |sha| and writes the resulting digest -// to |md|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It +// to |out|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It // returns one on success and zero on programmer error. -OPENSSL_EXPORT int SHA224_Final(uint8_t *md, SHA256_CTX *sha); +OPENSSL_EXPORT int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], + SHA256_CTX *sha); // SHA224 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |SHA224_DIGEST_LENGTH| bytes of space in // |out|. -OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len, + uint8_t out[SHA224_DIGEST_LENGTH]); // SHA-256. @@ -157,19 +161,22 @@ OPENSSL_EXPORT int SHA256_Update(SHA256_CTX *sha, const void *data, size_t len); // SHA256_Final adds the final padding to |sha| and writes the resulting digest -// to |md|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It +// to |out|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It // returns one on success and zero on programmer error. -OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha); +OPENSSL_EXPORT int SHA256_Final(uint8_t out[SHA256_DIGEST_LENGTH], + SHA256_CTX *sha); // SHA256 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |SHA256_DIGEST_LENGTH| bytes of space in // |out|. -OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, + uint8_t out[SHA256_DIGEST_LENGTH]); // SHA256_Transform is a low-level function that performs a single, SHA-256 // block transformation using the state from |sha| and |SHA256_CBLOCK| bytes // from |block|. -OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, const uint8_t *block); +OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, + const uint8_t block[SHA256_CBLOCK]); // SHA256_TransformBlocks is a low-level function that takes |num_blocks| * // |SHA256_CBLOCK| bytes of data and performs SHA-256 transforms on it to update @@ -202,14 +209,16 @@ OPENSSL_EXPORT int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len); // SHA384_Final adds the final padding to |sha| and writes the resulting digest -// to |md|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It +// to |out|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It // returns one on success and zero on programmer error. -OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha); +OPENSSL_EXPORT int SHA384_Final(uint8_t out[SHA384_DIGEST_LENGTH], + SHA512_CTX *sha); // SHA384 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |SHA384_DIGEST_LENGTH| bytes of space in // |out|. -OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, + uint8_t out[SHA384_DIGEST_LENGTH]); // SHA-512. @@ -227,19 +236,22 @@ OPENSSL_EXPORT int SHA512_Update(SHA512_CTX *sha, const void *data, size_t len); // SHA512_Final adds the final padding to |sha| and writes the resulting digest -// to |md|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It +// to |out|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It // returns one on success and zero on programmer error. -OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha); +OPENSSL_EXPORT int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH], + SHA512_CTX *sha); // SHA512 writes the digest of |len| bytes from |data| to |out| and returns // |out|. There must be at least |SHA512_DIGEST_LENGTH| bytes of space in // |out|. -OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out); +OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, + uint8_t out[SHA512_DIGEST_LENGTH]); // SHA512_Transform is a low-level function that performs a single, SHA-512 // block transformation using the state from |sha| and |SHA512_CBLOCK| bytes // from |block|. -OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, const uint8_t *block); +OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, + const uint8_t block[SHA512_CBLOCK]); struct sha512_state_st { uint64_t h[8];