diff options
author | Luca Casonato <hello@lcas.dev> | 2021-12-13 13:22:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 13:22:03 +0100 |
commit | 5afb2cca65f10b8d0baaff4989a102d24d629087 (patch) | |
tree | b390f1e3dccdff3bc9b58fd79473ba967ee62783 /ext/crypto/00_crypto.js | |
parent | cd03de3c7b8a99aeee3953e69392c26d3667c41d (diff) |
refactor(ext/crypto): clean up exportKey rust code (#13052)
Diffstat (limited to 'ext/crypto/00_crypto.js')
-rw-r--r-- | ext/crypto/00_crypto.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 4e2a90f3b..818061387 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -852,6 +852,7 @@ * @param {CryptoKey} key * @returns {Promise<any>} */ + // deno-lint-ignore require-await async exportKey(format, key) { webidl.assertBranded(this, SubtleCrypto); const prefix = "Failed to execute 'exportKey' on 'SubtleCrypto'"; @@ -878,7 +879,7 @@ case "RSASSA-PKCS1-v1_5": case "RSA-PSS": case "RSA-OAEP": { - return await exportKeyRSA(format, key, innerKey); + return exportKeyRSA(format, key, innerKey); } case "AES-CTR": case "AES-CBC": @@ -2532,7 +2533,7 @@ } } - async function exportKeyRSA(format, key, innerKey) { + function exportKeyRSA(format, key, innerKey) { switch (format) { case "pkcs8": { // 1. @@ -2544,12 +2545,10 @@ } // 2. - const data = await core.opAsync("op_crypto_export_key", { - key: innerKey, - format: "pkcs8", + const data = core.opSync("op_crypto_export_key", { algorithm: key[_algorithm].name, - hash: key[_algorithm].hash.name, - }); + format: "pkcs8", + }, innerKey); // 3. return data.buffer; @@ -2564,12 +2563,10 @@ } // 2. - const data = await core.opAsync("op_crypto_export_key", { - key: innerKey, - format: "spki", + const data = core.opSync("op_crypto_export_key", { algorithm: key[_algorithm].name, - hash: key[_algorithm].hash.name, - }); + format: "spki", + }, innerKey); // 3. return data.buffer; |