|
| 1 | +#include "c11.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_bmw.h" |
| 9 | +#include "sha3/sph_groestl.h" |
| 10 | +#include "sha3/sph_jh.h" |
| 11 | +#include "sha3/sph_keccak.h" |
| 12 | +#include "sha3/sph_skein.h" |
| 13 | +#include "sha3/sph_luffa.h" |
| 14 | +#include "sha3/sph_cubehash.h" |
| 15 | +#include "sha3/sph_shavite.h" |
| 16 | +#include "sha3/sph_simd.h" |
| 17 | +#include "sha3/sph_echo.h" |
| 18 | + |
| 19 | + |
| 20 | +void c11_hash(const char* input, char* output, uint32_t len) |
| 21 | +{ |
| 22 | + sph_blake512_context ctx_blake; |
| 23 | + sph_bmw512_context ctx_bmw; |
| 24 | + sph_groestl512_context ctx_groestl; |
| 25 | + sph_skein512_context ctx_skein; |
| 26 | + sph_jh512_context ctx_jh; |
| 27 | + sph_keccak512_context ctx_keccak; |
| 28 | + |
| 29 | + sph_luffa512_context ctx_luffa1; |
| 30 | + sph_cubehash512_context ctx_cubehash1; |
| 31 | + sph_shavite512_context ctx_shavite1; |
| 32 | + sph_simd512_context ctx_simd1; |
| 33 | + sph_echo512_context ctx_echo1; |
| 34 | + |
| 35 | + //these uint512 in the c++ source of the client are backed by an array of uint32 |
| 36 | + uint32_t hashA[16], hashB[16]; |
| 37 | + |
| 38 | + sph_blake512_init(&ctx_blake); |
| 39 | + sph_blake512 (&ctx_blake, input, 80); |
| 40 | + sph_blake512_close (&ctx_blake, hashA); |
| 41 | + |
| 42 | + sph_bmw512_init(&ctx_bmw); |
| 43 | + sph_bmw512 (&ctx_bmw, hashA, 64); |
| 44 | + sph_bmw512_close(&ctx_bmw, hashB); |
| 45 | + |
| 46 | + sph_groestl512_init(&ctx_groestl); |
| 47 | + sph_groestl512 (&ctx_groestl, hashB, 64); |
| 48 | + sph_groestl512_close(&ctx_groestl, hashA); |
| 49 | + |
| 50 | + sph_jh512_init(&ctx_jh); |
| 51 | + sph_jh512 (&ctx_jh, hashA, 64); |
| 52 | + sph_jh512_close(&ctx_jh, hashB); |
| 53 | + |
| 54 | + sph_keccak512_init(&ctx_keccak); |
| 55 | + sph_keccak512 (&ctx_keccak, hashB, 64); |
| 56 | + sph_keccak512_close(&ctx_keccak, hashA); |
| 57 | + |
| 58 | + sph_skein512_init(&ctx_skein); |
| 59 | + sph_skein512 (&ctx_skein, hashA, 64); |
| 60 | + sph_skein512_close (&ctx_skein, hashB); |
| 61 | + |
| 62 | + sph_luffa512_init (&ctx_luffa1); |
| 63 | + sph_luffa512 (&ctx_luffa1, hashB, 64); |
| 64 | + sph_luffa512_close (&ctx_luffa1, hashA); |
| 65 | + |
| 66 | + sph_cubehash512_init (&ctx_cubehash1); |
| 67 | + sph_cubehash512 (&ctx_cubehash1, hashA, 64); |
| 68 | + sph_cubehash512_close(&ctx_cubehash1, hashB); |
| 69 | + |
| 70 | + sph_shavite512_init (&ctx_shavite1); |
| 71 | + sph_shavite512 (&ctx_shavite1, hashB, 64); |
| 72 | + sph_shavite512_close(&ctx_shavite1, hashA); |
| 73 | + |
| 74 | + sph_simd512_init (&ctx_simd1); |
| 75 | + sph_simd512 (&ctx_simd1, hashA, 64); |
| 76 | + sph_simd512_close(&ctx_simd1, hashB); |
| 77 | + |
| 78 | + sph_echo512_init (&ctx_echo1); |
| 79 | + sph_echo512 (&ctx_echo1, hashB, 64); |
| 80 | + sph_echo512_close(&ctx_echo1, hashA); |
| 81 | + |
| 82 | + memcpy(output, hashA, 32); |
| 83 | + |
| 84 | +} |
| 85 | + |
0 commit comments