forked from krisklosterman/node-multi-hashing
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathskunk.c
42 lines (31 loc) · 990 Bytes
/
skunk.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 <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"
#include "gost.h"
#define _ALIGN(x) __attribute__ ((aligned(x)))
void skunk_hash(const char *input, char* output, uint32_t len)
{
uint32_t _ALIGN(64) hash[16];
sph_skein512_context ctx_skein;
sph_cubehash512_context ctx_cube;
sph_fugue512_context ctx_fugue;
sph_gost512_context ctx_gost;
sph_skein512_init(&ctx_skein);
sph_skein512(&ctx_skein, input, 80);
sph_skein512_close(&ctx_skein, (void*) hash);
sph_cubehash512_init(&ctx_cube);
sph_cubehash512(&ctx_cube, hash, 64);
sph_cubehash512_close(&ctx_cube, hash);
sph_fugue512_init (&ctx_fugue);
sph_fugue512(&ctx_fugue, hash, 64);
sph_fugue512_close(&ctx_fugue, hash);
sph_gost512_init(&ctx_gost);
sph_gost512(&ctx_gost, (const void*) hash, 64);
sph_gost512_close(&ctx_gost, (void*) hash);
memcpy(output, hash, 32);
}