forked from paixaop/node-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pedro Paixao
authored and
Pedro Paixao
committed
Apr 13, 2016
1 parent
194729e
commit 36595ed
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Node Native Module for Lib Sodium | ||
* | ||
* @Author Pedro Paixao | ||
* @email paixaop at gmail dot com | ||
* @License MIT | ||
*/ | ||
#include "node_sodium.h" | ||
|
||
|
||
/** | ||
* Register function calls in node binding | ||
*/ | ||
void register_crypto_aead(Handle<Object> target) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Node Native Module for Lib Sodium | ||
* | ||
* @Author Pedro Paixao | ||
* @email paixaop at gmail dot com | ||
* @License MIT | ||
*/ | ||
#ifndef __CRYPTO_AEAD_H__ | ||
#define __CRYPTO_AEAD_H__ | ||
|
||
/* | ||
int crypto_aead_aes256gcm_decrypt(unsigned char *m, | ||
unsigned long long *mlen_p, | ||
unsigned char *nsec, | ||
const unsigned char *c, | ||
unsigned long long clen, | ||
const unsigned char *ad, | ||
unsigned long long adlen, | ||
const unsigned char *npub, | ||
const unsigned char *k) | ||
*/ | ||
|
||
#define CRYPTO_AEAD_DEF(ALGO) \ | ||
NAN_METHOD(bind_crypto_aead_ ## ALGO ## _decrypt) { \ | ||
Nan::EscapableHandleScope scope; \ | ||
ARGS(2,"arguments message, and key must be buffers"); \ | ||
ARG_TO_UCHAR_BUFFER(msg);\ | ||
ARG_TO_UCHAR_BUFFER_LEN(key, crypto_auth_ ## ALGO ## _KEYBYTES); \ | ||
NEW_BUFFER_AND_PTR(token, crypto_auth_ ## ALGO ## _BYTES); \ | ||
if( crypto_auth_ ## ALGO ## _decrypt (token_ptr, msg, msg_size, key) == 0 ) { \ | ||
return info.GetReturnValue().Set(token); \ | ||
} \ | ||
return info.GetReturnValue().Set(Nan::Null()); \ | ||
}\ | ||
|
||
#define METHOD_AND_PROPS(ALGO) \ | ||
NEW_METHOD(crypto_aead_ ## ALGO ## _decrypt); \ | ||
NEW_METHOD(crypto_aead_ ## ALGO ## _decrypt_detached); \ | ||
NEW_METHOD(crypto_aead_ ## ALGO ## _encrypt); \ | ||
NEW_METHOD(crypto_aead_ ## ALGO ## _encrypt_detached); \ | ||
NEW_INT_PROP(crypto_aead_ ## ALGO ## _ABYTES); \ | ||
NEW_INT_PROP(crypto_aead_ ## ALGO ## _KEYBYTES); \ | ||
NEW_INT_PROP(crypto_aead_ ## ALGO ## _NPUBBYTES); \ | ||
NEW_INT_PROP(crypto_aead_ ## ALGO ## _NSECBYTES); \ | ||
NEW_INT_PROP(crypto_aead_ ## ALGO ## _STATEBYTES); | ||
|
||
#define NAN_METHODS(ALGO) \ | ||
NAN_METHOD(bind_crypto_auth_ ## ALGO); \ | ||
NAN_METHOD(bind_crypto_auth_ ## ALGO ## _verify); \ | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters