diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c index f4730463..355011f5 100644 --- a/crypto/sha/sha512.c +++ b/crypto/sha/sha512.c @@ -164,14 +164,14 @@ 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 *data) { +void SHA512_Transform(SHA512_CTX *c, const uint8_t *block) { #ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA - if ((size_t)data % sizeof(c->u.d[0]) != 0) { - memcpy(c->u.p, data, sizeof(c->u.p)); - data = c->u.p; + if ((size_t)block % sizeof(c->u.d[0]) != 0) { + memcpy(c->u.p, block, sizeof(c->u.p)); + block = c->u.p; } #endif - sha512_block_data_order(c->h, (uint64_t *)data, 1); + sha512_block_data_order(c->h, (uint64_t *)block, 1); } int SHA512_Update(SHA512_CTX *c, const void *in_data, size_t len) { diff --git a/include/openssl/sha.h b/include/openssl/sha.h index 48a52e8f..2ddcb62b 100644 --- a/include/openssl/sha.h +++ b/include/openssl/sha.h @@ -94,7 +94,8 @@ OPENSSL_EXPORT int SHA1_Final(uint8_t *md, SHA_CTX *sha); OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out); /* SHA1_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |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); struct sha_state_st { @@ -169,9 +170,10 @@ OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha); * |out|. */ OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out); -/* SHA256_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, const uint8_t *data); +/* 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); struct sha256_state_st { uint32_t h[8]; @@ -205,9 +207,10 @@ OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha); * |out|. */ OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out); -/* SHA384_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA384_Transform(SHA512_CTX *sha, const uint8_t *data); +/* SHA384_Transform is a low-level function that performs a single, SHA-384 + * block transformation using the state from |sha| and |SHA384_CBLOCK| bytes + * from |block|. */ +OPENSSL_EXPORT void SHA384_Transform(SHA512_CTX *sha, const uint8_t *block); /* SHA-512. */ @@ -234,9 +237,10 @@ OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha); * |out|. */ OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out); -/* SHA512_Transform is a low-level function that performs a single, SHA-1 block - * transformation using the state from |sha| and 64 bytes from |block|. */ -OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, const uint8_t *data); +/* 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); struct sha512_state_st { uint64_t h[8];