doc,test: account for OpenSSL 4.1 behaviours by panva · Pull Request #65956 · nodejs/node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 2 additions & 6 deletions doc/api/crypto.md
12 changes: 9 additions & 3 deletions test/parallel/test-crypto-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const TEST_CASES = require(fixtures.path('aead-vectors.js'));

const errMessages = {
auth: / auth/,
// OpenSSL 4.1 adds a provider error for AEAD tag mismatches.
// https://github.com/openssl/openssl/pull/32587
badDecrypt: hasOpenSSL(4, 1) ?
{ code: 'ERR_OSSL_BAD_DECRYPT' } : /Unsupported state or unable to authenticate data/,
state: / state/,
FIPS: /not supported in FIPS mode/,
length: /Invalid initialization vector/,
Expand Down Expand Up @@ -128,7 +132,8 @@ for (const test of TEST_CASES) {
assert.strictEqual(msg, test.plain);
} else {
// Assert that final throws if input data could not be verified!
assert.throws(function() { decrypt.final('hex'); }, errMessages.auth);
assert.throws(function() { decrypt.final('hex'); },
isCCM || isSIV ? errMessages.auth : errMessages.badDecrypt);
}
}
}
Expand Down Expand Up @@ -358,7 +363,8 @@ for (const test of TEST_CASES) {
decipher.update(ciphertext);
assert.throws(() => {
decipher.final();
}, /Unsupported state or unable to authenticate data/);
}, algo === 'aes-128-siv' ?
/Unsupported state or unable to authenticate data/ : errMessages.badDecrypt);
}
}
}
Expand Down Expand Up @@ -969,7 +975,7 @@ if (!fips3 && !isBoringSSL) {

assert.throws(() => {
decipher.final();
}, /Unsupported state or unable to authenticate data/);
}, errMessages.badDecrypt);
} else {
common.printSkipMessage('Skipping unsupported chacha20-poly1305 test');
}
Expand Down
16 changes: 14 additions & 2 deletions test/parallel/test-crypto-x509.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,21 @@ const der = Buffer.from(

assert.strictEqual(x509.checkIP('127.0.0.1'), undefined);
assert.strictEqual(x509.checkIP('::'), undefined);
assert.strictEqual(x509.checkHost('agent1'), 'agent1');
// OpenSSL 4.1 no longer checks the subject DN by default.
// https://github.com/openssl/openssl/pull/31982
for (const options of [undefined, { subject: 'default' }]) {
assert.strictEqual(x509.checkHost('agent1', options),
hasOpenSSL(4, 1) ? undefined : 'agent1');
assert.strictEqual(x509.checkEmail('ry@tinyclouds.org', options),
hasOpenSSL(4, 1) ? undefined : 'ry@tinyclouds.org');
}
assert.strictEqual(x509.checkHost('agent1', { subject: 'always' }), 'agent1');
assert.strictEqual(x509.checkHost('agent1', { subject: 'never' }), undefined);
assert.strictEqual(x509.checkHost('agent2'), undefined);
assert.strictEqual(x509.checkEmail('ry@tinyclouds.org'), 'ry@tinyclouds.org');
assert.strictEqual(x509.checkEmail('ry@tinyclouds.org', { subject: 'always' }),
'ry@tinyclouds.org');
assert.strictEqual(x509.checkEmail('ry@tinyclouds.org', { subject: 'never' }),
undefined);
assert.strictEqual(x509.checkEmail('sally@example.com'), undefined);
assert.throws(() => x509.checkHost('agent\x001'), {
code: 'ERR_INVALID_ARG_VALUE'
Expand Down
9 changes: 6 additions & 3 deletions test/parallel/test-tls-psk-circuit.js
Loading