From 342e096a0f28077549c73c0464534be23903e966 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 2 May 2025 10:56:50 +0200 Subject: [PATCH] test: make crypto tests work with BoringSSL --- test/parallel/test-crypto-stream.js | 8 ++++---- test/parallel/test-crypto.js | 4 ++-- test/parallel/test-tls-alert-handling.js | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js index 62be4eaf6edfb0..747af780469c22 100644 --- a/test/parallel/test-crypto-stream.js +++ b/test/parallel/test-crypto-stream.js @@ -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. diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index 93644e016de447..84111740cd9ef6 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -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; diff --git a/test/parallel/test-tls-alert-handling.js b/test/parallel/test-tls-alert-handling.js index cba5bebaa29b6f..7bd42bbe721c4c 100644 --- a/test/parallel/test-tls-alert-handling.js +++ b/test/parallel/test-tls-alert-handling.js @@ -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); })); }