From c1f97056f42d20158d469d023652f3b338411007 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 13 Aug 2021 14:57:56 +0530 Subject: fix(ext/crypto): take a copy of keyData bytes (#11666) --- ext/crypto/00_crypto.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ext') diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 449946295..4319f09ba 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -463,6 +463,18 @@ context: "Argument 5", }); + // 2. + if (ArrayBufferIsView(keyData)) { + keyData = new Uint8Array( + keyData.buffer, + keyData.byteOffset, + keyData.byteLength, + ); + } else { + keyData = new Uint8Array(keyData); + } + keyData = TypedArrayPrototypeSlice(keyData); + const normalizedAlgorithm = normalizeAlgorithm(algorithm, "importKey"); if ( -- cgit v1.2.3