Skip to content

Commit 1ef9923

Browse files
authored
test: add chacha20-poly1305 to auth tag order test
Add ChaCha20-Poly1305 to the algorithms for which we ensure that the authentication tag can be set either before or after calling `update()`. PR-URL: #58367 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
1 parent 38757c9 commit 1ef9923

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/parallel/test-crypto-authenticated.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,22 +448,22 @@ for (const test of TEST_CASES) {
448448
}
449449

450450
// 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.
452452
{
453453
const plain = Buffer.from('Hello world', 'utf8');
454-
const key = Buffer.from('0123456789abcdef', 'utf8');
454+
const key = Buffer.from('0123456789abcdefghijklmnopqrstuv', 'utf8');
455455
const iv = Buffer.from('0123456789ab', 'utf8');
456456

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, {
460460
authTagLength
461461
});
462462
const ciphertext = Buffer.concat([cipher.update(plain), cipher.final()]);
463463
const authTag = cipher.getAuthTag();
464464

465465
for (const authTagBeforeUpdate of [true, false]) {
466-
const decipher = crypto.createDecipheriv(`aes-128-${mode}`, key, iv, {
466+
const decipher = crypto.createDecipheriv(alg, key, iv, {
467467
authTagLength
468468
});
469469
if (authTagBeforeUpdate) {

0 commit comments

Comments
 (0)