Skip to content
Open
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
29 changes: 22 additions & 7 deletions test/parallel/test-crypto-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,29 @@ for (const test of TEST_CASES) {
const iv = Buffer.alloc(12);
const opts = { authTagLength: 10 };

const control = crypto.createCipheriv(algo, key, iv, opts);
control.update(Buffer.alloc(0));
control.final();
const expectedTag = control.getAuthTag();

const cipher = crypto.createCipheriv(algo, key, iv, opts);
assert.throws(() => {
cipher.final();
}, hasOpenSSL3 ? {
code: 'ERR_OSSL_TAG_NOT_SET'
} : {
message: /Unsupported state/
});
let output;
try {
output = cipher.final();
} catch (err) {
// OpenSSL without https://github.com/openssl/openssl/pull/32427
// cannot finalize an empty CCM message unless update() was called.
if (hasOpenSSL3) {
assert.strictEqual(err.code, 'ERR_OSSL_TAG_NOT_SET');
} else {
assert.match(err.message, /Unsupported state/);
}
}

if (output !== undefined) {
assert.deepStrictEqual(output, Buffer.alloc(0));
assert.deepStrictEqual(cipher.getAuthTag(), expectedTag);
}
}

{
Expand Down
Loading