@@ -165,92 +165,6 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
165165 const algo = 'aes-128-ccm';
166166 const key = Buffer.alloc(16);
167167 const iv = Buffer.alloc(12);
168- diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js
169- index 3bbca5b0da395b94c04da7bb7c55b107e41367d8..af62558c4f23aa82804e0077da7b7f3a86cfac60 100644
170- --- a/test/parallel/test-crypto-binary-default.js
171- +++ b/test/parallel/test-crypto-binary-default.js
172- @@ -51,15 +51,15 @@ tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
173-
174- assert.throws(function() {
175- tls.createSecureContext({ pfx: certPfx });
176- - }, /^Error: mac verify failure$/);
177- + }, /^Error: (mac verify failure|INCORRECT_PASSWORD)$/);
178-
179- assert.throws(function() {
180- tls.createSecureContext({ pfx: certPfx, passphrase: 'test' });
181- - }, /^Error: mac verify failure$/);
182- + }, /^Error: (mac verify failure|INCORRECT_PASSWORD)$/);
183-
184- assert.throws(function() {
185- tls.createSecureContext({ pfx: 'sample', passphrase: 'test' });
186- - }, /^Error: not enough data$/);
187- + }, /^Error: (not enough data|BAD_PKCS12_DATA)$/);
188-
189- // Test HMAC
190- {
191- @@ -462,7 +462,7 @@ assert.throws(function() {
192- function testCipher1(key) {
193- // Test encryption and decryption
194- const plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
195- - const cipher = crypto.createCipher('aes192', key);
196- + const cipher = crypto.createCipher('aes-192-cbc', key);
197-
198- // Encrypt plaintext which is in utf8 format
199- // to a ciphertext which will be in hex
200- @@ -470,7 +470,7 @@ function testCipher1(key) {
201- // Only use binary or hex, not base64.
202- ciph += cipher.final('hex');
203-
204- - const decipher = crypto.createDecipher('aes192', key);
205- + const decipher = crypto.createDecipher('aes-192-cbc', key);
206- let txt = decipher.update(ciph, 'hex', 'utf8');
207- txt += decipher.final('utf8');
208-
209- @@ -485,14 +485,14 @@ function testCipher2(key) {
210- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
211- 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
212- 'jAfaFg**';
213- - const cipher = crypto.createCipher('aes256', key);
214- + const cipher = crypto.createCipher('aes-256-cbc', key);
215-
216- // Encrypt plaintext which is in utf8 format
217- // to a ciphertext which will be in Base64
218- let ciph = cipher.update(plaintext, 'utf8', 'base64');
219- ciph += cipher.final('base64');
220-
221- - const decipher = crypto.createDecipher('aes256', key);
222- + const decipher = crypto.createDecipher('aes-256-cbc', key);
223- let txt = decipher.update(ciph, 'base64', 'utf8');
224- txt += decipher.final('utf8');
225-
226- @@ -537,6 +537,10 @@ function testCipher4(key, iv) {
227-
228-
229- function testCipher5(key, iv) {
230- + if (!crypto.getCiphers().includes('id-aes128-wrap')) {
231- + common.printSkipMessage(`unsupported id-aes128-wrap test`);
232- + return;
233- + }
234- // Test encryption and decryption with explicit key with aes128-wrap
235- const plaintext =
236- '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
237- @@ -662,6 +666,8 @@ assert.throws(
238- }
239-
240-
241- + /* NB: BoringSSL does not support using DSA through the EVP API.
242- + * https://boringssl.googlesource.com/boringssl/+/a2278d4d2cabe73f6663e3299ea7808edfa306b9/PORTING.md#dsa-s
243- //
244- // Test DSA signing and verification
245- //
246- @@ -682,6 +688,7 @@ assert.throws(
247-
248- assert.strictEqual(verify.verify(publicKey, signature, 'hex'), true);
249- }
250- + */
251-
252-
253- //
254168diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
255169index 4a5f1f149fe6c739f7f1d2ee17df6e61a942d621..b3287f428ce6b3fde11d449c601a57ff5e3843f9 100644
256170--- a/test/parallel/test-crypto-certificate.js
@@ -432,11 +346,11 @@ index 81a469c226c261564dee1e0b06b6571b18a41f1f..58b66045dba4201b7ebedd78b129420f
432346 assert.notStrictEqual(bad_dh.verifyError, 0);
433347
434348 const availableCurves = new Set(crypto.getCurves());
435- diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
436- index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e311bf20f 100644
437- --- a/test/parallel/test-crypto-dh.js
438- +++ b/test/parallel/test-crypto-dh.js
439- @@ -47,17 +47,19 @@ for (const bits of [-1, 0, 1]) {
349+ diff --git a/test/parallel/test-crypto-dh-errors .js b/test/parallel/test-crypto-dh-errors .js
350+ index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af514538780 100644
351+ --- a/test/parallel/test-crypto-dh-errors .js
352+ +++ b/test/parallel/test-crypto-dh-errors .js
353+ @@ -32,9 +32,9 @@ for (const bits of [-1, 0, 1]) {
440354 });
441355 } else {
442356 assert.throws(() => crypto.createDiffieHellman(bits), {
@@ -448,19 +362,7 @@ index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e
448362 });
449363 }
450364 }
451-
452- - // Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
453- {
454- const g = 0;
455- - crypto.createDiffieHellman('abcdef', g);
456- + assert.throws(() => crypto.createDiffieHellman('abcdef', g), {
457- + code: /INVALID_PARAMETERS/,
458- + name: 'Error'
459- + });
460- crypto.createDiffieHellman('abcdef', 'hex', g);
461- }
462-
463- @@ -65,13 +67,18 @@ for (const g of [-1, 1]) {
365+ @@ -43,7 +43,7 @@ for (const g of [-1, 1]) {
464366 const ex = {
465367 code: 'ERR_OSSL_DH_BAD_GENERATOR',
466368 name: 'Error',
@@ -469,19 +371,7 @@ index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e
469371 };
470372 assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
471373 assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
472- }
473-
474- - crypto.createDiffieHellman('abcdef', Buffer.from([2])); // OK
475- + {
476- + assert.throws(() => crypto.createDiffieHellman('abcdef', Buffer.from([2])), {
477- + code: /INVALID_PARAMETERS/,
478- + name: 'Error'
479- + });
480- + }
481-
482- for (const g of [Buffer.from([]),
483- Buffer.from([0]),
484- @@ -79,7 +86,7 @@ for (const g of [Buffer.from([]),
374+ @@ -55,7 +55,7 @@ for (const g of [Buffer.from([]),
485375 const ex = {
486376 code: 'ERR_OSSL_DH_BAD_GENERATOR',
487377 name: 'Error',
@@ -490,33 +380,56 @@ index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e
490380 };
491381 assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
492382 assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
493- @@ -133,18 +140,17 @@ assert.strictEqual(secret1, secret4);
494- let wrongBlockLength;
495- if (common.hasOpenSSL3) {
496- wrongBlockLength = {
497- - message: 'error:1C80006B:Provider routines::wrong final block length',
498- - code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
499- - library: 'Provider routines',
500- - reason: 'wrong final block length'
501- + message: /error:1C80006B:Provider routines::wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
502- + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
503- + library: /digital envelope routines|Cipher functions/,
504- + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
505- };
506- } else {
507- wrongBlockLength = {
508- - message: 'error:0606506D:digital envelope' +
509- - ' routines:EVP_DecryptFinal_ex:wrong final block length',
510- - code: 'ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH',
511- - library: 'digital envelope routines',
512- - reason: 'wrong final block length'
513- + message: /error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
514- + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
515- + library: /digital envelope routines|Cipher functions/,
516- + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
517- };
383+ diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
384+ index abbe1abe7e53d7bd113afb68b0e9af1e814c70bd..086a8e38021ed1a87be22246cdb4f5ceb56eee4c 100644
385+ --- a/test/parallel/test-crypto-dh.js
386+ +++ b/test/parallel/test-crypto-dh.js
387+ @@ -55,18 +55,17 @@ const crypto = require('crypto');
388+ let wrongBlockLength;
389+ if (common.hasOpenSSL3) {
390+ wrongBlockLength = {
391+ - message: 'error:1C80006B:Provider routines::wrong final block length',
392+ - code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
393+ - library: 'Provider routines',
394+ - reason: 'wrong final block length'
395+ + message: /error:1C80006B:Provider routines::wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
396+ + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
397+ + library: /digital envelope routines|Cipher functions/,
398+ + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
399+ };
400+ } else {
401+ wrongBlockLength = {
402+ - message: 'error:0606506D:digital envelope' +
403+ - ' routines:EVP_DecryptFinal_ex:wrong final block length',
404+ - code: 'ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH',
405+ - library: 'digital envelope routines',
406+ - reason: 'wrong final block length'
407+ + message: /error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
408+ + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
409+ + library: /digital envelope routines|Cipher functions/,
410+ + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
411+ };
412+ }
413+
414+ @@ -95,10 +94,16 @@ const crypto = require('crypto');
415+ // Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
416+ {
417+ const g = 0;
418+ - crypto.createDiffieHellman('abcdef', g);
419+ + assert.throws(() => crypto.createDiffieHellman('abcdef', g), {
420+ + code: /INVALID_PARAMETERS/,
421+ + name: 'Error'
422+ + });
423+ crypto.createDiffieHellman('abcdef', 'hex', g);
518424 }
519425
426+ {
427+ - crypto.createDiffieHellman('abcdef', Buffer.from([2])); // OK
428+ + assert.throws(() => crypto.createDiffieHellman('abcdef', Buffer.from([2])), {
429+ + code: /INVALID_PARAMETERS/,
430+ + name: 'Error'
431+ + });
432+ }
520433diff --git a/test/parallel/test-crypto-getcipherinfo.js b/test/parallel/test-crypto-getcipherinfo.js
521434index 98d2a52eceac4bc564fd2878f77b50c336a67a66..bcb2de6e354c26816000f2400d9c1d46de01888a 100644
522435--- a/test/parallel/test-crypto-getcipherinfo.js
@@ -783,8 +696,8 @@ index 930a2ba09088663298208f165f06a7710770938f..592b4140f14e659dfa38e438473c8d4a
783696+
784697 // Verify that legacy encoding works
785698 const legacyObjectCheck = {
786- subject: Object.assign(Object.create( null) , {
787- @@ -277,16 +287,8 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
699+ subject: Object.assign({ __proto__: null } , {
700+ @@ -277,15 +287,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
788701 'OCSP - URI': ['http://ocsp.nodejs.org/'],
789702 'CA Issuers - URI': ['http://ca.nodejs.org/ca.cert']
790703 }),
@@ -797,11 +710,10 @@ index 930a2ba09088663298208f165f06a7710770938f..592b4140f14e659dfa38e438473c8d4a
797710- 'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' +
798711- '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' +
799712- '5E2D2554AA65CE49695797095BF4DC6B',
800- bits: 2048,
801713+ modulusPattern: new RegExp(modulusOSSL, 'i'),
714+ bits: 2048,
802715 exponent: '0x10001',
803716 valid_from: 'Sep 3 21:40:37 2022 GMT',
804- valid_to: 'Jun 17 21:40:37 2296 GMT',
805717@@ -298,7 +300,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
806718 '51:62:18:39:E2:E2:77:F5:86:11:E8:C0:CA:54:43:7C:76:83:19:05:D0:03:' +
807719 '24:21:B8:EB:14:61:FB:24:16:EB:BD:51:1A:17:91:04:30:03:EB:68:5F:DC:' +
0 commit comments