Revert md_len removal from SHA256_CTX and SHA512_CTX. This reverts commits: - 91586371422dae70481c39752e55f01f50e9a93a - a90aa643024459c1698dbec84f4c79a3238b3db8 - c0d8b83b4462a0eb1889f32dbd7f46e83f4dbc81 It turns out code outside of BoringSSL also mismatches Init and Update/Final functions. Since this is largely cosmetic, it's probably not worth the cost to do this. Change-Id: I14e7b299172939f69ced2114be45ccba1dbbb704 Reviewed-on: https://boringssl-review.googlesource.com/7793 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/sha.h b/include/openssl/sha.h index 6e3df8f..48a52e8 100644 --- a/include/openssl/sha.h +++ b/include/openssl/sha.h
@@ -128,15 +128,15 @@ /* SHA224_DIGEST_LENGTH is the length of a SHA-224 digest. */ #define SHA224_DIGEST_LENGTH 28 -/* SHA224_Init initialises |sha| and returns one. */ +/* SHA224_Init initialises |sha| and returns 1. */ OPENSSL_EXPORT int SHA224_Init(SHA256_CTX *sha); -/* SHA224_Update adds |len| bytes from |data| to |sha| and returns one. */ +/* SHA224_Update adds |len| bytes from |data| to |sha| and returns 1. */ 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 - * returns one. */ + * returns one on success and zero on programmer error. */ OPENSSL_EXPORT int SHA224_Final(uint8_t *md, SHA256_CTX *sha); /* SHA224 writes the digest of |len| bytes from |data| to |out| and returns @@ -153,15 +153,15 @@ /* SHA256_DIGEST_LENGTH is the length of a SHA-256 digest. */ #define SHA256_DIGEST_LENGTH 32 -/* SHA256_Init initialises |sha| and returns one. */ +/* SHA256_Init initialises |sha| and returns 1. */ OPENSSL_EXPORT int SHA256_Init(SHA256_CTX *sha); -/* SHA256_Update adds |len| bytes from |data| to |sha| and returns one. */ +/* SHA256_Update adds |len| bytes from |data| to |sha| and returns 1. */ 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 - * returns one. */ + * returns one on success and zero on programmer error. */ OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha); /* SHA256 writes the digest of |len| bytes from |data| to |out| and returns @@ -177,7 +177,7 @@ uint32_t h[8]; uint32_t Nl, Nh; uint8_t data[SHA256_CBLOCK]; - unsigned num; + unsigned num, md_len; }; @@ -189,15 +189,15 @@ /* SHA384_DIGEST_LENGTH is the length of a SHA-384 digest. */ #define SHA384_DIGEST_LENGTH 48 -/* SHA384_Init initialises |sha| and returns one. */ +/* SHA384_Init initialises |sha| and returns 1. */ OPENSSL_EXPORT int SHA384_Init(SHA512_CTX *sha); -/* SHA384_Update adds |len| bytes from |data| to |sha| and returns one. */ +/* SHA384_Update adds |len| bytes from |data| to |sha| and returns 1. */ 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 - * returns one. */ + * returns one on success and zero on programmer error. */ OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha); /* SHA384 writes the digest of |len| bytes from |data| to |out| and returns @@ -218,15 +218,15 @@ /* SHA512_DIGEST_LENGTH is the length of a SHA-512 digest. */ #define SHA512_DIGEST_LENGTH 64 -/* SHA512_Init initialises |sha| and returns one. */ +/* SHA512_Init initialises |sha| and returns 1. */ OPENSSL_EXPORT int SHA512_Init(SHA512_CTX *sha); -/* SHA512_Update adds |len| bytes from |data| to |sha| and returns one. */ +/* SHA512_Update adds |len| bytes from |data| to |sha| and returns 1. */ 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 - * returns one. */ + * returns one on success and zero on programmer error. */ OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha); /* SHA512 writes the digest of |len| bytes from |data| to |out| and returns @@ -245,7 +245,7 @@ uint64_t d[16]; uint8_t p[128]; } u; - unsigned num; + unsigned num, md_len; };