2014-04-17 04:00:02 +02:00
|
|
|
#include "groestl.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "sha3/sph_groestl.h"
|
2014-04-19 19:15:36 +02:00
|
|
|
#include "sha256.h"
|
2014-04-17 04:00:02 +02:00
|
|
|
|
2014-04-19 20:27:09 +02:00
|
|
|
void groestl_hash(const char* input, char* output, uint32_t len)
|
2014-04-17 04:00:02 +02:00
|
|
|
{
|
2014-04-21 15:31:03 +02:00
|
|
|
char hash1[64];
|
|
|
|
char hash2[64];
|
2014-04-19 19:15:36 +02:00
|
|
|
|
|
|
|
sph_groestl512_context ctx_groestl;
|
|
|
|
sph_groestl512_init(&ctx_groestl);
|
|
|
|
sph_groestl512(&ctx_groestl, input, len);
|
2014-04-21 15:31:03 +02:00
|
|
|
sph_groestl512_close(&ctx_groestl, &hash1);
|
2014-04-19 19:15:36 +02:00
|
|
|
|
|
|
|
sph_groestl512(&ctx_groestl, hash1, 64);
|
2014-04-21 15:31:03 +02:00
|
|
|
sph_groestl512_close(&ctx_groestl, &hash2);
|
2014-04-19 19:15:36 +02:00
|
|
|
|
2014-04-21 15:31:03 +02:00
|
|
|
memcpy(output, &hash2, 32);
|
2014-04-19 19:15:36 +02:00
|
|
|
}
|
|
|
|
|
2014-04-21 21:43:41 +02:00
|
|
|
void groestlmyriad_hash(const char* input, char* output, uint32_t len)
|
2014-04-19 19:15:36 +02:00
|
|
|
{
|
2014-04-21 15:31:03 +02:00
|
|
|
char temp[64];
|
2014-04-19 19:15:36 +02:00
|
|
|
|
|
|
|
sph_groestl512_context ctx_groestl;
|
|
|
|
sph_groestl512_init(&ctx_groestl);
|
|
|
|
sph_groestl512(&ctx_groestl, input, len);
|
2014-04-21 15:31:03 +02:00
|
|
|
sph_groestl512_close(&ctx_groestl, &temp);
|
2014-04-19 19:15:36 +02:00
|
|
|
|
|
|
|
SHA256_CTX ctx_sha256;
|
|
|
|
SHA256_Init(&ctx_sha256);
|
2014-04-21 15:31:03 +02:00
|
|
|
SHA256_Update(&ctx_sha256, &temp, 64);
|
2014-04-19 21:15:34 +02:00
|
|
|
SHA256_Final((unsigned char*) output, &ctx_sha256);
|
2014-04-17 04:00:02 +02:00
|
|
|
}
|
|
|
|
|