Skip to content

Commit 9001f6b

Browse files
committed
crypto: fix generateKeyPair with encoding 'jwk'
nodejs/node#39319
1 parent 9987df5 commit 9001f6b

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

patches/node/fix_crypto_tests_to_run_with_bssl.patch

+10-19
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ index af2146982c7a3bf7bd7527f44e4b17a3b605026e..f6b91f675cfea367c608892dee078b56
489489
// Non-XOF hash functions should accept valid outputLength options as well.
490490
assert.strictEqual(crypto.createHash('sha224', { outputLength: 28 })
491491
diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js
492-
index 3159b0da3f2901aab17e0b360eda84decaed9eb3..995b7f6b45bd0aa83eef143b15dede5658ac1bc0 100644
492+
index aa03a0379a291a4632b68d428d4e1875d60166a3..b89071d41abfe731551b0445f2a92fd797165c98 100644
493493
--- a/test/parallel/test-crypto-key-objects.js
494494
+++ b/test/parallel/test-crypto-key-objects.js
495-
@@ -310,11 +310,11 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
495+
@@ -307,11 +307,11 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
496496
}, common.hasOpenSSL3 ? {
497-
message: 'Failed to read private key',
497+
message: 'error:1E08010C:DECODER routines::unsupported',
498498
} : {
499499
- message: 'error:0909006C:PEM routines:get_name:no start line',
500500
- code: 'ERR_OSSL_PEM_NO_START_LINE',
@@ -554,15 +554,6 @@ index 3159b0da3f2901aab17e0b360eda84decaed9eb3..995b7f6b45bd0aa83eef143b15dede56
554554
{
555555
// Reading an encrypted key without a passphrase should fail.
556556
assert.throws(() => createPrivateKey(privateDsa), common.hasOpenSSL3 ? {
557-
@@ -550,7 +552,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
558-
}), {
559-
message: common.hasOpenSSL3 ?
560-
'error:07880109:common libcrypto routines::interrupted or cancelled' :
561-
- /bad decrypt/
562-
+ /bad decrypt|BAD_DECRYPT/
563-
});
564-
565-
const publicKey = createPublicKey(publicDsa);
566557
@@ -573,7 +575,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
567558
() => privateKey.export({ format: 'jwk' }),
568559
{ code: 'ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE' });
@@ -643,22 +634,22 @@ index 4612fc4a1ac40a27ccc2c70ac11e32f0fdcaa2c3..a4d604cf0318cfb0771e3573245b1ed9
643634
}
644635

645636
{
646-
@@ -566,6 +574,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
637+
@@ -562,6 +562,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
647638
});
648639
}));
649640

650-
+ /*
641+
+/*
651642
// Test async elliptic curve key generation, e.g. for ECDSA, with an encrypted
652643
// private key with paramEncoding explicit.
653644
generateKeyPair('ec', {
654-
@@ -603,6 +612,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
655-
passphrase: 'top secret'
656-
});
657-
}));
658-
+ */
645+
@@ -688,6 +689,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
646+
});
659647
}
660648

649+
+*/
661650
// Test invalid parameter encoding.
651+
{
652+
assert.throws(() => generateKeyPairSync('ec', {
662653
@@ -951,6 +961,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
663654
}
664655
}

0 commit comments

Comments
 (0)