diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-04-29 19:16:38 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 19:16:38 +0530 |
commit | b02ffec37c73be8a73b95b33b32efa693e84e01b (patch) | |
tree | 6bdcda1ee6e6e7d1b63d05320fe2236dfa86999b /ext/node/polyfills/internal/crypto/keygen.ts | |
parent | 7d937045910968fbb2c050e803d79bc1c1e5984b (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 'ext/node/polyfills/internal/crypto/keygen.ts')
-rw-r--r-- | ext/node/polyfills/internal/crypto/keygen.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts index f3263aecf..dd5d5ad7e 100644 --- a/ext/node/polyfills/internal/crypto/keygen.ts +++ b/ext/node/polyfills/internal/crypto/keygen.ts @@ -7,6 +7,8 @@ import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts"; import { kAesKeyLengths } from "ext:deno_node/internal/crypto/util.ts"; import { + PrivateKeyObject, + PublicKeyObject, SecretKeyObject, setOwnedKey, } from "ext:deno_node/internal/crypto/keys.ts"; @@ -564,8 +566,8 @@ export function generateKeyPair( ) => void, ) { createJob(kAsync, type, options).then(([privateKey, publicKey]) => { - privateKey = new KeyObject("private", setOwnedKey(privateKey)); - publicKey = new KeyObject("public", setOwnedKey(publicKey)); + privateKey = new PrivateKeyObject(setOwnedKey(privateKey), { type }); + publicKey = new PublicKeyObject(setOwnedKey(publicKey), { type }); if (typeof options === "object" && options !== null) { const { publicKeyEncoding, privateKeyEncoding } = options as any; @@ -766,8 +768,8 @@ export function generateKeyPairSync( | KeyPairSyncResult<string | Buffer, string | Buffer> { let [privateKey, publicKey] = createJob(kSync, type, options); - privateKey = new KeyObject("private", setOwnedKey(privateKey)); - publicKey = new KeyObject("public", setOwnedKey(publicKey)); + privateKey = new PrivateKeyObject(setOwnedKey(privateKey), { type }); + publicKey = new PublicKeyObject(setOwnedKey(publicKey), { type }); if (typeof options === "object" && options !== null) { const { publicKeyEncoding, privateKeyEncoding } = options as any; |