Pull HASH_TRANSFORM out of md32_common.h.

The macro isn't doing any work here.

Change-Id: Id97dfa4b027407c5e4b3e7eb1586c3c2a2d977d8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47806
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
grpc-202302
David Benjamin 4 years ago committed by CQ bot account: commit-bot@chromium.org
parent d4c3f2a599
commit 4320bc4761
  1. 11
      crypto/fipsmodule/digest/md32_common.h
  2. 6
      crypto/fipsmodule/md4/md4.c
  3. 5
      crypto/fipsmodule/md5/md5.c
  4. 16
      crypto/fipsmodule/sha/sha1.c
  5. 15
      crypto/fipsmodule/sha/sha256.c
  6. 6
      decrepit/ripemd/ripemd.c

@ -86,9 +86,6 @@ extern "C" {
// |HASH_UPDATE| must be defined as the name of the "Update" function to // |HASH_UPDATE| must be defined as the name of the "Update" function to
// generate. // generate.
// //
// |HASH_TRANSFORM| must be defined as the the name of the "Transform"
// function to generate.
//
// |HASH_FINAL| must be defined as the name of "Final" function to generate. // |HASH_FINAL| must be defined as the name of "Final" function to generate.
// //
// |HASH_BLOCK_DATA_ORDER| must be defined as the name of the "Block" function. // |HASH_BLOCK_DATA_ORDER| must be defined as the name of the "Block" function.
@ -121,9 +118,6 @@ extern "C" {
#ifndef HASH_UPDATE #ifndef HASH_UPDATE
#error "HASH_UPDATE must be defined!" #error "HASH_UPDATE must be defined!"
#endif #endif
#ifndef HASH_TRANSFORM
#error "HASH_TRANSFORM must be defined!"
#endif
#ifndef HASH_FINAL #ifndef HASH_FINAL
#error "HASH_FINAL must be defined!" #error "HASH_FINAL must be defined!"
#endif #endif
@ -185,11 +179,6 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) {
} }
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 out[HASH_DIGEST_LENGTH], 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 // |c->data| always has room for at least one byte. A full block would have
// been consumed. // been consumed.

@ -84,13 +84,16 @@ int MD4_Init(MD4_CTX *md4) {
void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num); void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num);
void MD4_Transform(MD4_CTX *c, const uint8_t data[MD4_CBLOCK]) {
md4_block_data_order(c->h, data, 1);
}
#define DATA_ORDER_IS_LITTLE_ENDIAN #define DATA_ORDER_IS_LITTLE_ENDIAN
#define HASH_CTX MD4_CTX #define HASH_CTX MD4_CTX
#define HASH_CBLOCK 64 #define HASH_CBLOCK 64
#define HASH_DIGEST_LENGTH 16 #define HASH_DIGEST_LENGTH 16
#define HASH_UPDATE MD4_Update #define HASH_UPDATE MD4_Update
#define HASH_TRANSFORM MD4_Transform
#define HASH_FINAL MD4_Final #define HASH_FINAL MD4_Final
#define HASH_MAKE_STRING(c, s) \ #define HASH_MAKE_STRING(c, s) \
do { \ do { \
@ -240,7 +243,6 @@ void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num) {
#undef HASH_CBLOCK #undef HASH_CBLOCK
#undef HASH_DIGEST_LENGTH #undef HASH_DIGEST_LENGTH
#undef HASH_UPDATE #undef HASH_UPDATE
#undef HASH_TRANSFORM
#undef HASH_FINAL #undef HASH_FINAL
#undef HASH_MAKE_STRING #undef HASH_MAKE_STRING
#undef HASH_BLOCK_DATA_ORDER #undef HASH_BLOCK_DATA_ORDER

@ -89,6 +89,9 @@ static void md5_block_data_order(uint32_t *state, const uint8_t *data,
size_t num); size_t num);
#endif #endif
void MD5_Transform(MD5_CTX *c, const uint8_t data[MD5_CBLOCK]) {
md5_block_data_order(c->h, data, 1);
}
#define DATA_ORDER_IS_LITTLE_ENDIAN #define DATA_ORDER_IS_LITTLE_ENDIAN
@ -96,7 +99,6 @@ static void md5_block_data_order(uint32_t *state, const uint8_t *data,
#define HASH_CBLOCK 64 #define HASH_CBLOCK 64
#define HASH_DIGEST_LENGTH 16 #define HASH_DIGEST_LENGTH 16
#define HASH_UPDATE MD5_Update #define HASH_UPDATE MD5_Update
#define HASH_TRANSFORM MD5_Transform
#define HASH_FINAL MD5_Final #define HASH_FINAL MD5_Final
#define HASH_MAKE_STRING(c, s) \ #define HASH_MAKE_STRING(c, s) \
do { \ do { \
@ -283,7 +285,6 @@ static void md5_block_data_order(uint32_t *state, const uint8_t *data,
#undef HASH_CBLOCK #undef HASH_CBLOCK
#undef HASH_DIGEST_LENGTH #undef HASH_DIGEST_LENGTH
#undef HASH_UPDATE #undef HASH_UPDATE
#undef HASH_TRANSFORM
#undef HASH_FINAL #undef HASH_FINAL
#undef HASH_MAKE_STRING #undef HASH_MAKE_STRING
#undef HASH_BLOCK_DATA_ORDER #undef HASH_BLOCK_DATA_ORDER

@ -83,6 +83,15 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
return out; return out;
} }
#if !defined(SHA1_ASM)
static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
size_t num);
#endif
void SHA1_Transform(SHA_CTX *c, const uint8_t data[SHA_CBLOCK]) {
sha1_block_data_order(c->h, data, 1);
}
#define DATA_ORDER_IS_BIG_ENDIAN #define DATA_ORDER_IS_BIG_ENDIAN
#define HASH_CTX SHA_CTX #define HASH_CTX SHA_CTX
@ -103,7 +112,6 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
} while (0) } while (0)
#define HASH_UPDATE SHA1_Update #define HASH_UPDATE SHA1_Update
#define HASH_TRANSFORM SHA1_Transform
#define HASH_FINAL SHA1_Final #define HASH_FINAL SHA1_Final
#define HASH_BLOCK_DATA_ORDER sha1_block_data_order #define HASH_BLOCK_DATA_ORDER sha1_block_data_order
#define ROTATE(a, n) (((a) << (n)) | ((a) >> (32 - (n)))) #define ROTATE(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
@ -113,11 +121,6 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
(ix) = (a) = ROTATE((a), 1); \ (ix) = (a) = ROTATE((a), 1); \
} while (0) } while (0)
#if !defined(SHA1_ASM)
static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
size_t num);
#endif
#include "../digest/md32_common.h" #include "../digest/md32_common.h"
#define K_00_19 0x5a827999UL #define K_00_19 0x5a827999UL
@ -346,7 +349,6 @@ static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
#undef HASH_DIGEST_LENGTH #undef HASH_DIGEST_LENGTH
#undef HASH_MAKE_STRING #undef HASH_MAKE_STRING
#undef HASH_UPDATE #undef HASH_UPDATE
#undef HASH_TRANSFORM
#undef HASH_FINAL #undef HASH_FINAL
#undef HASH_BLOCK_DATA_ORDER #undef HASH_BLOCK_DATA_ORDER
#undef ROTATE #undef ROTATE

