|
|
@@ -15,12 +15,6 @@ |
|
|
|
#define NROUNDS 24 |
|
|
|
#define ROL(a, offset) (((a) << (offset)) ^ ((a) >> (64 - (offset)))) |
|
|
|
|
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
#include "hal.h" |
|
|
|
extern unsigned long long hash_cycles; |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/************************************************* |
|
|
|
* Name: keccak_absorb |
|
|
|
* |
|
|
@@ -211,47 +205,19 @@ static void keccak_inc_squeeze(uint8_t *h, size_t outlen, |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_inc_init(shake128incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_init(state->ctx); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_inc_absorb(shake128incctx *state, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_absorb(state->ctx, SHAKE128_RATE, input, inlen); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_inc_finalize(shake128incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_finalize(state->ctx, SHAKE128_RATE, 0x1F); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_inc_squeeze(uint8_t *output, size_t outlen, shake128incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_squeeze(output, outlen, state->ctx, SHAKE128_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_inc_ctx_clone(shake128incctx* dest, const shake128incctx *src) { |
|
|
@@ -263,47 +229,19 @@ void shake128_inc_ctx_release(shake128incctx *state) { |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_inc_init(shake256incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_init(state->ctx); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_inc_absorb(shake256incctx *state, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_absorb(state->ctx, SHAKE256_RATE, input, inlen); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_inc_finalize(shake256incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_finalize(state->ctx, SHAKE256_RATE, 0x1F); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_inc_squeeze(uint8_t *output, size_t outlen, shake256incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_squeeze(output, outlen, state->ctx, SHAKE256_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_inc_ctx_clone(shake256incctx* dest, const shake256incctx *src) { |
|
|
@@ -318,9 +256,6 @@ void shake256_inc_ctx_release(shake256incctx *state) { |
|
|
|
|
|
|
|
void cshake128_simple_absorb(shake128ctx *state, uint16_t cstm, const uint8_t *in, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
uint8_t sep[8]; |
|
|
@@ -345,24 +280,13 @@ void cshake128_simple_absorb(shake128ctx *state, uint16_t cstm, const uint8_t *i |
|
|
|
/* Absorb input */ |
|
|
|
keccak_absorb(state->ctx, SHAKE128_RATE, in, inlen, 0x04); |
|
|
|
|
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void cshake128_simple_squeezeblocks(uint8_t *output, size_t nblocks, shake128ctx *state) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE128_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -374,9 +298,6 @@ void cshake128_simple(uint8_t *output, size_t outlen, uint16_t cstm, const uint8 |
|
|
|
|
|
|
|
cshake128_simple_absorb(&state, cstm, in, inlen); |
|
|
|
|
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Squeeze output */ |
|
|
|
keccak_squeezeblocks(output, outlen/SHAKE128_RATE, state.ctx, SHAKE128_RATE); |
|
|
@@ -388,10 +309,6 @@ void cshake128_simple(uint8_t *output, size_t outlen, uint16_t cstm, const uint8 |
|
|
|
for (i = 0; i < outlen%SHAKE128_RATE; i++) |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -408,18 +325,11 @@ void cshake128_simple(uint8_t *output, size_t outlen, uint16_t cstm, const uint8 |
|
|
|
**************************************************/ |
|
|
|
void shake128_absorb(shake128ctx *state, const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
int i; |
|
|
|
for (i = 0; i < 25; i++) |
|
|
|
state->ctx[i] = 0; |
|
|
|
|
|
|
|
keccak_absorb(state->ctx, SHAKE128_RATE, input, inlen, 0x1F); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
/************************************************* |
|
|
@@ -435,21 +345,11 @@ void shake128_absorb(shake128ctx *state, const uint8_t *input, size_t inlen) |
|
|
|
**************************************************/ |
|
|
|
void shake128_squeezeblocks(uint8_t *output, size_t nblocks, shake128ctx *state) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE128_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
shake128ctx state; |
|
|
|
uint8_t t[SHAKE128_RATE]; |
|
|
|
size_t nblocks = outlen/SHAKE128_RATE; |
|
|
@@ -474,10 +374,6 @@ void shake128(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen |
|
|
|
for (i = 0; i < outlen; i++) |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake128_ctx_release(shake128ctx *state) { |
|
|
@@ -489,31 +385,17 @@ void shake128_ctx_clone(shake128ctx *dest, const shake128ctx *src) { |
|
|
|
|
|
|
|
void shake256_absorb(shake256ctx *state, const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
int i; |
|
|
|
for (i = 0; i < 25; i++) |
|
|
|
state->ctx[i] = 0; |
|
|
|
|
|
|
|
keccak_absorb(state->ctx, SHAKE256_RATE, input, inlen, 0x1F); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void shake256_squeezeblocks(uint8_t *output, size_t nblocks, shake256ctx *state) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE256_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
/************************************************* |
|
|
@@ -529,9 +411,6 @@ void shake256_squeezeblocks(uint8_t *output, size_t nblocks, shake256ctx *state) |
|
|
|
void shake256(uint8_t *output, size_t outlen, |
|
|
|
const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
shake256ctx state; |
|
|
|
uint8_t t[SHAKE256_RATE]; |
|
|
|
size_t nblocks = outlen/SHAKE256_RATE; |
|
|
@@ -556,10 +435,6 @@ void shake256(uint8_t *output, size_t outlen, |
|
|
|
for(i=0;i<outlen;i++) |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void shake256_ctx_release(shake256ctx *state) { |
|
|
@@ -582,9 +457,6 @@ void shake256_ctx_clone(shake256ctx *dest, const shake256ctx *src) { |
|
|
|
**************************************************/ |
|
|
|
void sha3_256(uint8_t *output, const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint64_t s[25] = {0}; |
|
|
|
uint8_t t[SHA3_256_RATE]; |
|
|
|
size_t i; |
|
|
@@ -597,37 +469,16 @@ void sha3_256(uint8_t *output, const uint8_t *input, size_t inlen) |
|
|
|
|
|
|
|
for(i=0;i<32;i++) |
|
|
|
output[i] = t[i]; |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
void sha3_256_inc_init(sha3_256incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_init(state->ctx); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_256_inc_absorb(sha3_256incctx *state, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_absorb(state->ctx, SHA3_256_RATE, input, inlen); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_256_inc_finalize(uint8_t *output, sha3_256incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint8_t t[SHA3_256_RATE]; |
|
|
|
keccak_inc_finalize(state->ctx, SHA3_256_RATE, 0x06); |
|
|
|
|
|
|
@@ -636,10 +487,6 @@ void sha3_256_inc_finalize(uint8_t *output, sha3_256incctx *state) { |
|
|
|
for (size_t i = 0; i < 32; i++) { |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_256_inc_ctx_clone(sha3_256incctx *dest, const sha3_256incctx *src) { |
|
|
@@ -651,31 +498,14 @@ void sha3_256_inc_ctx_release(sha3_256incctx *state) { |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_384_inc_init(sha3_384incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_init(state->ctx); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_384_inc_absorb(sha3_384incctx *state, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_absorb(state->ctx, SHA3_384_RATE, input, inlen); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_384_inc_finalize(uint8_t *output, sha3_384incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint8_t t[SHA3_384_RATE]; |
|
|
|
keccak_inc_finalize(state->ctx, SHA3_384_RATE, 0x06); |
|
|
|
|
|
|
@@ -684,10 +514,6 @@ void sha3_384_inc_finalize(uint8_t *output, sha3_384incctx *state) { |
|
|
|
for (size_t i = 0; i < 48; i++) { |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_384_inc_ctx_clone(sha3_384incctx *dest, const sha3_384incctx *src) { |
|
|
@@ -708,9 +534,6 @@ void sha3_384_inc_ctx_release(sha3_384incctx *state) { |
|
|
|
* - size_t inlen: length of input in bytes |
|
|
|
**************************************************/ |
|
|
|
void sha3_384(uint8_t *output, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint64_t s[25]; |
|
|
|
uint8_t t[SHA3_384_RATE]; |
|
|
|
|
|
|
@@ -723,10 +546,6 @@ void sha3_384(uint8_t *output, const uint8_t *input, size_t inlen) { |
|
|
|
for (size_t i = 0; i < 48; i++) { |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
/************************************************* |
|
|
|
* Name: sha3_512 |
|
|
@@ -739,9 +558,6 @@ void sha3_384(uint8_t *output, const uint8_t *input, size_t inlen) { |
|
|
|
**************************************************/ |
|
|
|
void sha3_512(uint8_t *output, const uint8_t *input, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint64_t s[25] = {0}; |
|
|
|
uint8_t t[SHA3_512_RATE]; |
|
|
|
size_t i; |
|
|
@@ -754,37 +570,16 @@ void sha3_512(uint8_t *output, const uint8_t *input, size_t inlen) |
|
|
|
|
|
|
|
for(i=0;i<64;i++) |
|
|
|
output[i] = t[i]; |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
void sha3_512_inc_init(sha3_512incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_init(state->ctx); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_512_inc_absorb(sha3_512incctx *state, const uint8_t *input, size_t inlen) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_inc_absorb(state->ctx, SHA3_512_RATE, input, inlen); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_512_inc_finalize(uint8_t *output, sha3_512incctx *state) { |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint8_t t[SHA3_512_RATE]; |
|
|
|
keccak_inc_finalize(state->ctx, SHA3_512_RATE, 0x06); |
|
|
|
|
|
|
@@ -793,10 +588,6 @@ void sha3_512_inc_finalize(uint8_t *output, sha3_512incctx *state) { |
|
|
|
for (size_t i = 0; i < 64; i++) { |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void sha3_512_inc_ctx_clone(sha3_512incctx *dest, const sha3_512incctx *src) { |
|
|
@@ -811,9 +602,6 @@ void sha3_512_inc_ctx_release(sha3_512incctx *state) { |
|
|
|
|
|
|
|
void cshake256_simple_absorb(shake256ctx *state, uint16_t cstm, const uint8_t *in, size_t inlen) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
uint8_t sep[8]; |
|
|
|
size_t i; |
|
|
|
|
|
|
@@ -835,23 +623,12 @@ void cshake256_simple_absorb(shake256ctx *state, uint16_t cstm, const uint8_t *i |
|
|
|
|
|
|
|
/* Absorb input */ |
|
|
|
keccak_absorb(state->ctx, SHAKE256_RATE, in, inlen, 0x04); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void cshake256_simple_squeezeblocks(uint8_t *output, size_t nblocks, shake256ctx *state) |
|
|
|
{ |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
keccak_squeezeblocks(output, nblocks, state->ctx, SHAKE256_RATE); |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -863,9 +640,6 @@ void cshake256_simple(uint8_t *output, size_t outlen, uint16_t cstm, const uint8 |
|
|
|
|
|
|
|
cshake256_simple_absorb(&state, cstm, in, inlen); |
|
|
|
|
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t0 = hal_get_time(); |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Squeeze output */ |
|
|
|
keccak_squeezeblocks(output, outlen/SHAKE256_RATE, state.ctx, SHAKE256_RATE); |
|
|
@@ -877,8 +651,4 @@ void cshake256_simple(uint8_t *output, size_t outlen, uint16_t cstm, const uint8 |
|
|
|
for (i = 0; i < outlen%SHAKE256_RATE; i++) |
|
|
|
output[i] = t[i]; |
|
|
|
} |
|
|
|
#ifdef PROFILE_HASHING |
|
|
|
uint64_t t1 = hal_get_time(); |
|
|
|
hash_cycles += (t1-t0); |
|
|
|
#endif |
|
|
|
} |