Browse Source

Drop useless files

master
Henry Case 1 year ago
parent
commit
aa333171af
4 changed files with 0 additions and 302 deletions
  1. +0
    -230
      src/common/fips202.c
  2. +0
    -10
      src/common/hal-stm32f4.c
  3. +0
    -1
      src/common/hal.h
  4. +0
    -61
      src/common/sendfn.h

+ 0
- 230
src/common/fips202.c View File

@@ -15,12 +15,6 @@
#define NROUNDS 24 #define NROUNDS 24
#define ROL(a, offset) (((a) << (offset)) ^ ((a) >> (64 - (offset)))) #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 * Name: keccak_absorb
* *
@@ -211,47 +205,19 @@ static void keccak_inc_squeeze(uint8_t *h, size_t outlen,
} }


void shake128_inc_init(shake128incctx *state) { void shake128_inc_init(shake128incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_init(state->ctx); 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) { 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); 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) { void shake128_inc_finalize(shake128incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_finalize(state->ctx, SHAKE128_RATE, 0x1F); 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) { 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); 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) { 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) { void shake256_inc_init(shake256incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_init(state->ctx); 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) { 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); 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) { void shake256_inc_finalize(shake256incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_finalize(state->ctx, SHAKE256_RATE, 0x1F); 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) { 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); 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) { 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) 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]; uint8_t sep[8];
@@ -345,24 +280,13 @@ void cshake128_simple_absorb(shake128ctx *state, uint16_t cstm, const uint8_t *i
/* Absorb input */ /* Absorb input */
keccak_absorb(state->ctx, SHAKE128_RATE, in, inlen, 0x04); 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) 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); 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); cshake128_simple_absorb(&state, cstm, in, inlen);


#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif


/* Squeeze output */ /* Squeeze output */
keccak_squeezeblocks(output, outlen/SHAKE128_RATE, state.ctx, SHAKE128_RATE); 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++) for (i = 0; i < outlen%SHAKE128_RATE; i++)
output[i] = t[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) void shake128_absorb(shake128ctx *state, const uint8_t *input, size_t inlen)
{ {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
int i; int i;
for (i = 0; i < 25; i++) for (i = 0; i < 25; i++)
state->ctx[i] = 0; state->ctx[i] = 0;


keccak_absorb(state->ctx, SHAKE128_RATE, input, inlen, 0x1F); 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) 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); 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) 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; shake128ctx state;
uint8_t t[SHAKE128_RATE]; uint8_t t[SHAKE128_RATE];
size_t nblocks = outlen/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++) for (i = 0; i < outlen; i++)
output[i] = t[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) { 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) void shake256_absorb(shake256ctx *state, const uint8_t *input, size_t inlen)
{ {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
int i; int i;
for (i = 0; i < 25; i++) for (i = 0; i < 25; i++)
state->ctx[i] = 0; state->ctx[i] = 0;


keccak_absorb(state->ctx, SHAKE256_RATE, input, inlen, 0x1F); 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) 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); 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, void shake256(uint8_t *output, size_t outlen,
const uint8_t *input, size_t inlen) const uint8_t *input, size_t inlen)
{ {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
shake256ctx state; shake256ctx state;
uint8_t t[SHAKE256_RATE]; uint8_t t[SHAKE256_RATE];
size_t nblocks = outlen/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++) for(i=0;i<outlen;i++)
output[i] = t[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) { 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) 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}; uint64_t s[25] = {0};
uint8_t t[SHA3_256_RATE]; uint8_t t[SHA3_256_RATE];
size_t i; 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++) for(i=0;i<32;i++)
output[i] = t[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) { void sha3_256_inc_init(sha3_256incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_init(state->ctx); 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) { 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); 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) { 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]; uint8_t t[SHA3_256_RATE];
keccak_inc_finalize(state->ctx, SHA3_256_RATE, 0x06); 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++) { for (size_t i = 0; i < 32; i++) {
output[i] = t[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) { 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) { void sha3_384_inc_init(sha3_384incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_init(state->ctx); 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) { 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); 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) { 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]; uint8_t t[SHA3_384_RATE];
keccak_inc_finalize(state->ctx, SHA3_384_RATE, 0x06); 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++) { for (size_t i = 0; i < 48; i++) {
output[i] = t[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) { 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 * - size_t inlen: length of input in bytes
**************************************************/ **************************************************/
void sha3_384(uint8_t *output, const uint8_t *input, size_t inlen) { 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]; uint64_t s[25];
uint8_t t[SHA3_384_RATE]; 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++) { for (size_t i = 0; i < 48; i++) {
output[i] = t[i]; output[i] = t[i];
} }
#ifdef PROFILE_HASHING
uint64_t t1 = hal_get_time();
hash_cycles += (t1-t0);
#endif
} }
/************************************************* /*************************************************
* Name: sha3_512 * 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) 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}; uint64_t s[25] = {0};
uint8_t t[SHA3_512_RATE]; uint8_t t[SHA3_512_RATE];
size_t i; 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++) for(i=0;i<64;i++)
output[i] = t[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) { void sha3_512_inc_init(sha3_512incctx *state) {
#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif
keccak_inc_init(state->ctx); 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) { 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); 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) { 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]; uint8_t t[SHA3_512_RATE];
keccak_inc_finalize(state->ctx, SHA3_512_RATE, 0x06); 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++) { for (size_t i = 0; i < 64; i++) {
output[i] = t[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) { 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) 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]; uint8_t sep[8];
size_t i; size_t i;


@@ -835,23 +623,12 @@ void cshake256_simple_absorb(shake256ctx *state, uint16_t cstm, const uint8_t *i


/* Absorb input */ /* Absorb input */
keccak_absorb(state->ctx, SHAKE256_RATE, in, inlen, 0x04); 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) 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); 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); cshake256_simple_absorb(&state, cstm, in, inlen);


