forked from chuanwc/node-multi-hashing-1
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathskunkhash.c
41 lines (31 loc) · 1.13 KB
/
skunkhash.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "skunkhash.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "sha3/sph_skein.h"
#include "sha3/sph_cubehash.h"
#include "sha3/sph_fugue.h"
#include "sha3/sph_gost.h"
void skunk_hash(const char* input, char* output, uint32_t len)
{
sph_skein512_context ctx_skein;
sph_cubehash512_context ctx_cubehash;
sph_fugue512_context ctx_fugue;
sph_gost512_context ctx_gost;
//these uint512 in the c++ source of the client are backed by an array of uint32
uint32_t hashA[16], hashB[16];
sph_skein512_init(&ctx_skein);
sph_skein512 (&ctx_skein, input, len);
sph_skein512_close(&ctx_skein, hashA);
sph_cubehash512_init(&ctx_cubehash);
sph_cubehash512 (&ctx_cubehash, hashA, 64);
sph_cubehash512_close(&ctx_cubehash, hashB);
sph_fugue512_init(&ctx_fugue);
sph_fugue512 (&ctx_fugue, hashB, 64);
sph_fugue512_close(&ctx_fugue, hashA);
sph_gost512_init(&ctx_gost);
sph_gost512 (&ctx_gost, hashA, 64);
sph_gost512_close(&ctx_gost, hashB);
memcpy(output, hashB, 32);
}