diff options
author | David Benjamin <davidben@google.com> | 2021-03-29 14:45:13 -0400 |
---|---|---|
committer | CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> | 2021-06-01 18:53:05 +0000 |
commit | 597ffef971dd980b7de5e97a0c9b7ca26eec94bc (patch) | |
tree | 1e136a277f00c085585226ee1e1a33158b0450d7 /decrepit | |
parent | 4320bc47617a66d4219e66e2420311dbfb6c3cb0 (diff) | |
download | boringssl-597ffef971dd980b7de5e97a0c9b7ca26eec94bc.zip boringssl-597ffef971dd980b7de5e97a0c9b7ca26eec94bc.tar.gz boringssl-597ffef971dd980b7de5e97a0c9b7ca26eec94bc.tar.bz2 |
Make md32_common.h single-included and use an unsized helper for SHA-256.
Similar to
https://boringssl-review.googlesource.com/c/boringssl/+/46405,
SHA256_Final and SHA224_Final hit array size warnings in the new GCC.
The array sizes are, strictly speaking, purely decoration, but this is a
good warning so we should be clean with it on.
That same change is difficult to apply to md32_common.h because
md32_common.h generates the functions for us. md32_common.h is already
strange in that it is multiply-included and changes behavior based on
macros defined by the caller.
Instead, replace it with inline functions, which are a bit more
conventional and typesafe. This allows each hash function to define the
function prototype. Use this to add an unsized helper for SHA-256.
Bug: 402
Change-Id: I61bc30fb58c54dd40a55c9b1ebf3fb9adde5e038
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47807
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Peter Foley <pefoley@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Diffstat (limited to 'decrepit')
-rw-r--r-- | decrepit/ripemd/ripemd.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/decrepit/ripemd/ripemd.c b/decrepit/ripemd/ripemd.c index ac6bd83..9120cdd 100644 --- a/decrepit/ripemd/ripemd.c +++ b/decrepit/ripemd/ripemd.c @@ -59,6 +59,7 @@ #include <string.h> #include "../../crypto/internal.h" +#include "../../crypto/fipsmodule/digest/md32_common.h" #define RIPEMD160_A 0x67452301L @@ -85,31 +86,24 @@ void RIPEMD160_Transform(RIPEMD160_CTX *c, ripemd160_block_data_order(c->h, data, 1); } -#define DATA_ORDER_IS_LITTLE_ENDIAN - -#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_FINAL RIPEMD160_Final -#define HASH_MAKE_STRING(c, s) \ - do { \ - CRYPTO_store_u32_le((s), (c)->h[0]); \ - (s) += 4; \ - CRYPTO_store_u32_le((s), (c)->h[1]); \ - (s) += 4; \ - CRYPTO_store_u32_le((s), (c)->h[2]); \ - (s) += 4; \ - CRYPTO_store_u32_le((s), (c)->h[3]); \ - (s) += 4; \ - CRYPTO_store_u32_le((s), (c)->h[4]); \ - (s) += 4; \ - } while (0) - -#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order +int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len) { + crypto_md32_update(&ripemd160_block_data_order, c->h, c->data, + RIPEMD160_CBLOCK, &c->num, &c->Nh, &c->Nl, data, len); + return 1; +} -#include "../../crypto/fipsmodule/digest/md32_common.h" +int RIPEMD160_Final(uint8_t out[RIPEMD160_DIGEST_LENGTH], RIPEMD160_CTX *c) { + crypto_md32_final(&ripemd160_block_data_order, c->h, c->data, + RIPEMD160_CBLOCK, &c->num, c->Nh, c->Nl, + /*is_big_endian=*/0); + + CRYPTO_store_u32_le(out, c->h[0]); + CRYPTO_store_u32_le(out + 4, c->h[1]); + CRYPTO_store_u32_le(out + 8, c->h[2]); + CRYPTO_store_u32_le(out + 12, c->h[3]); + CRYPTO_store_u32_le(out + 16, c->h[4]); + return 1; +} // Transformed F2 and F4 are courtesy of Wei Dai <weidai@eskimo.com> #define F1(x, y, z) ((x) ^ (y) ^ (z)) |