summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-04-29 19:16:38 +0530
committerGitHub <noreply@github.com>2024-04-29 19:16:38 +0530
commitb02ffec37c73be8a73b95b33b32efa693e84e01b (patch)
tree6bdcda1ee6e6e7d1b63d05320fe2236dfa86999b /tests
parent7d937045910968fbb2c050e803d79bc1c1e5984b (diff)
fix(ext/node): exporting rsa public keys (#23596)
Initial support for exporting rsa public KeyObject. Current assumption is that RSA keys are stored in pkcs1 der format in key storage. Ref https://github.com/denoland/deno/issues/23471 Ref https://github.com/denoland/deno/issues/18928 Ref https://github.com/denoland/deno/issues/21124
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_node/crypto/crypto_key_test.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/unit_node/crypto/crypto_key_test.ts b/tests/unit_node/crypto/crypto_key_test.ts
index c7c741f3e..013601572 100644
--- a/tests/unit_node/crypto/crypto_key_test.ts
+++ b/tests/unit_node/crypto/crypto_key_test.ts
@@ -15,7 +15,7 @@ import {
} from "node:crypto";
import { promisify } from "node:util";
import { Buffer } from "node:buffer";
-import { assertEquals, assertThrows } from "@std/assert/mod.ts";
+import { assert, assertEquals, assertThrows } from "@std/assert/mod.ts";
const RUN_SLOW_TESTS = Deno.env.get("SLOW_TESTS") === "1";
@@ -402,3 +402,16 @@ SogaIHQjE81ZkmNtU5gM5Q==
`jEwckJ/d5GkF/8TTm+wllq2JNghG/m2JYJIW7vS8Vms53zCTTNSSegTSoIVoxWymwTPw2dTtZi41Lg0O271/WvEmQhiWD2dnjz6D/0F4eyn+QUhcmGCadDFyfp7+8x1XOppSw2YB8vL5WCL0QDdp3TAa/rWI0Hn4OftHMa6HPvatkGs+8XlQOGCCfd3TLg+t1UROgpgmetjoAM67mlwxXMGGu/Tr/EbXnnINKeB0iuSmD1FCxlrgFuYWDKxd79n2jZ74FrS/zto+bqWSI5uUa4Ar7yvXtek1Cu1OFM6vgdN9Y6Po2UD9+IT04EhU03LUDY5paYOO8yohz7p7kqHvpA==`,
);
});
+
+Deno.test("generate rsa export public key", async function () {
+ const { publicKey } = await generateKeyPairAsync("rsa", {
+ modulusLength: 2048,
+ });
+
+ const spkiPem = publicKey.export({ format: "pem", type: "spki" });
+ assert(typeof spkiPem === "string");
+ assert(spkiPem.startsWith("-----BEGIN PUBLIC KEY-----"));
+
+ const der = publicKey.export({ format: "der", type: "spki" });
+ assert(der instanceof Uint8Array);
+});