diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-01-22 22:27:21 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-01-22 22:27:21 +0100 |
commit | 277fba5f031721197947832f0c721e43913af995 (patch) | |
tree | ff21d1bf38882df5124d663225d525458177a96e /test/monniaux/sha-2/sha-256.c | |
parent | 38f01037de197285181c8ce1868b2a69dcf136ee (diff) | |
download | compcert-kvx-277fba5f031721197947832f0c721e43913af995.tar.gz compcert-kvx-277fba5f031721197947832f0c721e43913af995.zip |
autoincrement
Diffstat (limited to 'test/monniaux/sha-2/sha-256.c')
-rw-r--r-- | test/monniaux/sha-2/sha-256.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/monniaux/sha-2/sha-256.c b/test/monniaux/sha-2/sha-256.c index 17ba98aa..05cda24f 100644 --- a/test/monniaux/sha-2/sha-256.c +++ b/test/monniaux/sha-2/sha-256.c @@ -126,6 +126,9 @@ static int calc_chunk(uint8_t chunk[CHUNK_SIZE], struct buffer_state * state) * for bit string lengths that are not multiples of eight, and it really operates on arrays of bytes. * In particular, the len parameter is a number of bytes. */ +#define DO_NOT_UNROLL 1 +#define AUTOINCREMENT 1 + #if USE_ORIGINAL void calc_sha_256(uint8_t hash[32], const void * input, size_t len) { @@ -278,10 +281,18 @@ void calc_sha_256(uint8_t hash[32], const void * input, size_t len) ah7 = h[7]; /* Compression function main loop: */ +#if AUTOINCREMENT + const uint32_t *ki = k, *wi = w; +#endif for (i = 0; i < 64; i++) { const uint32_t s1 = right_rot(ah4, 6) ^ right_rot(ah4, 11) ^ right_rot(ah4, 25); const uint32_t ch = (ah4 & ah5) ^ (~ah4 & ah6); - const uint32_t temp1 = ah7 + s1 + ch + k[i] + w[i]; + const uint32_t temp1 = ah7 + s1 + ch + +#if AUTOINCREMENT + *(ki++) + *(wi++); +#else + k[i] + w[i]; +#endif const uint32_t s0 = right_rot(ah0, 2) ^ right_rot(ah0, 13) ^ right_rot(ah0, 22); const uint32_t maj = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2); const uint32_t temp2 = s0 + maj; |