summaryrefslogtreecommitdiff
path: root/tests/unit_node/crypto/crypto_key_test.ts
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /tests/unit_node/crypto/crypto_key_test.ts
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'tests/unit_node/crypto/crypto_key_test.ts')
-rw-r--r--tests/unit_node/crypto/crypto_key_test.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/unit_node/crypto/crypto_key_test.ts b/tests/unit_node/crypto/crypto_key_test.ts
index 7995ce5d3..5d206acc7 100644
--- a/tests/unit_node/crypto/crypto_key_test.ts
+++ b/tests/unit_node/crypto/crypto_key_test.ts
@@ -656,3 +656,47 @@ z6TExWlQMjt66nV7R8cRAkzmABrG+NW3e8Zpac7Lkuv+zu0S+K7c
assertEquals(publicKey.type, "public");
assertEquals(publicKey.asymmetricKeyType, "rsa");
});
+
+// https://github.com/denoland/deno/issues/26188
+Deno.test("generateKeyPair large pem", function () {
+ const passphrase = "mypassphrase";
+ const cipher = "aes-256-cbc";
+ const modulusLength = 4096;
+
+ generateKeyPairSync("rsa", {
+ modulusLength,
+ publicKeyEncoding: {
+ type: "spki",
+ format: "pem",
+ },
+ privateKeyEncoding: {
+ type: "pkcs8",
+ format: "pem",
+ cipher,
+ passphrase,
+ },
+ });
+});
+
+Deno.test("generateKeyPair promisify", async () => {
+ const passphrase = "mypassphrase";
+ const cipher = "aes-256-cbc";
+ const modulusLength = 4096;
+
+ const { privateKey, publicKey } = await promisify(generateKeyPair)("rsa", {
+ modulusLength,
+ publicKeyEncoding: {
+ type: "spki",
+ format: "pem",
+ },
+ privateKeyEncoding: {
+ type: "pkcs8",
+ format: "pem",
+ cipher,
+ passphrase,
+ },
+ });
+
+ assert(publicKey.startsWith("-----BEGIN PUBLIC KEY-----"));
+ assert(privateKey.startsWith("-----BEGIN PRIVATE KEY-----"));
+});