test: make crypto tests work with BoringSSL

PR-URL: https://github.com/nodejs/node/pull/58117
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
Shelley Vohr 2025-05-22 13:26:56 +02:00 committed by GitHub
parent 2b425345fe
commit 5ffcf6bca1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View File

@ -74,14 +74,14 @@ const decipher = crypto.createDecipheriv('aes-128-cbc', badkey, iv);
cipher.pipe(decipher)
.on('error', common.expectsError(hasOpenSSL3 ? {
message: /bad decrypt/,
message: /bad[\s_]decrypt/,
library: 'Provider routines',
reason: 'bad decrypt',
reason: /bad[\s_]decrypt/i,
} : {
message: /bad decrypt/,
message: /bad[\s_]decrypt/i,
function: 'EVP_DecryptFinal_ex',
library: 'digital envelope routines',
reason: 'bad decrypt',
reason: /bad[\s_]decrypt/i,
}));
cipher.end('Papaya!'); // Should not cause an unhandled exception.

View File

@ -218,9 +218,9 @@ assert.throws(() => {
} : {
name: 'Error',
message: /routines:RSA_sign:digest too big for rsa key$/,
library: 'rsa routines',
library: /rsa routines/i,
function: 'RSA_sign',
reason: 'digest too big for rsa key',
reason: /digest[\s_]too[\s_]big[\s_]for[\s_]rsa[\s_]key/i,
code: 'ERR_OSSL_RSA_DIGEST_TOO_BIG_FOR_RSA_KEY'
});
return true;

View File

@ -35,16 +35,16 @@ let iter = 0;
const errorHandler = common.mustCall((err) => {
let expectedErrorCode = 'ERR_SSL_WRONG_VERSION_NUMBER';
let expectedErrorReason = 'wrong version number';
let expectedErrorReason = /wrong[\s_]version[\s_]number/i;
if (hasOpenSSL(3, 2)) {
expectedErrorCode = 'ERR_SSL_PACKET_LENGTH_TOO_LONG';
expectedErrorReason = 'packet length too long';
expectedErrorReason = /packet[\s_]length[\s_]too[\s_]long/i;
};
assert.strictEqual(err.code, expectedErrorCode);
assert.strictEqual(err.library, 'SSL routines');
if (!hasOpenSSL3) assert.strictEqual(err.function, 'ssl3_get_record');
assert.strictEqual(err.reason, expectedErrorReason);
assert.match(err.reason, expectedErrorReason);
errorReceived = true;
if (canCloseServer())
server.close();
@ -98,15 +98,15 @@ function sendBADTLSRecord() {
}));
client.on('error', common.mustCall((err) => {
let expectedErrorCode = 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION';
let expectedErrorReason = 'tlsv1 alert protocol version';
let expectedErrorReason = /tlsv1[\s_]alert[\s_]protocol[\s_]version/i;
if (hasOpenSSL(3, 2)) {
expectedErrorCode = 'ERR_SSL_TLSV1_ALERT_RECORD_OVERFLOW';
expectedErrorReason = 'tlsv1 alert record overflow';
expectedErrorReason = /tlsv1[\s_]alert[\s_]record[\s_]overflow/i;
}
assert.strictEqual(err.code, expectedErrorCode);
assert.strictEqual(err.library, 'SSL routines');
if (!hasOpenSSL3)
assert.strictEqual(err.function, 'ssl3_read_bytes');
assert.strictEqual(err.reason, expectedErrorReason);
assert.match(err.reason, expectedErrorReason);
}));
}