@ -122,6 +122,15 @@ int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx) {
return SHA256_Final(out, ctx); return SHA256_Final(out, ctx);
} }
#ifndef SHA256_ASM
static void sha256_block_data_order(uint32_t *state, const uint8_t *in,
size_t num);
#endif
void SHA256_Transform(SHA256_CTX *c, const uint8_t data[SHA256_CBLOCK]) {
sha256_block_data_order(c->h, data, 1);
}
#define DATA_ORDER_IS_BIG_ENDIAN #define DATA_ORDER_IS_BIG_ENDIAN
#define HASH_CTX SHA256_CTX #define HASH_CTX SHA256_CTX
@ -167,13 +176,8 @@ int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx) {
#define HASH_UPDATE SHA256_Update #define HASH_UPDATE SHA256_Update
#define HASH_TRANSFORM SHA256_Transform
#define HASH_FINAL SHA256_Final #define HASH_FINAL SHA256_Final
#define HASH_BLOCK_DATA_ORDER sha256_block_data_order #define HASH_BLOCK_DATA_ORDER sha256_block_data_order
#ifndef SHA256_ASM
static void sha256_block_data_order(uint32_t *state, const uint8_t *in,
size_t num);
#endif
#include "../digest/md32_common.h" #include "../digest/md32_common.h"
@ -324,7 +328,6 @@ void SHA256_TransformBlocks(uint32_t state[8], const uint8_t *data,
#undef HASH_DIGEST_LENGTH #undef HASH_DIGEST_LENGTH
#undef HASH_MAKE_STRING #undef HASH_MAKE_STRING
#undef HASH_UPDATE #undef HASH_UPDATE
#undef HASH_TRANSFORM
#undef HASH_FINAL #undef HASH_FINAL
#undef HASH_BLOCK_DATA_ORDER #undef HASH_BLOCK_DATA_ORDER
#undef ROTATE #undef ROTATE

@ -80,6 +80,11 @@ int RIPEMD160_Init(RIPEMD160_CTX *ctx) {
static void ripemd160_block_data_order(uint32_t h[5], const uint8_t *data, static void ripemd160_block_data_order(uint32_t h[5], const uint8_t *data,
size_t num); size_t num);
void RIPEMD160_Transform(RIPEMD160_CTX *c,
const uint8_t data[RIPEMD160_CBLOCK]) {
ripemd160_block_data_order(c->h, data, 1);
}
#define DATA_ORDER_IS_LITTLE_ENDIAN #define DATA_ORDER_IS_LITTLE_ENDIAN
#define HASH_LONG uint32_t #define HASH_LONG uint32_t
@ -87,7 +92,6 @@ static void ripemd160_block_data_order(uint32_t h[5], const uint8_t *data,
#define HASH_CBLOCK RIPEMD160_CBLOCK #define HASH_CBLOCK RIPEMD160_CBLOCK
#define HASH_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH #define HASH_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH
#define HASH_UPDATE RIPEMD160_Update #define HASH_UPDATE RIPEMD160_Update
#define HASH_TRANSFORM RIPEMD160_Transform
#define HASH_FINAL RIPEMD160_Final #define HASH_FINAL RIPEMD160_Final
#define HASH_MAKE_STRING(c, s) \ #define HASH_MAKE_STRING(c, s) \
do { \ do { \

Loading…
Cancel
Save