summaryrefslogtreecommitdiff
path: root/ext/crypto/00_crypto.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/crypto/00_crypto.js')
-rw-r--r--ext/crypto/00_crypto.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js
index 19e669acd..d88aef219 100644
--- a/ext/crypto/00_crypto.js
+++ b/ext/crypto/00_crypto.js
@@ -2319,7 +2319,12 @@ function importKeyEd25519(
// 9.
if (jwk.d !== undefined) {
// https://www.rfc-editor.org/rfc/rfc8037#section-2
- const privateKeyData = ops.op_crypto_base64url_decode(jwk.d);
+ let privateKeyData;
+ try {
+ privateKeyData = ops.op_crypto_base64url_decode(jwk.d);
+ } catch (_) {
+ throw new DOMException("invalid private key data", "DataError");
+ }
const handle = {};
WeakMapPrototypeSet(KEY_STORE, handle, privateKeyData);
@@ -2337,7 +2342,12 @@ function importKeyEd25519(
);
} else {
// https://www.rfc-editor.org/rfc/rfc8037#section-2
- const publicKeyData = ops.op_crypto_base64url_decode(jwk.x);
+ let publicKeyData;
+ try {
+ publicKeyData = ops.op_crypto_base64url_decode(jwk.x);
+ } catch (_) {
+ throw new DOMException("invalid public key data", "DataError");
+ }
const handle = {};
WeakMapPrototypeSet(KEY_STORE, handle, publicKeyData);