forked from paixaop/node-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto_aead.cc
593 lines (549 loc) · 19.8 KB
/
crypto_aead.cc
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
/*
* Node Native Module for Lib Sodium
*
* @Author Pedro Paixao
* @email paixaop at gmail dot com
* @License MIT
*/
#include "node_sodium.h"
#include "crypto_aead.h"
/***
* Authenticated Encryption with Additional Data:
*
* Encrypts a message with a key and a nonce to keep it confidential Computes
* an authentication tag. This tag is used to make sure that the message, as
* well as optional, non-confidential (non-encrypted) data, haven't been
* tampered with.
*
* A typical use case for additional data is to store protocol-specific metadata
* about the message, such as its length and encoding.
*
* Supported Algorithms:
* * AES-GCM 256: API names use `aes256gcm`
* * ChaCha20-Poly1305: API names use `chacha20poly1305`
* * ChaCha20-Poly1305-IETF: API names use `chacha20poly1305-ietf`
*
* ### Modes
*
* #### Combined
* In combined mode, the authentication tag and the encrypted
* message are stored together. Functions return a buffer that includes the
* cipher text and authentication tag.
* Encrypt/Decrypt functions return a buffer with length equal to
* `message_length + crypto_aead_*_ABYTES` bytes.
*
* #### Detached
* In detached mode, the authentication tag and the encrypted
* message in different buffers. Detached function variants are named with the
* `_detached` sufix. Encrypt functions return:
*
* { cipherText: <buffer>, mac: <buffer> }
*
* ~ cipherText (Buffer): encrypted message
* ~ mac (Buffer): authentication tag (`crypto_aead_*_ABYTES` long)
*
* ### Constants
* Replace `ALGORITHM` with one of the supported algorithms (`aes256gcm`,
* `chacha20poly1305`, or `chacha20poly1305-ietf`)
*
* ~ crypto_aead_ALGORITHM_ABYTES: length of the authentication tag buffer
* ~ crypto_aead_ALGORITHM_KEYBYTES: length of secret key
* ~ crypto_aead_ALGORITHM_NPUBBYTES: lenght of public nonce
* ~ crypto_aead_ALGORITHM_NSECBYTES: length of secret nonce. Not used
*/
/**
* Crypto AEAD AES-GCM 256 API:
*
* The current implementation of this construction is hardware-accelerated and
* requires the Intel SSSE3 extensions, as well as the aesni and pclmul
* instructions.
*
* Intel Westmere processors (introduced in 2010) and newer meet the requirements.
*
* There are no plans to support non hardware-accelerated implementations of
* [AES-GCM](https://en.wikipedia.org/wiki/Galois/Counter_Mode).
* If portability is a concern, use ChaCha20-Poly1305 instead.
*/
/**
* Precompute API:
*
* Speeding up the encryption/decryption process.
* The precompute API breaks down the encrypt/decrypt functions in two stages -
* "Before" and "After". The "before" stage is called once, everytime your
* application changes encryption keys. The "after" stage is called for every
* message you need to encrypt/decrypt.
* The functions `*_beforenm` implement the "before" stage, and the `*_afternm`
* the "after" stage. They offer the same functionality as their non-precompute
* counterparts but take a "state" object generated by the `*_beforenm` instead
* of an encryption key.
*
* **Sample**:
*
* var sodium = require('sodium').api;
*
* // Generate a random key
* var key = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(key);
*
* // Generate random nonce
* var nonce = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(nonce);
*
* // Precompute and generate the state
* var state = sodium.crypto_aead_aes256gcm_beforenm(key);
*
* var message = new Buffer("this is a plain text message");
* var additionalData = new Buffer("metadata");
*
* // Encrypt Data
* var cipherText = sodium.crypto_aead_aes256gcm_encrypt_afternm(
* message, additionalData, nonce, state);
*
* // Get the plain text, i.e., original message back
* var plainText = sodium.crypto_aead_aes256gcm_decrypt_afternm(
* cipherText, additionalData, nonce, state);
*/
/**
* crypto_aead_aes256gcm_is_available:
*
* Check hardware support for AES 256 GCM
*
* **Returns**:
*
* ~ true: if hardware supports AES 256 GCM
*
* **Sample**:
*
* if( sodium.crypto_aead_aes256gcm_is_available() ) {
* // You can use the crypto_aead_aes256gcm_*()
* }
* else {
* // Use crypto_aead_chacha20poly1305_*()
* }
*
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_is_available) {
Nan::EscapableHandleScope scope;
if( crypto_aead_aes256gcm_is_available() == 1 ) {
return info.GetReturnValue().Set(Nan::True());
}
return info.GetReturnValue().Set(Nan::False());
}
/**
* crypto_aead_aes256gcm_beforenm:
* Precompute AES key expansion.
*
* Applications that encrypt several messages using the same key can gain a
* little speed by expanding the AES key only once, via the precalculation interface
* Initializes a context ctx by expanding the key k and always returns 0.
*
* var ctx = sodium.crypto_aead_aes256gcm_beforenm(key);
*
* ~ key (Buffer): AES 256 GCM Key buffer with crypto_aead_aes256gcm_KEYBYTES in length
*
* **Sample**:
*
* // Generate a random key
* var key = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(key);
* var state = sodium.crypto_aead_aes256gcm_beforenm(key);
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_beforenm) {
Nan::EscapableHandleScope scope;
ARGS(1,"arguments key must be a buffer");
ARG_TO_UCHAR_BUFFER_LEN(key, crypto_aead_aes256gcm_KEYBYTES);
NEW_BUFFER_AND_PTR(ctxt, crypto_aead_aes256gcm_statebytes());
if (crypto_aead_aes256gcm_beforenm((crypto_aead_aes256gcm_state*)ctxt_ptr, key) == 0) {
return info.GetReturnValue().Set(ctxt);
}
return info.GetReturnValue().Set(Nan::Undefined());
}
/**
* crypto_aead_aes256gcm_encrypt_afternm:
* Encrypt data in Combined Mode
*
* var c = sodium.crypto_aead_aes256gcm_encrypt_afternm(
* message,
* additionalData,
* nonce,
* ctx);
*
* ~ message (Buffer): plain text buffer
* ~ additionalData (Buffer): non-confidential data to add to the cipher text. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ ctx (Buffer): state computed by `crypto_aead_aes256gcm_beforenm()`
*
* **Returns**:
*
* ~ cipherText (Buffer): The encrypted message, as well as a tag authenticating
* both the confidential message `message` and non-confidential data `additionalData`
* ~ undefined: if `message` fails to encrypt
*
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_encrypt_afternm) {
Nan::EscapableHandleScope scope;
ARGS(4,"arguments message, additional data, nonce, and key must be buffers");
ARG_TO_UCHAR_BUFFER(m);
ARG_TO_UCHAR_BUFFER_OR_NULL(ad);
ARG_TO_UCHAR_BUFFER_LEN(npub, crypto_aead_aes256gcm_NPUBBYTES);
ARG_TO_VOID_BUFFER_LEN(ctx, crypto_aead_aes256gcm_statebytes());
NEW_BUFFER_AND_PTR(c, crypto_aead_aes256gcm_ABYTES + m_size);
sodium_memzero(c_ptr, crypto_aead_aes256gcm_ABYTES + m_size);
unsigned long long clen;
if( crypto_aead_aes256gcm_encrypt_afternm (c_ptr, &clen, m, m_size, ad, ad_size, NULL, npub, (crypto_aead_aes256gcm_state*)ctx) == 0 ) {
return info.GetReturnValue().Set(c);
}
return info.GetReturnValue().Set(Nan::Undefined());
}
/**
* crypto_aead_aes256gcm_decrypt_afternm:
* Decrypt data in Combined Mode
*
* var c = sodium.crypto_aead_aes256gcm_decrypt_afternm(
* cipherText,
* additionalData,
* nonce,
* ctx);
*
* ~ cipherText (Buffer): cipher text buffer, encrypted by crypto_aead_aes256gcm_encrypt_afternm()
* ~ additionalData (Buffer): non-confidential data to add to the cipher text. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ ctx (Buffer): state computed by `crypto_aead_aes256gcm_beforenm()`
*
* **Returns**:
*
* ~ message (Buffer): plain text message
* ~ undefined: if `cipherText` is not valid
*
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_decrypt_afternm) {
Nan::EscapableHandleScope scope;
ARGS(4,"arguments chiper text, additional data, nonce, and key must be buffers");
ARG_TO_UCHAR_BUFFER(c);
if( c_size < crypto_aead_aes256gcm_ABYTES ) {
std::ostringstream oss;
oss << "argument cipher text must be at least " << crypto_aead_aes256gcm_ABYTES << " bytes long" ;
return Nan::ThrowError(oss.str().c_str());
}
ARG_TO_UCHAR_BUFFER_OR_NULL(ad);
ARG_TO_UCHAR_BUFFER_LEN(npub, crypto_aead_aes256gcm_NPUBBYTES);
ARG_TO_VOID_BUFFER_LEN(ctx, crypto_aead_aes256gcm_statebytes());
NEW_BUFFER_AND_PTR(m, c_size - crypto_aead_aes256gcm_ABYTES);
unsigned long long mlen;
if( crypto_aead_aes256gcm_decrypt_afternm (m_ptr, &mlen, NULL, c, c_size, ad, ad_size, npub, (crypto_aead_aes256gcm_state*)ctx) == 0 ) {
return info.GetReturnValue().Set(m);
}
return info.GetReturnValue().Set(Nan::Undefined());
}
/**
* crypto_aead_aes256gcm_encrypt_detached_afternm:
* Encrypt data in Detached Mode
*
* var c = sodium.crypto_aead_aes256gcm_encrypt_detached_afternm(
* message,
* additionalData,
* nonce,
* ctx);
*
* ~ message (Buffer): plain text buffer
* ~ additionalData (Buffer): non-confidential data to add to the cipher text.
* Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in
* length
* ~ ctx (Buffer): state computed by `crypto_aead_aes256gcm_beforenm()`
*
* **Returns**:
*
* ~ object: `cipherText` buffer with ciphered text, and `mac` buffer with the
* authentication tag
*
* { cipherText: <buffer>, mac: <buffer> }
*
* ~ undefined: if `message` fails to encrypt
*
* **Sample**:
*
* var sodium = require('sodium').api;
*
* // Generate a random key
* var key = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(key);
*
* // Generate random nonce
* var nonce = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(nonce);
*
* // Precompute and generate the state
* var state = sodium.crypto_aead_aes256gcm_beforenm(key);
*
* var message = new Buffer("this is a plain text message");
* var additionalData = new Buffer("metadata");
*
* // Encrypt Data
* var c = sodium.crypto_aead_aes256gcm_encrypt_detached_afternm(
* message, additionalData, nonce, state);
*
* // Get the plain text, i.e., original message back
* var plainText = sodium.crypto_aead_aes256gcm_decrypt_detached_afternm(
* c.cipherText, c.mac, nonce, state);
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_encrypt_detached_afternm) {
Nan::EscapableHandleScope scope;
ARGS(4,"arguments message, additional data, nonce, and key must be buffers");
ARG_TO_UCHAR_BUFFER(m);
ARG_TO_UCHAR_BUFFER_OR_NULL(ad);
ARG_TO_UCHAR_BUFFER_LEN(npub, crypto_aead_aes256gcm_NPUBBYTES);
ARG_TO_VOID_BUFFER_LEN(ctx, crypto_aead_aes256gcm_statebytes());
NEW_BUFFER_AND_PTR(c, m_size);
NEW_BUFFER_AND_PTR(mac, crypto_aead_aes256gcm_ABYTES);
if( crypto_aead_aes256gcm_encrypt_detached_afternm(c_ptr, mac_ptr, NULL, m, m_size, ad, ad_size, NULL, npub, (crypto_aead_aes256gcm_state*)ctx) == 0 ) {
Local<Object> result = Nan::New<Object>();
result->ForceSet(Nan::New<String>("cipherText").ToLocalChecked(), c, DontDelete);
result->ForceSet(Nan::New<String>("mac").ToLocalChecked(), mac, DontDelete);
return info.GetReturnValue().Set(result);
}
return info.GetReturnValue().Set(Nan::Undefined());
}
/**
* crypto_aead_aes256gcm_decrypt_detached_afternm:
* Encrypt data in Detached Mode
*
* var c = sodium.crypto_aead_aes256gcm_decrypt_detached_afternm(
* cipherText,
* mac,
* nonce,
* ctx);
*
* ~ cipherText (Buffer): cipher text buffer
* ~ mac (Buffer): authentication tag. Can be null
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in
* length
* ~ ctx (Buffer): state computed by `crypto_aead_aes256gcm_beforenm()`
*
* **Returns**:
*
* ~ message (Buffer): plain text message
* ~ undefined: if `message` fails to encrypt
*
* See: [crypto_aead_aes256gcm_encrypt_detached_afternm](#crypto_aead_aes256gcm_encrypt_detached_afternm)
*
*/
NAN_METHOD(bind_crypto_aead_aes256gcm_decrypt_detached_afternm) {
Nan::EscapableHandleScope scope;
ARGS(4,"arguments cipher message, mac, additional data, nsec, nonce, and key must be buffers");
ARG_TO_UCHAR_BUFFER(c);
ARG_TO_UCHAR_BUFFER_LEN(mac, crypto_aead_aes256gcm_ABYTES);
ARG_TO_UCHAR_BUFFER_OR_NULL(ad);
ARG_TO_UCHAR_BUFFER_LEN(npub, crypto_aead_aes256gcm_NPUBBYTES);
ARG_TO_VOID_BUFFER_LEN(ctx, crypto_aead_aes256gcm_statebytes());
NEW_BUFFER_AND_PTR(m, c_size);
if( crypto_aead_aes256gcm_decrypt_detached_afternm(m_ptr, NULL, c, c_size, mac, ad, ad_size, npub, (crypto_aead_aes256gcm_state*)ctx) == 0 ) {
return info.GetReturnValue().Set(m);
}
return info.GetReturnValue().Set(Nan::Undefined());
}
/**
* crypto_aead_aes256gcm_encrypt:
* Encrypt Message in Combined Mode
*
* var c = sodium.crypto_aead_aes256gcm_encrypt(
* message,
* additionalData,
* nonce,
* key);
*
* ~ message (Buffer): plain text buffer
* ~ additionalData (Buffer): non-confidential data to add to the cipher text. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ key (Buffer): secret key `sodium.crypto_aead_aes256gcm_KEYBYTES` in length
*
* **Returns**:
*
* ~ cipherText (Buffer): The encrypted message, as well as a tag authenticating
* both the confidential message `message` and non-confidential data `additionalData`
* ~ undefined: if `message` fails to encrypt
*
* **Sample**:
*
* var sodium = require('sodium').api;
*
* // Generate a random key
* var key = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(key);
*
* // Generate random nonce
* var nonce = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(nonce);
*
* var message = new Buffer("this is a plain text message");
* var additionalData = new Buffer("metadata");
*
* // Encrypt Data
* var cipherText = sodium.crypto_aead_aes256gcm_encrypt(
* message, additionalData, nonce, key);
*
* // Get the plain text, i.e., original message back
* var plainText = sodium.crypto_aead_aes256gcm_decrypt(
* cipherText, additionalData, nonce, key);
*/
/**
* crypto_aead_aes256gcm_decrypt:
* Encrypt Message in Combined Mode
*
* var m = sodium.crypto_aead_aes256gcm_decrypt(
* cipherText,
* additionalData,
* nonce,
* key);
*
* ~ cipherText (Buffer): encrypted buffer
* ~ additionalData (Buffer): non-confidential data to add to the cipher text. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ key (Buffer): secret key `sodium.crypto_aead_aes256gcm_KEYBYTES` in length
*
* **Returns**:
*
* ~ plainText (Buffer): The decrypted plain text message
* ~ undefined: if `message` fails to encrypt
*
* **See**: [crypto_aead_aes256gcm_encrypt](#crypto_aead_aes256gcm_encrypt)
*/
CRYPTO_AEAD_DEF(aes256gcm)
/**
* crypto_aead_aes256gcm_encrypt_detached:
* Encrypt Message in Detached Mode
*
* var c = sodium.crypto_aead_aes256gcm_encrypt_detached(
* message,
* additionalData,
* nonce,
* key);
*
* ~ message (Buffer): plain text buffer
* ~ additionalData (Buffer): non-confidential data to add to the cipher text. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ key (Buffer): secret key `sodium.crypto_aead_aes256gcm_KEYBYTES` in length
*
* **Returns**:
*
* ~ object: `cipherText` buffer with ciphered text, and `mac` buffer with the
* authentication tag
*
* { cipherText: <buffer>, mac: <buffer> }
*
* ~ undefined: if `message` fails to encrypt
*
* **Sample**:
*
* var sodium = require('sodium').api;
*
* // Generate a random key
* var key = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(key);
*
* // Generate random nonce
* var nonce = new Buffer(crypto_aead_aes256gcm_KEYBYTES);
* sodium.randombytes_buf(nonce);
*
* var message = new Buffer("this is a plain text message");
* var additionalData = new Buffer("metadata");
*
* // Encrypt Data
* var c = sodium.crypto_aead_aes256gcm_encrypt_detached(
* message, additionalData, nonce, key);
*
* // Get the plain text, i.e., original message back
* var plainText = sodium.crypto_aead_aes256gcm_decrypt_detached(
* c.cipherText, c.mac, nonce, key);
*/
/**
* crypto_aead_aes256gcm_decrypt_detached:
* Encrypt Message in Detached Mode
*
* var m = sodium.crypto_aead_aes256gcm_decrypt(
* cipherText,
* mac,
* nonce,
* key);
*
* ~ cipherText (Buffer): encrypted buffer
* ~ mac (Buffer): authentication tag. Can be `null`
* ~ nonce (Buffer): a nonce with `sodium.crypto_aead_aes256gcm_NPUBBYTES` in length
* ~ key (Buffer): secret key `sodium.crypto_aead_aes256gcm_KEYBYTES` in length
*
* **Returns**:
*
* ~ plainText (Buffer): The decrypted plain text message
* ~ undefined: if `message` fails to encrypt
*
* **See**: [crypto_aead_aes256gcm_encrypt](#crypto_aead_aes256gcm_encrypt)
*/
CRYPTO_AEAD_DETACHED_DEF(aes256gcm)
/** Crypto AEAD ChaCha20-Poly1305 API: */
/**
* crypto_aead_chacha20poly1305_encrypt:
* Encrypt Message in Detached Mode using ChaCha20-Poly1305
*
* See [crypto_aead_aes256gcm_encrypt](#crypto_aead_aes256gcm_encrypt)
*/
/**
* crypto_aead_chacha20poly1305_decrypt:
* Dencrypt Message in Detached Mode using ChaCha20-Poly1305
*
* See [crypto_aead_aes256gcm_decrypt](#crypto_aead_aes256gcm_decrypt)
*/
CRYPTO_AEAD_DEF(chacha20poly1305)
/**
* crypto_aead_chacha20poly1305_encrypt_detached:
* Encrypt Message in Detached Mode using ChaCha20-Poly1305
*
* See [crypto_aead_aes256gcm_encrypt_detached](#crypto_aead_aes256gcm_encrypt_detached)
*/
/**
* crypto_aead_chacha20poly1305_decrypt_detached:
* Dencrypt Message in Detached Mode using ChaCha20-Poly1305
*
* See [crypto_aead_aes256gcm_decrypt_detached](#crypto_aead_aes256gcm_decrypt_detached)
*/
CRYPTO_AEAD_DETACHED_DEF(chacha20poly1305)
/** Crypto AEAD ChaCha20-Poly1305-IETF API: */
/**
* crypto_aead_chacha20poly1305_ietf_encrypt:
* Encrypt Message in Combined Mode using ChaCha20-Poly1305-IETF
*
* See [crypto_aead_aes256gcm_encrypt](#crypto_aead_aes256gcm_encrypt)
*/
/**
* crypto_aead_chacha20poly1305_ietf_decrypt:
* Dencrypt Message in Combined Mode using ChaCha20-Poly1305-IETF
*
* See [crypto_aead_aes256gcm_decrypt](#crypto_aead_aes256gcm_decrypt)
*/
CRYPTO_AEAD_DEF(chacha20poly1305_ietf)
/**
* crypto_aead_chacha20poly1305_ietf_encrypt_detached:
* Encrypt Message in Detached Mode using ChaCha20-Poly1305-IETF
*
* See [crypto_aead_aes256gcm_encrypt_detached](#crypto_aead_aes256gcm_encrypt_detached)
*/
/**
* crypto_aead_chacha20poly1305_decrypt_detached:
* Dencrypt Message in Detached Mode using ChaCha20-Poly1305-IETF
*
* See [crypto_aead_aes256gcm_decrypt_detached](#crypto_aead_aes256gcm_decrypt_detached)
*/
CRYPTO_AEAD_DETACHED_DEF(chacha20poly1305_ietf)
/*
* Register function calls in node binding
*/
void register_crypto_aead(Handle<Object> target) {
NEW_METHOD(crypto_aead_aes256gcm_is_available);
NEW_METHOD(crypto_aead_aes256gcm_beforenm);
NEW_METHOD(crypto_aead_aes256gcm_encrypt_afternm);
NEW_METHOD(crypto_aead_aes256gcm_decrypt_afternm);
NEW_METHOD(crypto_aead_aes256gcm_encrypt_detached_afternm);
NEW_METHOD(crypto_aead_aes256gcm_decrypt_detached_afternm);
METHOD_AND_PROPS(aes256gcm);
METHOD_AND_PROPS(chacha20poly1305);
METHOD_AND_PROPS(chacha20poly1305_ietf);
}