diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-11-19 01:39:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-19 01:39:40 +0100 |
commit | df1d36324ffd4f687c406e412f9255bf7a9d8a61 (patch) | |
tree | c9ed10db694d05bc0ce0dab6ddadf2d3058fb370 /tests/unit_node/crypto/crypto_key_test.ts | |
parent | 594a99817cbe44553b2c288578fbba8e1e9c1907 (diff) |
fix(node/crypto): support promisify on generateKeyPair (#26913)
Calling `promisify(generateKeyPair)` didn't work as expected. It
requires a custom promisify implementation.
This was easy to fix thanks to the excellent debugging investigation in
https://github.com/denoland/deno/issues/26910
Fixes https://github.com/denoland/deno/issues/26910
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'tests/unit_node/crypto/crypto_key_test.ts')
-rw-r--r-- | tests/unit_node/crypto/crypto_key_test.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit_node/crypto/crypto_key_test.ts b/tests/unit_node/crypto/crypto_key_test.ts index 3c7ad4423..5d206acc7 100644 --- a/tests/unit_node/crypto/crypto_key_test.ts +++ b/tests/unit_node/crypto/crypto_key_test.ts @@ -677,3 +677,26 @@ Deno.test("generateKeyPair large pem", function () { }, }); }); + +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-----")); +}); |