1+ #include "nist5.h"
2+ #include <stdlib.h>
3+ #include <stdint.h>
4+ #include <string.h>
5+ #include <stdio.h>
6+
7+ #include "sha3/sph_blake.h"
8+ #include "sha3/sph_groestl.h"
9+ #include "sha3/sph_jh.h"
10+ #include "sha3/sph_keccak.h"
11+ #include "sha3/sph_skein.h"
12+
13+
14+ void nist5_hash (const char * input , char * output , uint32_t len )
15+ {
16+ sph_blake512_context ctx_blake ;
17+ sph_groestl512_context ctx_groestl ;
18+ sph_skein512_context ctx_skein ;
19+ sph_jh512_context ctx_jh ;
20+ sph_keccak512_context ctx_keccak ;
21+
22+ //these uint512 in the c++ source of the client are backed by an array of uint32
23+ uint32_t hash [16 ];
24+
25+ sph_blake512_init (& ctx_blake );
26+ sph_blake512 (& ctx_blake , input , len );
27+ sph_blake512_close (& ctx_blake , hash );
28+
29+ sph_groestl512_init (& ctx_groestl );
30+ sph_groestl512 (& ctx_groestl , hash , 64 );
31+ sph_groestl512_close (& ctx_groestl , hash );
32+
33+ sph_jh512_init (& ctx_jh );
34+ sph_jh512 (& ctx_jh , hash , 64 );
35+ sph_jh512_close (& ctx_jh , hash );
36+
37+ sph_keccak512_init (& ctx_keccak );
38+ sph_keccak512 (& ctx_keccak , hash , 64 );
39+ sph_keccak512_close (& ctx_keccak , hash );
40+
41+ sph_skein512_init (& ctx_skein );
42+ sph_skein512 (& ctx_skein , hash , 64 );
43+ sph_skein512_close (& ctx_skein , hash );
44+
45+ memcpy (output , hash , 32 );
46+ }
0 commit comments