mirror of
https://github.com/denoland/deno.git
synced 2025-01-09 15:48:16 -05:00
fix(ext/crypto): ECDH and X25519 non byte length and 0 length fixes (#16146)
This commit is contained in:
parent
8d20784f7a
commit
fd08b13dff
1 changed files with 6 additions and 9 deletions
|
@ -27,6 +27,7 @@
|
||||||
Int8ArrayPrototype,
|
Int8ArrayPrototype,
|
||||||
JSONParse,
|
JSONParse,
|
||||||
JSONStringify,
|
JSONStringify,
|
||||||
|
MathCeil,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
StringPrototypeToLowerCase,
|
StringPrototypeToLowerCase,
|
||||||
|
@ -4396,14 +4397,11 @@
|
||||||
// 8.
|
// 8.
|
||||||
if (length === null) {
|
if (length === null) {
|
||||||
return buf.buffer;
|
return buf.buffer;
|
||||||
}
|
} else if (buf.buffer.byteLength * 8 < length) {
|
||||||
if (
|
|
||||||
length === 0 || buf.buffer.byteLength * 8 < length ||
|
|
||||||
length % 8 !== 0
|
|
||||||
) {
|
|
||||||
throw new DOMException("Invalid length", "OperationError");
|
throw new DOMException("Invalid length", "OperationError");
|
||||||
|
} else {
|
||||||
|
return buf.buffer.slice(0, MathCeil(length / 8));
|
||||||
}
|
}
|
||||||
return buf.buffer.slice(0, length / 8);
|
|
||||||
} else {
|
} else {
|
||||||
throw new DOMException("Not implemented", "NotSupportedError");
|
throw new DOMException("Not implemented", "NotSupportedError");
|
||||||
}
|
}
|
||||||
|
@ -4469,12 +4467,11 @@
|
||||||
if (length === null) {
|
if (length === null) {
|
||||||
return secret.buffer;
|
return secret.buffer;
|
||||||
} else if (
|
} else if (
|
||||||
length === 0 || secret.buffer.byteLength * 8 < length ||
|
secret.buffer.byteLength * 8 < length
|
||||||
secret.length * 8 < length
|
|
||||||
) {
|
) {
|
||||||
throw new DOMException("Invalid length", "OperationError");
|
throw new DOMException("Invalid length", "OperationError");
|
||||||
} else {
|
} else {
|
||||||
return secret.subarray(0, length / 8).buffer;
|
return secret.buffer.slice(0, MathCeil(length / 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue