summaryrefslogtreecommitdiff
path: root/ext/crypto
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-08-17 14:59:32 +0530
committerGitHub <noreply@github.com>2021-08-17 11:29:32 +0200
commitaf97535b7cc64bf4586da77fc0afa146230e758c (patch)
treed19a22a169934112411e0a7bace222f21fb75175 /ext/crypto
parentc67f6c13cd1de22e32f81723bc9224b8e2103a7a (diff)
fix(ext/crypto): exportKey() for HMAC (#11737)
Fixes typings and innerKey processing (WPT doesn't test exportKey for HMAC so this wasn't caught earlier).
Diffstat (limited to 'ext/crypto')
-rw-r--r--ext/crypto/00_crypto.js5
-rw-r--r--ext/crypto/lib.deno_crypto.d.ts1
2 files changed, 4 insertions, 2 deletions
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js
index 5fdbe6ebc..115271dab 100644
--- a/ext/crypto/00_crypto.js
+++ b/ext/crypto/00_crypto.js
@@ -577,16 +577,17 @@
const handle = key[_handle];
// 2.
- const bits = WeakMapPrototypeGet(KEY_STORE, handle);
+ const innerKey = WeakMapPrototypeGet(KEY_STORE, handle);
switch (key[_algorithm].name) {
case "HMAC": {
- if (bits == null) {
+ if (innerKey == null) {
throw new DOMException("Key is not available", "OperationError");
}
switch (format) {
// 3.
case "raw": {
+ const bits = innerKey.data;
for (let _i = 7 & (8 - bits.length % 8); _i > 0; _i--) {
bits.push(0);
}
diff --git a/ext/crypto/lib.deno_crypto.d.ts b/ext/crypto/lib.deno_crypto.d.ts
index b89b62f2e..09273e78a 100644
--- a/ext/crypto/lib.deno_crypto.d.ts
+++ b/ext/crypto/lib.deno_crypto.d.ts
@@ -107,6 +107,7 @@ interface SubtleCrypto {
extractable: boolean,
keyUsages: KeyUsage[],
): Promise<CryptoKey>;
+ exportKey(format: "raw", key: CryptoKey): Promise<ArrayBuffer>;
sign(
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams,
key: CryptoKey,