From 932542bea00c0b3ca4c182a1306fc255bba65059 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 27 Oct 2020 14:35:47 +0100 Subject: [PATCH] some more cleanup --- src/platform/web/dom/Crypto.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform/web/dom/Crypto.js b/src/platform/web/dom/Crypto.js index 18c0ed66..f80c1a40 100644 --- a/src/platform/web/dom/Crypto.js +++ b/src/platform/web/dom/Crypto.js @@ -215,7 +215,6 @@ class AESLegacyCrypto { * @return {BufferSource} [description] */ async decryptCTR({key, jwkKey, iv, data, counterLength = 64}) { - const aesjs = this._aesjs; if (counterLength !== 64) { throw new Error(`Unsupported counter length: ${counterLength}`); } @@ -229,11 +228,12 @@ class AESLegacyCrypto { if (jwkKey.kty !== "oct") { throw new Error(`Invalid key type, "oct" expected: ${jwkKey.kty}`); } - // need //var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - const base64Key = jwkKey.k.replace(/-/g, "+").replace(/_/g, "/"); + // convert base64-url to normal base64 + const base64UrlKey = jwkKey.k; + const base64Key = base64UrlKey.replace(/-/g, "+").replace(/_/g, "/"); key = base64.decode(base64Key); } - + const aesjs = this._aesjs; var aesCtr = new aesjs.ModeOfOperation.ctr(new Uint8Array(key), new aesjs.Counter(new Uint8Array(iv))); return aesCtr.decrypt(new Uint8Array(data)); }