aad-assignment-1/aad_sha1_wasm.h

36 lines
662 B
C

#ifndef AAD_SHA1_WASM
#define AAD_SHA1_WASM
#include "aad_data_types.h"
#include "aad_sha1.h"
//
// SHA1 hash computation for WebAssembly (scalar implementation)
//
static inline u32_t rotate_left(u32_t x, int n)
{
return (x << n) | (x >> (32 - n));
}
static void sha1(u32_t *coin, u32_t *hash)
{
// Define the macros needed by CUSTOM_SHA1_CODE
#define T u32_t
#define C(c) (c)
#define ROTATE(x,n) rotate_left(x,n)
#define DATA(idx) coin[idx]
#define HASH(idx) hash[idx]
// Use the standard SHA1 template from aad_sha1.h
CUSTOM_SHA1_CODE();
#undef T
#undef C
#undef ROTATE
#undef DATA
#undef HASH
}
#endif