diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index 1fc7409c47d..a554327d728 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -448,22 +448,22 @@ for (const test of TEST_CASES) { } // Test that the authentication tag can be set at any point before calling -// final() in GCM or OCB mode. +// final() in GCM mode, OCB mode, and for ChaCha20-Poly1305. { const plain = Buffer.from('Hello world', 'utf8'); - const key = Buffer.from('0123456789abcdef', 'utf8'); + const key = Buffer.from('0123456789abcdefghijklmnopqrstuv', 'utf8'); const iv = Buffer.from('0123456789ab', 'utf8'); - for (const mode of ['gcm', 'ocb']) { - for (const authTagLength of mode === 'gcm' ? [undefined, 8] : [8]) { - const cipher = crypto.createCipheriv(`aes-128-${mode}`, key, iv, { + for (const alg of ['aes-256-gcm', 'aes-256-ocb', 'chacha20-poly1305']) { + for (const authTagLength of alg === 'aes-256-gcm' ? [undefined, 8] : [8]) { + const cipher = crypto.createCipheriv(alg, key, iv, { authTagLength }); const ciphertext = Buffer.concat([cipher.update(plain), cipher.final()]); const authTag = cipher.getAuthTag(); for (const authTagBeforeUpdate of [true, false]) { - const decipher = crypto.createDecipheriv(`aes-128-${mode}`, key, iv, { + const decipher = crypto.createDecipheriv(alg, key, iv, { authTagLength }); if (authTagBeforeUpdate) {