diff options
author | Levente Kurusa <lkurusa@kernelstuff.org> | 2023-06-05 14:52:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 14:52:02 +0200 |
commit | 11dd5a0ae73b4d3612de6422893a25232f930b84 (patch) | |
tree | abc7dd09d91ed2b7e60d53ea03b25534c645f0d6 /ext/crypto/00_crypto.js | |
parent | d2047f1337ccb5e27598308bf5fefa913eeaa34f (diff) |
fix(ext/crypto): fix JWK import of Ed25519 (#19279)
Fixes: #18049
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/crypto/00_crypto.js')
-rw-r--r-- | ext/crypto/00_crypto.js | 14 |
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); |