Repository: nodejs/node
Pull request: test: make crypto tests work with BoringSSL

As in title - this PR makes crypto tests work with BoringSSL. Similar to previous PRs.

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: test/parallel/test-crypto-stream.js
patch: @@ -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.

filename: test/parallel/test-crypto.js
patch: @@ -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;

filename: test/parallel/test-tls-alert-handling.js
patch: @@ -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);
   }));
 }