#ifdef PROFILE_HASHING
uint64_t t0 = hal_get_time();
#endif


/* Squeeze output */ /* Squeeze output */
keccak_squeezeblocks(output, outlen/SHAKE256_RATE, state.ctx, SHAKE256_RATE); 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++) for (i = 0; i < outlen%SHAKE256_RATE; i++)
output[i] = t[i]; output[i] = t[i];
} }
#ifdef PROFILE_HASHING
uint64_t t1 = hal_get_time();
hash_cycles += (t1-t0);
#endif
} }

+ 0
- 10
src/common/hal-stm32f4.c View File

@@ -99,13 +99,3 @@ void sys_tick_handler(void)
{ {
++overflowcnt; ++overflowcnt;
} }
uint64_t hal_get_time()
{
while (true) {
unsigned long long before = overflowcnt;
unsigned long long result = (before + 1) * 16777216llu - systick_get_value();
if (overflowcnt == before) {
return result;
}
}
}

+ 0
- 1
src/common/hal.h View File

@@ -10,6 +10,5 @@ enum clock_mode {


void hal_setup(const enum clock_mode clock); void hal_setup(const enum clock_mode clock);
void hal_send_str(const char* in); void hal_send_str(const char* in);
uint64_t hal_get_time(void);


#endif #endif

+ 0
- 61
src/common/sendfn.h View File

@@ -1,61 +0,0 @@
#ifndef SENDFN_H
#define SENDFN_H

#include "hal.h"

__attribute__((unused))
static void send_unsigned(const char *s, unsigned int c) {
int i = 0;
char outs[11] = {0};
if (c < 10) {
outs[0] = '0' + c;
} else {
for (i = 9; c != 0; c /= 10, i -= 1) {
unsigned d = c % 10;
outs[i] = '0' + d;
}
i += 1;
}
hal_send_str(s);
hal_send_str(outs + i);
}

__attribute__((unused))
static void send_unsignedll(const char *s, unsigned long long c) {
int i = 0;
char outs[21] = {0};
if (c < 10) {
outs[0] = '0' + c;
} else {
i = 19;
while (c != 0) {
/* Method adapted from ""hackers delight":
Creates an approximation of q = (8/10) */
unsigned long long q = (c >> 1) + (c >> 2);
q = q + (q >> 4);
q = q + (q >> 8);
q = q + (q >> 16);
q = q + (q >> 32);
/* Now q = (1/10) */
q = q >> 3;
/* Since q contains an error due to the bits shifted out of the value, we
only use it to determine the remainder. */
unsigned long long r = c - ((q << 3) + (q << 1));
c = q;
/* The remainder might be off by 10, so q may be off by 1 */
if (r > 9) {
c += 1;
r -= 10;
}
outs[i] = '0' + (unsigned) r;
i -= 1;
}
i += 1;
}
hal_send_str(s);
hal_send_str(outs + i);
}


#endif /* SENDFN_H */


Loading…
Cancel
Save