| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1eda87c commit 33f6158
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -448,22 +448,22 @@ for (const test of TEST_CASES) { | |||
| 448 | 448 | } | |
| 449 | 449 | ||
| 450 | 450 | // Test that the authentication tag can be set at any point before calling | |
| 451 | - // final() in GCM or OCB mode. | ||
| 451 | + // final() in GCM mode, OCB mode, and for ChaCha20-Poly1305. | ||
| 452 | 452 | { | |
| 453 | 453 | const plain = Buffer.from('Hello world', 'utf8'); | |
| 454 | - const key = Buffer.from('0123456789abcdef', 'utf8'); | ||
| 454 | + const key = Buffer.from('0123456789abcdefghijklmnopqrstuv', 'utf8'); | ||
| 455 | 455 | const iv = Buffer.from('0123456789ab', 'utf8'); | |
| 456 | 456 | ||
| 457 | - for (const mode of ['gcm', 'ocb']) { | ||
| 458 | - for (const authTagLength of mode === 'gcm' ? [undefined, 8] : [8]) { | ||
| 459 | - const cipher = crypto.createCipheriv(`aes-128-${mode}`, key, iv, { | ||
| 457 | + for (const alg of ['aes-256-gcm', 'aes-256-ocb', 'chacha20-poly1305']) { | ||
| 458 | + for (const authTagLength of alg === 'aes-256-gcm' ? [undefined, 8] : [8]) { | ||
| 459 | + const cipher = crypto.createCipheriv(alg, key, iv, { | ||
| 460 | 460 | authTagLength | |
| 461 | 461 | }); | |
| 462 | 462 | const ciphertext = Buffer.concat([cipher.update(plain), cipher.final()]); | |
| 463 | 463 | const authTag = cipher.getAuthTag(); | |
| 464 | 464 | ||
| 465 | 465 | for (const authTagBeforeUpdate of [true, false]) { | |
| 466 | - const decipher = crypto.createDecipheriv(`aes-128-${mode}`, key, iv, { | ||
| 466 | + const decipher = crypto.createDecipheriv(alg, key, iv, { | ||
| 467 | 467 | authTagLength | |
| 468 | 468 | }); | |
| 469 | 469 | if (authTagBeforeUpdate) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments