summaryrefslogtreecommitdiff
path: root/ext/crypto/00_crypto.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-08-13 23:04:24 +0530
committerGitHub <noreply@github.com>2021-08-13 19:34:24 +0200
commitc6e3f93ebb716c2df310e4ca4fd1f4c8290feed1 (patch)
tree971836d82286306d3a449f8a9040842e9ccb2185 /ext/crypto/00_crypto.js
parent74d523e924e9cfcc2a36c0e02d5077e1c4154374 (diff)
fix(ext/crypto): handle idlValue not being present (#11685)
Diffstat (limited to 'ext/crypto/00_crypto.js')
-rw-r--r--ext/crypto/00_crypto.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js
index 4319f09ba..b341aabe7 100644
--- a/ext/crypto/00_crypto.js
+++ b/ext/crypto/00_crypto.js
@@ -88,6 +88,7 @@
};
// See https://www.w3.org/TR/WebCryptoAPI/#dfn-normalize-an-algorithm
+ // 18.4.4
function normalizeAlgorithm(algorithm, op) {
if (typeof algorithm == "string") {
return normalizeAlgorithm({ name: algorithm }, op);
@@ -125,18 +126,22 @@
return { name: algName };
}
+ // 6.
const normalizedAlgorithm = webidl.converters[desiredType](algorithm, {
prefix: "Failed to normalize algorithm",
context: "passed algorithm",
});
+ // 7.
normalizedAlgorithm.name = algName;
+ // 9.
const dict = simpleAlgorithmDictionaries[desiredType];
+ // 10.
for (const member in dict) {
const idlType = dict[member];
const idlValue = normalizedAlgorithm[member];
-
- if (idlType === "BufferSource") {
+ // 3.
+ if (idlType === "BufferSource" && idlValue) {
normalizedAlgorithm[member] = new Uint8Array(
TypedArrayPrototypeSlice(
(ArrayBufferIsView(idlValue) ? idlValue.buffer : idlValue),