Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/parallel/test-crypto-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading