Skip to content

Commit e0d291b

Browse files
committed
Initial fugue support
1 parent 1190307 commit e0d291b

File tree

6 files changed

+1345
-0
lines changed

6 files changed

+1345
-0
lines changed

binding.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"bcrypt.c",
1515
"groestl.c",
1616
"blake.c",
17+
"fugue.c",
18+
"sha3/sph_fugue.c",
1719
"sha3/aes_helper.c",
1820
"sha3/sph_blake.c",
1921
"sha3/sph_bmw.c",

fugue.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "fugue.h"
2+
3+
#include "sha3/sph_fugue.h"
4+
5+
void fugue_hash(const char* input, char* output, uint32_t len)
6+
{
7+
sph_fugue256_context ctx_fugue;
8+
sph_fugue256_init(&ctx_fugue);
9+
sph_fugue256(&ctx_fugue, input, len);
10+
sph_fugue256_close(&ctx_fugue, output);
11+
}
12+

fugue.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef FUGUE_H
2+
#define FUGUE_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
#include <stdint.h>
9+
10+
void fugue_hash(const char* input, char* output, uint32_t len);
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif
15+
16+
#endif

multihashing.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414
#include "x11.h"
1515
#include "groestl.h"
1616
#include "blake.h"
17+
#include "fugue.h"
1718
}
1819

1920
using namespace node;
@@ -287,6 +288,30 @@ Handle<Value> blake(const Arguments& args) {
287288
Buffer* buff = Buffer::New(output, 32);
288289
return scope.Close(buff->handle_);
289290
}
291+
292+
293+
Handle<Value> fugue(const Arguments& args) {
294+
HandleScope scope;
295+
296+
if (args.Length() < 1)
297+
return except("You must provide one argument.");
298+
299+
Local<Object> target = args[0]->ToObject();
300+
301+
if(!Buffer::HasInstance(target))
302+
return except("Argument should be a buffer object.");
303+
304+
char * input = Buffer::Data(target);
305+
char * output = new char[32];
306+
307+
uint32_t input_len = Buffer::Length(target);
308+
309+
fugue_hash(input, output, input_len);
310+
311+
Buffer* buff = Buffer::New(output, 32);
312+
return scope.Close(buff->handle_);
313+
}
314+
290315
void init(Handle<Object> exports) {
291316
exports->Set(String::NewSymbol("quark"), FunctionTemplate::New(quark)->GetFunction());
292317
exports->Set(String::NewSymbol("x11"), FunctionTemplate::New(x11)->GetFunction());
@@ -299,6 +324,7 @@ void init(Handle<Object> exports) {
299324
exports->Set(String::NewSymbol("groestl"), FunctionTemplate::New(groestl)->GetFunction());
300325
exports->Set(String::NewSymbol("groestl_myriad"), FunctionTemplate::New(groestl_myriad)->GetFunction());
301326
exports->Set(String::NewSymbol("blake"), FunctionTemplate::New(blake)->GetFunction());
327+
exports->Set(String::NewSymbol("fugue"), FunctionTemplate::New(fugue)->GetFunction());
302328
}
303329

304330
NODE_MODULE(multihashing, init)

0 commit comments

Comments
 (0)