fix_crypto_tests_to_run_with_bssl.patch 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Jeremy Rose <[email protected]>
  3. Date: Tue, 9 Feb 2021 12:34:46 -0800
  4. Subject: fix crypto tests to run with bssl
  5. This fixes some crypto tests so that they pass when compiled with
  6. BoringSSL.
  7. This should be upstreamed in some form, though it may need to be tweaked
  8. before it's acceptable to upstream, as this patch comments out a couple
  9. of tests that upstream probably cares about.
  10. diff --git a/test/common/index.js b/test/common/index.js
  11. index d1eaf6e69f603b0a7037e44be6ef185283972090..e3f26d32dbad2e4ccb47dea028dbf1a855525cfb 100644
  12. --- a/test/common/index.js
  13. +++ b/test/common/index.js
  14. @@ -65,6 +65,8 @@ const opensslVersionNumber = (major = 0, minor = 0, patch = 0) => {
  15. return (major << 28) | (minor << 20) | (patch << 4);
  16. };
  17. +const openSSLIsBoringSSL = process.versions.openssl === '0.0.0';
  18. +
  19. let OPENSSL_VERSION_NUMBER;
  20. const hasOpenSSL = (major = 0, minor = 0, patch = 0) => {
  21. if (!hasCrypto) return false;
  22. @@ -1008,6 +1010,7 @@ const common = {
  23. mustNotMutateObjectDeep,
  24. mustSucceed,
  25. nodeProcessAborted,
  26. + openSSLIsBoringSSL,
  27. PIPE,
  28. parseTestFlags,
  29. platformTimeout,
  30. diff --git a/test/parallel/test-buffer-tostring-range.js b/test/parallel/test-buffer-tostring-range.js
  31. index d033cd204b3200cdd736b581abe027d6e46e4ff3..73fec107a36c3db4af6f492137d0ca174f2d0547 100644
  32. --- a/test/parallel/test-buffer-tostring-range.js
  33. +++ b/test/parallel/test-buffer-tostring-range.js
  34. @@ -102,7 +102,8 @@ assert.throws(() => {
  35. // Must not throw when start and end are within kMaxLength
  36. // Cannot test on 32bit machine as we are testing the case
  37. // when start and end are above the threshold
  38. -common.skipIf32Bits();
  39. +if (!common.openSSLIsBoringSSL) {
  40. const threshold = 0xFFFFFFFF;
  41. const largeBuffer = Buffer.alloc(threshold + 20);
  42. largeBuffer.toString('utf8', threshold, threshold + 20);
  43. +}
  44. diff --git a/test/parallel/test-crypto-async-sign-verify.js b/test/parallel/test-crypto-async-sign-verify.js
  45. index 4e3c32fdcd23fbe3e74bd5e624b739d224689f33..29149838ca76986928c7649a5f60a0f5e22a0705 100644
  46. --- a/test/parallel/test-crypto-async-sign-verify.js
  47. +++ b/test/parallel/test-crypto-async-sign-verify.js
  48. @@ -88,6 +88,7 @@ test('rsa_public.pem', 'rsa_private.pem', 'sha256', false,
  49. // ED25519
  50. test('ed25519_public.pem', 'ed25519_private.pem', undefined, true);
  51. // ED448
  52. +if (!common.openSSLIsBoringSSL) {
  53. test('ed448_public.pem', 'ed448_private.pem', undefined, true);
  54. // ECDSA w/ der signature encoding
  55. @@ -109,6 +110,7 @@ test('dsa_public.pem', 'dsa_private.pem', 'sha256',
  56. // DSA w/ ieee-p1363 signature encoding
  57. test('dsa_public.pem', 'dsa_private.pem', 'sha256', false,
  58. { dsaEncoding: 'ieee-p1363' });
  59. +}
  60. // Test Parallel Execution w/ KeyObject is threadsafe in openssl3
  61. {
  62. diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
  63. index 4a5f1f149fe6c739f7f1d2ee17df6e61a942d621..b3287f428ce6b3fde11d449c601a57ff5e3843f9 100644
  64. --- a/test/parallel/test-crypto-certificate.js
  65. +++ b/test/parallel/test-crypto-certificate.js
  66. @@ -40,8 +40,10 @@ function copyArrayBuffer(buf) {
  67. }
  68. function checkMethods(certificate) {
  69. -
  70. + /* spkacValid has a md5 based signature which is not allowed in boringssl
  71. + https://boringssl.googlesource.com/boringssl/+/33d7e32ce40c04e8f1b99c05964956fda187819f
  72. assert.strictEqual(certificate.verifySpkac(spkacValid), true);
  73. + */
  74. assert.strictEqual(certificate.verifySpkac(spkacFail), false);
  75. assert.strictEqual(
  76. @@ -56,10 +58,12 @@ function checkMethods(certificate) {
  77. );
  78. assert.strictEqual(certificate.exportChallenge(spkacFail), '');
  79. + /* spkacValid has a md5 based signature which is not allowed in boringssl
  80. const ab = copyArrayBuffer(spkacValid);
  81. assert.strictEqual(certificate.verifySpkac(ab), true);
  82. assert.strictEqual(certificate.verifySpkac(new Uint8Array(ab)), true);
  83. assert.strictEqual(certificate.verifySpkac(new DataView(ab)), true);
  84. + */
  85. }
  86. {
  87. diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js
  88. index 3e3632203af72c54f2795d8de0cf345862a043bb..a066bbb803d41d9d1f26a02e41115b71233988d6 100644
  89. --- a/test/parallel/test-crypto-cipheriv-decipheriv.js
  90. +++ b/test/parallel/test-crypto-cipheriv-decipheriv.js
  91. @@ -60,6 +60,10 @@ function testCipher2(key, iv) {
  92. function testCipher3(key, iv) {
  93. + if (!crypto.getCiphers().includes('id-aes128-wrap')) {
  94. + common.printSkipMessage(`unsupported id-aes128-wrap test`);
  95. + return;
  96. + }
  97. // Test encryption and decryption with explicit key and iv.
  98. // AES Key Wrap test vector comes from RFC3394
  99. const plaintext = Buffer.from('00112233445566778899AABBCCDDEEFF', 'hex');
  100. diff --git a/test/parallel/test-crypto-dh-curves.js b/test/parallel/test-crypto-dh-curves.js
  101. index 81a469c226c261564dee1e0b06b6571b18a41f1f..58b66045dba4201b7ebedd78b129420ffc316051 100644
  102. --- a/test/parallel/test-crypto-dh-curves.js
  103. +++ b/test/parallel/test-crypto-dh-curves.js
  104. @@ -16,7 +16,7 @@ const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
  105. crypto.createDiffieHellman(p, 'hex');
  106. // Confirm DH_check() results are exposed for optional examination.
  107. -const bad_dh = crypto.createDiffieHellman('02', 'hex');
  108. +const bad_dh = crypto.createDiffieHellman('abcd', 'hex', 0);
  109. assert.notStrictEqual(bad_dh.verifyError, 0);
  110. const availableCurves = new Set(crypto.getCurves());
  111. diff --git a/test/parallel/test-crypto-dh-errors.js b/test/parallel/test-crypto-dh-errors.js
  112. index 476ca64b4425b5b8b0fa2dc8352ee6f03d563813..2250a8f24a875d6af198426891870b450078ee5f 100644
  113. --- a/test/parallel/test-crypto-dh-errors.js
  114. +++ b/test/parallel/test-crypto-dh-errors.js
  115. @@ -32,9 +32,9 @@ for (const bits of [-1, 0, 1]) {
  116. });
  117. } else {
  118. assert.throws(() => crypto.createDiffieHellman(bits), {
  119. - code: 'ERR_OSSL_BN_BITS_TOO_SMALL',
  120. + code: /ERR_OSSL_BN_BITS_TOO_SMALL|ERR_OSSL_DH_MODULUS_TOO_LARGE/,
  121. name: 'Error',
  122. - message: /bits too small/,
  123. + message: /bits too small|BITS_TOO_SMALL|MODULUS_TOO_LARGE/,
  124. });
  125. }
  126. }
  127. diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
  128. index 9ebe14011eed223994e0901bc22dcc582b4b0739..e78f90eb76380916ce7098fb517c83a954edb053 100644
  129. --- a/test/parallel/test-crypto-dh.js
  130. +++ b/test/parallel/test-crypto-dh.js
  131. @@ -55,18 +55,17 @@ const crypto = require('crypto');
  132. let wrongBlockLength;
  133. if (common.hasOpenSSL3) {
  134. wrongBlockLength = {
  135. - message: 'error:1C80006B:Provider routines::wrong final block length',
  136. - code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
  137. - library: 'Provider routines',
  138. - reason: 'wrong final block length'
  139. + message: /error:1C80006B:Provider routines::wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
  140. + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
  141. + library: /digital envelope routines|Cipher functions/,
  142. + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
  143. };
  144. } else {
  145. wrongBlockLength = {
  146. - message: 'error:0606506D:digital envelope' +
  147. - ' routines:EVP_DecryptFinal_ex:wrong final block length',
  148. - code: 'ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH',
  149. - library: 'digital envelope routines',
  150. - reason: 'wrong final block length'
  151. + message: /error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
  152. + code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
  153. + library: /digital envelope routines|Cipher functions/,
  154. + reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
  155. };
  156. }
  157. @@ -93,17 +92,23 @@ const crypto = require('crypto');
  158. dh3.computeSecret('');
  159. }, { message: common.hasOpenSSL3 && !hasOpenSSL3WithNewErrorMessage ?
  160. 'Unspecified validation error' :
  161. - 'Supplied key is too small' });
  162. + 'Supplied key is invalid' });
  163. }
  164. }
  165. // Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
  166. {
  167. const g = 0;
  168. - crypto.createDiffieHellman('abcdef', g);
  169. + assert.throws(() => crypto.createDiffieHellman('abcdef', g), {
  170. + code: /ERR_CRYPTO_OPERATION_FAILED/,
  171. + name: 'Error'
  172. + });
  173. crypto.createDiffieHellman('abcdef', 'hex', g);
  174. }
  175. {
  176. - crypto.createDiffieHellman('abcdef', Buffer.from([2])); // OK
  177. + assert.throws(() => crypto.createDiffieHellman('abcdef', Buffer.from([2])), {
  178. + code: /ERR_CRYPTO_OPERATION_FAILED/,
  179. + name: 'Error'
  180. + });
  181. }
  182. diff --git a/test/parallel/test-crypto-getcipherinfo.js b/test/parallel/test-crypto-getcipherinfo.js
  183. index 64b79fc36ccf4d38f763fcd8c1930473c82cefd7..1c6717ebd46497384b9b13174b65894ca89e7f2d 100644
  184. --- a/test/parallel/test-crypto-getcipherinfo.js
  185. +++ b/test/parallel/test-crypto-getcipherinfo.js
  186. @@ -62,9 +62,13 @@ assert(getCipherInfo('aes-128-cbc', { ivLength: 16 }));
  187. assert(!getCipherInfo('aes-128-ccm', { ivLength: 1 }));
  188. assert(!getCipherInfo('aes-128-ccm', { ivLength: 14 }));
  189. +if (!common.openSSLIsBoringSSL) {
  190. for (let n = 7; n <= 13; n++)
  191. assert(getCipherInfo('aes-128-ccm', { ivLength: n }));
  192. +}
  193. assert(!getCipherInfo('aes-128-ocb', { ivLength: 16 }));
  194. +if (!common.openSSLIsBoringSSL) {
  195. for (let n = 1; n < 16; n++)
  196. assert(getCipherInfo('aes-128-ocb', { ivLength: n }));
  197. +}
  198. \ No newline at end of file
  199. diff --git a/test/parallel/test-crypto-hash-stream-pipe.js b/test/parallel/test-crypto-hash-stream-pipe.js
  200. index d22281abbd5c3cab3aaa3ac494301fa6b4a8a968..5f0c6a4aed2e868a1a1049212edf218791cd6868 100644
  201. --- a/test/parallel/test-crypto-hash-stream-pipe.js
  202. +++ b/test/parallel/test-crypto-hash-stream-pipe.js
  203. @@ -30,11 +30,11 @@ const crypto = require('crypto');
  204. const stream = require('stream');
  205. const s = new stream.PassThrough();
  206. -const h = crypto.createHash('sha3-512');
  207. -const expect = '36a38a2a35e698974d4e5791a3f05b05' +
  208. - '198235381e864f91a0e8cd6a26b677ec' +
  209. - 'dcde8e2b069bd7355fabd68abd6fc801' +
  210. - '19659f25e92f8efc961ee3a7c815c758';
  211. +const h = crypto.createHash('sha512');
  212. +const expect = 'fba055c6fd0c5b6645407749ed7a8b41' +
  213. + 'b8f629f2163c3ca3701d864adabda1f8' +
  214. + '93c37bf82b22fdd151ba8e357f611da4' +
  215. + '88a74b6a5525dd9b69554c6ce5138ad7';
  216. s.pipe(h).on('data', common.mustCall(function(c) {
  217. assert.strictEqual(c, expect);
  218. diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js
  219. index 83218c105a4596e0ae0381136f176bb8d759899e..afb3c8c592d2a8e2a053fd44f455af06c592a85e 100644
  220. --- a/test/parallel/test-crypto-hash.js
  221. +++ b/test/parallel/test-crypto-hash.js
  222. @@ -182,6 +182,7 @@ assert.throws(
  223. // Test XOF hash functions and the outputLength option.
  224. {
  225. + /*
  226. // Default outputLengths.
  227. assert.strictEqual(crypto.createHash('shake128').digest('hex'),
  228. '7f9c2ba4e88f827d616045507605853e');
  229. @@ -236,6 +237,7 @@ assert.throws(
  230. assert.strictEqual(superLongHash.length, 2 * 1024 * 1024);
  231. assert.ok(superLongHash.endsWith('193414035ddba77bf7bba97981e656ec'));
  232. assert.ok(superLongHash.startsWith('a2a28dbc49cfd6e5d6ceea3d03e77748'));
  233. + */
  234. // Non-XOF hash functions should accept valid outputLength options as well.
  235. assert.strictEqual(crypto.createHash('sha224', { outputLength: 28 })
  236. diff --git a/test/parallel/test-crypto-hkdf.js b/test/parallel/test-crypto-hkdf.js
  237. index ff3abdf291efcd076b36e755de4147b0aad0b345..d29854cf0c0ce89f84c912def672e7c4e11427a3 100644
  238. --- a/test/parallel/test-crypto-hkdf.js
  239. +++ b/test/parallel/test-crypto-hkdf.js
  240. @@ -124,8 +124,6 @@ const algorithms = [
  241. ['sha256', '', 'salt', '', 10],
  242. ['sha512', 'secret', 'salt', '', 15],
  243. ];
  244. -if (!common.hasOpenSSL3)
  245. - algorithms.push(['whirlpool', 'secret', '', 'info', 20]);
  246. algorithms.forEach(([ hash, secret, salt, info, length ]) => {
  247. {
  248. diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js
  249. index f1f14b472997e76bb4100edb1c6cf4fc24d1074d..5057e3f9bc5bb78aceffa5e79530f8ceed84e6f7 100644
  250. --- a/test/parallel/test-crypto-padding.js
  251. +++ b/test/parallel/test-crypto-padding.js
  252. @@ -87,10 +87,9 @@ assert.throws(function() {
  253. code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
  254. reason: 'wrong final block length',
  255. } : {
  256. - message: 'error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:' +
  257. - 'data not multiple of block length',
  258. - code: 'ERR_OSSL_EVP_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH',
  259. - reason: 'data not multiple of block length',
  260. + message: /error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:data not multiple of block length|error:1e00006a:Cipher functions:OPENSSL_internal:DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH/,
  261. + code: /ERR_OSSL(_EVP)?_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH/,
  262. + reason: /data not multiple of block length|DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH/,
  263. }
  264. );
  265. @@ -114,10 +113,9 @@ assert.throws(function() {
  266. reason: 'bad decrypt',
  267. code: 'ERR_OSSL_BAD_DECRYPT',
  268. } : {
  269. - message: 'error:06065064:digital envelope routines:EVP_DecryptFinal_ex:' +
  270. - 'bad decrypt',
  271. - reason: 'bad decrypt',
  272. - code: 'ERR_OSSL_EVP_BAD_DECRYPT',
  273. + message: /error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt|error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT/,
  274. + reason: /bad decrypt|BAD_DECRYPT/,
  275. + code: /ERR_OSSL(_EVP)?_BAD_DECRYPT/,
  276. });
  277. // No-pad encrypted string should return the same:
  278. diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js
  279. index 5f4fafdfffbf726b7cb39c472baa3df25c9794cf..d52376da2cddd90adcdf8a9b7dcd03e348d9f2b4 100644
  280. --- a/test/parallel/test-crypto-rsa-dsa.js
  281. +++ b/test/parallel/test-crypto-rsa-dsa.js
  282. @@ -28,12 +28,11 @@ const dsaPkcs8KeyPem = fixtures.readKey('dsa_private_pkcs8.pem');
  283. const ec = new TextEncoder();
  284. const openssl1DecryptError = {
  285. - message: 'error:06065064:digital envelope routines:EVP_DecryptFinal_ex:' +
  286. - 'bad decrypt',
  287. - code: 'ERR_OSSL_EVP_BAD_DECRYPT',
  288. - reason: 'bad decrypt',
  289. - function: 'EVP_DecryptFinal_ex',
  290. - library: 'digital envelope routines',
  291. + message: /error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt|error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT/,
  292. + code: /ERR_OSSL(_EVP)?_BAD_DECRYPT/,
  293. + reason: /bad decrypt|BAD_DECRYPT/,
  294. + function: /EVP_DecryptFinal_ex|OPENSSL_internal/,
  295. + library: /digital envelope routines|Cipher functions/,
  296. };
  297. const decryptError = common.hasOpenSSL3 ?
  298. @@ -222,7 +221,8 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
  299. }, bufferToEncrypt);
  300. - if (padding === constants.RSA_PKCS1_PADDING) {
  301. + // BoringSSL does not support RSA_PKCS1_PADDING.
  302. + if (false) {
  303. if (!process.config.variables.node_shared_openssl) {
  304. assert.throws(() => {
  305. crypto.privateDecrypt({
  306. @@ -466,10 +466,10 @@ assert.throws(() => {
  307. assert.strictEqual(verify2.verify(publicKey, signature, 'hex'), true);
  308. }
  309. -
  310. //
  311. // Test DSA signing and verification
  312. //
  313. +if (!common.openSSLIsBoringSSL) {
  314. {
  315. const input = 'I AM THE WALRUS';
  316. @@ -541,3 +541,4 @@ const input = 'I AM THE WALRUS';
  317. assert.strictEqual(verify.verify(dsaPubPem, signature, 'hex'), true);
  318. }
  319. +}
  320. diff --git a/test/parallel/test-crypto-scrypt.js b/test/parallel/test-crypto-scrypt.js
  321. index 338a19b0e88ad6f08d2f6b6a5d38b9980996ce11..a4ee215575d072450ba66c558ddca88bfb23d85f 100644
  322. --- a/test/parallel/test-crypto-scrypt.js
  323. +++ b/test/parallel/test-crypto-scrypt.js
  324. @@ -178,7 +178,7 @@ for (const options of bad) {
  325. for (const options of toobig) {
  326. const expected = {
  327. - message: /Invalid scrypt params:.*memory limit exceeded/,
  328. + message: /Invalid scrypt params/,
  329. code: 'ERR_CRYPTO_INVALID_SCRYPT_PARAMS',
  330. };
  331. assert.throws(() => crypto.scrypt('pass', 'salt', 1, options, () => {}),
  332. diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
  333. index 8a263ec3350f5540591ac02e70fa2f552b9ac477..dcc4c2ec816d28f1b27df1c358cfce66f1a3a03b 100644
  334. --- a/test/parallel/test-crypto-sign-verify.js
  335. +++ b/test/parallel/test-crypto-sign-verify.js
  336. @@ -29,7 +29,7 @@ const keySize = 2048;
  337. }
  338. // Test handling of exceptional conditions
  339. -{
  340. +if (!common.openSSLIsBoringSSL) {
  341. const library = {
  342. configurable: true,
  343. set() {
  344. @@ -341,15 +341,17 @@ assert.throws(
  345. padding: crypto.constants.RSA_PKCS1_OAEP_PADDING
  346. });
  347. }, common.hasOpenSSL3 ? {
  348. - code: 'ERR_OSSL_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE',
  349. - message: /illegal or unsupported padding mode/,
  350. + code: /^ERR_OSSL_(RSA|EVP)_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE$/,
  351. + message: /illegal or unsupported padding mode|ILLEGAL_OR_UNSUPPORTED_PADDING_MODE/,
  352. } : {
  353. - code: 'ERR_OSSL_RSA_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE',
  354. - message: /illegal or unsupported padding mode/,
  355. + code: /^ERR_OSSL_(RSA|EVP)_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE$/,
  356. + message: /illegal or unsupported padding mode|ILLEGAL_OR_UNSUPPORTED_PADDING_MODE/,
  357. + /*
  358. opensslErrorStack: [
  359. 'error:06089093:digital envelope routines:EVP_PKEY_CTX_ctrl:' +
  360. 'command not supported',
  361. ],
  362. + */
  363. });
  364. }
  365. @@ -419,10 +421,12 @@ assert.throws(
  366. public: fixtures.readKey('ed25519_public.pem', 'ascii'),
  367. algo: null,
  368. sigLen: 64 },
  369. + /*
  370. { private: fixtures.readKey('ed448_private.pem', 'ascii'),
  371. public: fixtures.readKey('ed448_public.pem', 'ascii'),
  372. algo: null,
  373. sigLen: 114 },
  374. + */
  375. { private: fixtures.readKey('rsa_private_2048.pem', 'ascii'),
  376. public: fixtures.readKey('rsa_public_2048.pem', 'ascii'),
  377. algo: 'sha1',
  378. @@ -493,7 +497,7 @@ assert.throws(
  379. {
  380. const data = Buffer.from('Hello world');
  381. - const keys = [['ec-key.pem', 64], ['dsa_private_1025.pem', 40]];
  382. + const keys = [['ec-key.pem', 64]/*, ['dsa_private_1025.pem', 40]*/];
  383. for (const [file, length] of keys) {
  384. const privKey = fixtures.readKey(file);
  385. diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js
  386. index 008ab129f0e019c659eecf5a76b7eb412c947fe3..6688f5d916f50e1e4fcfff1619c8634a3233f820 100644
  387. --- a/test/parallel/test-crypto-stream.js
  388. +++ b/test/parallel/test-crypto-stream.js
  389. @@ -76,10 +76,10 @@ cipher.pipe(decipher)
  390. library: 'Provider routines',
  391. reason: 'bad decrypt',
  392. } : {
  393. - message: /bad decrypt/,
  394. - function: 'EVP_DecryptFinal_ex',
  395. - library: 'digital envelope routines',
  396. - reason: 'bad decrypt',
  397. + message: /bad decrypt|BAD_DECRYPT/,
  398. + function: /EVP_DecryptFinal_ex|OPENSSL_internal/,
  399. + library: /digital envelope routines|Cipher functions/,
  400. + reason: /bad decrypt|BAD_DECRYPT/,
  401. }));
  402. cipher.end('Papaya!'); // Should not cause an unhandled exception.
  403. diff --git a/test/parallel/test-crypto-x509.js b/test/parallel/test-crypto-x509.js
  404. index bd906c25b9ee194ff34fe5fb8ecb68d7a672138c..5b631a32d07bd916ff7cd847e52b26f694bd00c6 100644
  405. --- a/test/parallel/test-crypto-x509.js
  406. +++ b/test/parallel/test-crypto-x509.js
  407. @@ -96,8 +96,10 @@ const der = Buffer.from(
  408. assert.strictEqual(x509.infoAccess, infoAccessCheck);
  409. assert.strictEqual(x509.validFrom, 'Sep 3 21:40:37 2022 GMT');
  410. assert.strictEqual(x509.validTo, 'Jun 17 21:40:37 2296 GMT');
  411. + if (!common.openSSLIsBoringSSL) {
  412. assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
  413. assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
  414. + }
  415. assert.strictEqual(
  416. x509.fingerprint,
  417. '8B:89:16:C4:99:87:D2:13:1A:64:94:36:38:A5:32:01:F0:95:3B:53');
  418. @@ -325,6 +327,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
  419. legacyObjectCheck.serialNumberPattern);
  420. }
  421. +if (!common.openSSLIsBoringSSL) {
  422. {
  423. // This X.509 Certificate can be parsed by OpenSSL because it contains a
  424. // structurally sound TBSCertificate structure. However, the SPKI field of the
  425. @@ -363,6 +366,7 @@ UcXd/5qu2GhokrKU2cPttU+XAN2Om6a0
  426. assert.strictEqual(cert.checkIssued(cert), false);
  427. }
  428. +}
  429. {
  430. // Test date parsing of `validFromDate` and `validToDate` fields, according to RFC 5280.
  431. @@ -400,8 +404,10 @@ UidvpWWipVLZgK+oDks+bKTobcoXGW9oXobiIYqslXPy
  432. -----END CERTIFICATE-----`.trim();
  433. const c1 = new X509Certificate(certPemUTCTime);
  434. + if (!common.openSSLIsBoringSSL) {
  435. assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
  436. assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
  437. + }
  438. // The GeneralizedTime format is used for dates in 2050 or later.
  439. const certPemGeneralizedTime = `-----BEGIN CERTIFICATE-----
  440. @@ -435,6 +441,8 @@ CWwQO8JZjJqFtqtuzy2n+gLCvqePgG/gmSqHOPm2ZbLW
  441. -----END CERTIFICATE-----`.trim();
  442. const c2 = new X509Certificate(certPemGeneralizedTime);
  443. + if (!common.openSSLIsBoringSSL) {
  444. assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
  445. assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
  446. + }
  447. }
  448. diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js
  449. index 4271121881379b6c6892e89e520345f77e4181df..7a17285deee18ffbccf1d01d9d1b7b87e561bffa 100644
  450. --- a/test/parallel/test-crypto.js
  451. +++ b/test/parallel/test-crypto.js
  452. @@ -61,7 +61,7 @@ assert.throws(() => {
  453. // Throws general Error, so there is no opensslErrorStack property.
  454. return err instanceof Error &&
  455. err.name === 'Error' &&
  456. - /^Error: mac verify failure$/.test(err) &&
  457. + (/^Error: (mac verify failure|INCORRECT_PASSWORD)$/.test(err)) &&
  458. !('opensslErrorStack' in err);
  459. });
  460. @@ -71,7 +71,7 @@ assert.throws(() => {
  461. // Throws general Error, so there is no opensslErrorStack property.
  462. return err instanceof Error &&
  463. err.name === 'Error' &&
  464. - /^Error: mac verify failure$/.test(err) &&
  465. + (/^Error: (mac verify failure|INCORRECT_PASSWORD)$/.test(err)) &&
  466. !('opensslErrorStack' in err);
  467. });
  468. @@ -81,7 +81,7 @@ assert.throws(() => {
  469. // Throws general Error, so there is no opensslErrorStack property.
  470. return err instanceof Error &&
  471. err.name === 'Error' &&
  472. - /^Error: not enough data$/.test(err) &&
  473. + /^Error: (not enough data|BAD_PKCS12_DATA)$/.test(err) &&
  474. !('opensslErrorStack' in err);
  475. });
  476. @@ -144,8 +144,6 @@ assert(crypto.getHashes().includes('sha1'));
  477. assert(crypto.getHashes().includes('sha256'));
  478. assert(!crypto.getHashes().includes('SHA1'));
  479. assert(!crypto.getHashes().includes('SHA256'));
  480. -assert(crypto.getHashes().includes('RSA-SHA1'));
  481. -assert(!crypto.getHashes().includes('rsa-sha1'));
  482. validateList(crypto.getHashes());
  483. // Make sure all of the hashes are supported by OpenSSL
  484. for (const algo of crypto.getHashes())
  485. @@ -196,6 +194,7 @@ assert.throws(
  486. }
  487. );
  488. +if (!common.openSSLIsBoringSSL) {
  489. assert.throws(() => {
  490. const priv = [
  491. '-----BEGIN RSA PRIVATE KEY-----',
  492. @@ -216,10 +215,10 @@ assert.throws(() => {
  493. library: 'rsa routines',
  494. } : {
  495. name: 'Error',
  496. - message: /routines:RSA_sign:digest too big for rsa key$/,
  497. - library: 'rsa routines',
  498. - function: 'RSA_sign',
  499. - reason: 'digest too big for rsa key',
  500. + message: /routines:RSA_sign:digest too big for rsa key$|routines:OPENSSL_internal:DIGEST_TOO_BIG_FOR_RSA_KEY$/,
  501. + library: /rsa routines|RSA routines/,
  502. + function: /RSA_sign|OPENSSL_internal/,
  503. + reason: /digest too big for rsa key|DIGEST_TOO_BIG_FOR_RSA_KEY/,
  504. code: 'ERR_OSSL_RSA_DIGEST_TOO_BIG_FOR_RSA_KEY'
  505. });
  506. return true;
  507. @@ -252,7 +251,7 @@ if (!common.hasOpenSSL3) {
  508. return true;
  509. });
  510. }
  511. -
  512. +}
  513. // Make sure memory isn't released before being returned
  514. console.log(crypto.randomBytes(16));
  515. diff --git a/test/parallel/test-https-agent-additional-options.js b/test/parallel/test-https-agent-additional-options.js
  516. index 543ee176fb6af38874fee9f14be76f3fdda11060..fef9f1bc2f9fc6c220cf47847e86e03882b51b1d 100644
  517. --- a/test/parallel/test-https-agent-additional-options.js
  518. +++ b/test/parallel/test-https-agent-additional-options.js
  519. @@ -13,7 +13,7 @@ const options = {
  520. cert: fixtures.readKey('agent1-cert.pem'),
  521. ca: fixtures.readKey('ca1-cert.pem'),
  522. minVersion: 'TLSv1.1',
  523. - ciphers: 'ALL@SECLEVEL=0'
  524. + // ciphers: 'ALL@SECLEVEL=0'
  525. };
  526. const server = https.Server(options, (req, res) => {
  527. @@ -28,7 +28,7 @@ function getBaseOptions(port) {
  528. ca: options.ca,
  529. rejectUnauthorized: true,
  530. servername: 'agent1',
  531. - ciphers: 'ALL@SECLEVEL=0'
  532. + // ciphers: 'ALL@SECLEVEL=0'
  533. };
  534. }
  535. diff --git a/test/parallel/test-https-agent-session-eviction.js b/test/parallel/test-https-agent-session-eviction.js
  536. index e0986e53c1103b63cf15002a7fa4ce8bc4844d90..33c8a2aa72c56dd4a98558aab2102f03fae2b3cf 100644
  537. --- a/test/parallel/test-https-agent-session-eviction.js
  538. +++ b/test/parallel/test-https-agent-session-eviction.js
  539. @@ -14,7 +14,7 @@ const options = {
  540. key: readKey('agent1-key.pem'),
  541. cert: readKey('agent1-cert.pem'),
  542. secureOptions: SSL_OP_NO_TICKET,
  543. - ciphers: 'RSA@SECLEVEL=0'
  544. + // ciphers: 'RSA@SECLEVEL=0'
  545. };
  546. // Create TLS1.2 server
  547. diff --git a/test/parallel/test-tls-getprotocol.js b/test/parallel/test-tls-getprotocol.js
  548. index a9c8775e2f112f2b5e1f4e80f22264f219bf6a9d..4550d28125379e6043962826b8e97b692d63804b 100644
  549. --- a/test/parallel/test-tls-getprotocol.js
  550. +++ b/test/parallel/test-tls-getprotocol.js
  551. @@ -27,7 +27,7 @@ const clientConfigs = [
  552. const serverConfig = {
  553. secureProtocol: 'TLS_method',
  554. - ciphers: 'RSA@SECLEVEL=0',
  555. + // ciphers: 'RSA@SECLEVEL=0',
  556. key: fixtures.readKey('agent2-key.pem'),
  557. cert: fixtures.readKey('agent2-cert.pem')
  558. };
  559. diff --git a/test/parallel/test-tls-write-error.js b/test/parallel/test-tls-write-error.js
  560. index b06f2fa2c53ea72f9a66f0d002dd9281d0259a0f..864fffeebfad75d95416fd47efdea7f222c507a2 100644
  561. --- a/test/parallel/test-tls-write-error.js
  562. +++ b/test/parallel/test-tls-write-error.js
  563. @@ -17,7 +17,7 @@ const server_cert = fixtures.readKey('agent1-cert.pem');
  564. const opts = {
  565. key: server_key,
  566. cert: server_cert,
  567. - ciphers: 'ALL@SECLEVEL=0'
  568. + // ciphers: 'ALL@SECLEVEL=0'
  569. };
  570. const server = https.createServer(opts, (req, res) => {
  571. diff --git a/test/parallel/test-webcrypto-derivebits.js b/test/parallel/test-webcrypto-derivebits.js
  572. index eb09bc24f0cb8244b05987e3a7c1d203360d3a38..8c251ff2371fb59bf679160574e1c5dc1b4b2665 100644
  573. --- a/test/parallel/test-webcrypto-derivebits.js
  574. +++ b/test/parallel/test-webcrypto-derivebits.js
  575. @@ -101,8 +101,9 @@ const { subtle } = globalThis.crypto;
  576. tests.then(common.mustCall());
  577. }
  578. +
  579. // Test X25519 and X448 bit derivation
  580. -{
  581. +if (!common.openSSLIsBoringSSL) {
  582. async function test(name) {
  583. const [alice, bob] = await Promise.all([
  584. subtle.generateKey({ name }, true, ['deriveBits']),
  585. diff --git a/test/parallel/test-webcrypto-derivekey.js b/test/parallel/test-webcrypto-derivekey.js
  586. index 558d37d90d5796b30101d1b512c9df3e7661d0db..f42bf8f4be0b439dd7e7c8d0f6f8a41e01588870 100644
  587. --- a/test/parallel/test-webcrypto-derivekey.js
  588. +++ b/test/parallel/test-webcrypto-derivekey.js
  589. @@ -176,7 +176,7 @@ const { KeyObject } = require('crypto');
  590. }
  591. // Test X25519 and X448 key derivation
  592. -{
  593. +if (!common.openSSLIsBoringSSL) {
  594. async function test(name) {
  595. const [alice, bob] = await Promise.all([
  596. subtle.generateKey({ name }, true, ['deriveKey']),
  597. diff --git a/test/parallel/test-webcrypto-sign-verify.js b/test/parallel/test-webcrypto-sign-verify.js
  598. index de736102bdcb71a5560c95f7041537f25026aed4..12d7fa39446c196bdf1479dbe74c9ee8ab02f949 100644
  599. --- a/test/parallel/test-webcrypto-sign-verify.js
  600. +++ b/test/parallel/test-webcrypto-sign-verify.js
  601. @@ -105,8 +105,9 @@ const { subtle } = globalThis.crypto;
  602. test('hello world').then(common.mustCall());
  603. }
  604. +
  605. // Test Sign/Verify Ed25519
  606. -{
  607. +if (!common.openSSLIsBoringSSL) {
  608. async function test(data) {
  609. const ec = new TextEncoder();
  610. const { publicKey, privateKey } = await subtle.generateKey({
  611. @@ -126,7 +127,7 @@ const { subtle } = globalThis.crypto;
  612. }
  613. // Test Sign/Verify Ed448
  614. -{
  615. +if (!common.openSSLIsBoringSSL) {
  616. async function test(data) {
  617. const ec = new TextEncoder();
  618. const { publicKey, privateKey } = await subtle.generateKey({
  619. diff --git a/test/parallel/test-webcrypto-wrap-unwrap.js b/test/parallel/test-webcrypto-wrap-unwrap.js
  620. index d1ca571af4be713082d32093bfb8a65f2aef9800..57b8df2ce18df58ff54b2d828af67e3c2e082fe0 100644
  621. --- a/test/parallel/test-webcrypto-wrap-unwrap.js
  622. +++ b/test/parallel/test-webcrypto-wrap-unwrap.js
  623. @@ -18,14 +18,15 @@ const kWrappingData = {
  624. wrap: { label: new Uint8Array(8) },
  625. pair: true
  626. },
  627. - 'AES-CTR': {
  628. + 'AES-CBC': {
  629. generate: { length: 128 },
  630. - wrap: { counter: new Uint8Array(16), length: 64 },
  631. + wrap: { iv: new Uint8Array(16) },
  632. pair: false
  633. },
  634. - 'AES-CBC': {
  635. + /*
  636. + 'AES-CTR': {
  637. generate: { length: 128 },
  638. - wrap: { iv: new Uint8Array(16) },
  639. + wrap: { counter: new Uint8Array(16), length: 64 },
  640. pair: false
  641. },
  642. 'AES-GCM': {
  643. @@ -42,6 +43,7 @@ const kWrappingData = {
  644. wrap: { },
  645. pair: false
  646. }
  647. + */
  648. };
  649. function generateWrappingKeys() {
  650. diff --git a/test/parallel/test-x509-escaping.js b/test/parallel/test-x509-escaping.js
  651. index e6ae4d886908cbc0e56787009db855dad8b12ba7..a17147daa0576ec49e560c05448f1ed0ae8d5640 100644
  652. --- a/test/parallel/test-x509-escaping.js
  653. +++ b/test/parallel/test-x509-escaping.js
  654. @@ -447,7 +447,7 @@ const { hasOpenSSL3 } = common;
  655. assert.strictEqual(certX509.checkHost(servername, { subject: 'default' }),
  656. undefined);
  657. assert.strictEqual(certX509.checkHost(servername, { subject: 'always' }),
  658. - servername);
  659. + undefined);
  660. assert.strictEqual(certX509.checkHost(servername, { subject: 'never' }),
  661. undefined);
  662. @@ -482,11 +482,11 @@ const { hasOpenSSL3 } = common;
  663. assert.strictEqual(certX509.subjectAltName, 'IP Address:1.2.3.4');
  664. // The newer X509Certificate API allows customizing this behavior:
  665. - assert.strictEqual(certX509.checkHost(servername), servername);
  666. + assert.strictEqual(certX509.checkHost(servername), undefined);
  667. assert.strictEqual(certX509.checkHost(servername, { subject: 'default' }),
  668. - servername);
  669. + undefined);
  670. assert.strictEqual(certX509.checkHost(servername, { subject: 'always' }),
  671. - servername);
  672. + undefined);
  673. assert.strictEqual(certX509.checkHost(servername, { subject: 'never' }),
  674. undefined);