#include #include #include "crypto_hash.h" #include "gimli.inc" #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define rateInBytes 16 static void Gimli_hash(const uint8_t *input, uint64_t inputByteLen, uint8_t *output, uint64_t outputByteLen) { uint8_t state_8[48]; uint64_t blockSize = 0; uint64_t i; // === Initialize the state === memset(state_8, 0, sizeof(state_8)); // === Absorb all the input blocks === while(inputByteLen > 0) { blockSize = MIN(inputByteLen, rateInBytes); for(i=0; i 0) { blockSize = MIN(outputByteLen, rateInBytes); memcpy(output, state_8, blockSize); output += blockSize; outputByteLen -= blockSize; if (outputByteLen > 0) gimli(state_8); } } int crypto_hash(unsigned char *out,const unsigned char *in,unsigned long long inlen) { Gimli_hash(in,inlen,out,32); return 0; }