summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/webcrypto_test.ts5
-rw-r--r--ext/crypto/00_crypto.js5
-rw-r--r--ext/crypto/lib.deno_crypto.d.ts1
3 files changed, 8 insertions, 3 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts
index 23a4e0c57..608e4660a 100644
--- a/cli/tests/unit/webcrypto_test.ts
+++ b/cli/tests/unit/webcrypto_test.ts
@@ -160,7 +160,7 @@ unitTest(async function testSignRSASSAKey() {
assert(signature);
});
-unitTest(async function subtleCryptoHmacImport() {
+unitTest(async function subtleCryptoHmacImportExport() {
// deno-fmt-ignore
const rawKey = new Uint8Array([
1, 2, 3, 4, 5, 6, 7, 8,
@@ -189,4 +189,7 @@ unitTest(async function subtleCryptoHmacImport() {
new Uint8Array(actual),
expected,
);
+
+ const exportedKey = await crypto.subtle.exportKey("raw", key);
+ assertEquals(new Uint8Array(exportedKey), rawKey);
});
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,