summaryrefslogtreecommitdiff
path: root/tests/unit_node/crypto/crypto_key_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node/crypto/crypto_key_test.ts')
-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);
+});