summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-03-22 19:28:28 +0530
committerGitHub <noreply@github.com>2024-03-22 19:28:28 +0530
commit43be97923f671f37493549c8463a8824c8b63f6b (patch)
tree9341e659381d2614b4bdde4a832be45c1995adc6 /ext/node/polyfills/internal/crypto
parent22eec2b3cfcb0341e1b28329dbf82a40e66a672a (diff)
fix(ext/node): handle KeyObject in `prepareAsymmetricKey` (#23026)
Fixes https://github.com/denoland/deno/issues/20938
Diffstat (limited to 'ext/node/polyfills/internal/crypto')
-rw-r--r--ext/node/polyfills/internal/crypto/keys.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/node/polyfills/internal/crypto/keys.ts b/ext/node/polyfills/internal/crypto/keys.ts
index 74379015b..4ab8cac4f 100644
--- a/ext/node/polyfills/internal/crypto/keys.ts
+++ b/ext/node/polyfills/internal/crypto/keys.ts
@@ -215,6 +215,12 @@ export interface JsonWebKeyInput {
export function prepareAsymmetricKey(key) {
if (isStringOrBuffer(key)) {
return { format: "pem", data: getArrayBufferOrView(key, "key") };
+ } else if (isKeyObject(key)) {
+ return {
+ // Assumes that assymetric keys are stored as PEM.
+ format: "pem",
+ data: getKeyMaterial(key),
+ };
} else if (typeof key == "object") {
const { key: data, encoding, format, type } = key;
if (!isStringOrBuffer(data)) {