build 2.5.1

This commit is contained in:
Coffee Converter 2020-03-24 16:00:29 -05:00
parent 5701881360
commit 4de924a186
5 changed files with 23 additions and 14 deletions

View File

@ -360,11 +360,14 @@ var bigintCryptoUtils = (function (exports) {
throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`);
const byteLength = Math.ceil(bitLength / 8);
let rndBytes = randBytesSync(byteLength, false);
const rndBytes = randBytesSync(byteLength, false);
const bitLengthMod8 = bitLength % 8;
if (bitLengthMod8) {
// Fill with 0's the extra bits
rndBytes[0] = rndBytes[0] & (2 ** (bitLength % 8) - 1);
rndBytes[0] = rndBytes[0] & (2 ** bitLengthMod8 - 1);
}
if (forceLength) {
let mask = (bitLength % 8) ? 2 ** ((bitLength % 8) - 1) : 128;
const mask = bitLengthMod8 ? 2 ** (bitLengthMod8 - 1) : 128;
rndBytes[0] = rndBytes[0] | mask;
}
return rndBytes;

File diff suppressed because one or more lines are too long

View File

@ -357,11 +357,14 @@ function randBits(bitLength, forceLength = false) {
throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`);
const byteLength = Math.ceil(bitLength / 8);
let rndBytes = randBytesSync(byteLength, false);
const rndBytes = randBytesSync(byteLength, false);
const bitLengthMod8 = bitLength % 8;
if (bitLengthMod8) {
// Fill with 0's the extra bits
rndBytes[0] = rndBytes[0] & (2 ** (bitLength % 8) - 1);
rndBytes[0] = rndBytes[0] & (2 ** bitLengthMod8 - 1);
}
if (forceLength) {
let mask = (bitLength % 8) ? 2 ** ((bitLength % 8) - 1) : 128;
const mask = bitLengthMod8 ? 2 ** (bitLengthMod8 - 1) : 128;
rndBytes[0] = rndBytes[0] | mask;
}
return rndBytes;

File diff suppressed because one or more lines are too long

View File

@ -376,11 +376,14 @@ function randBits(bitLength, forceLength = false) {
throw new RangeError(`bitLength MUST be > 0 and it is ${bitLength}`);
const byteLength = Math.ceil(bitLength / 8);
let rndBytes = randBytesSync(byteLength, false);
const rndBytes = randBytesSync(byteLength, false);
const bitLengthMod8 = bitLength % 8;
if (bitLengthMod8) {
// Fill with 0's the extra bits
rndBytes[0] = rndBytes[0] & (2 ** (bitLength % 8) - 1);
rndBytes[0] = rndBytes[0] & (2 ** bitLengthMod8 - 1);
}
if (forceLength) {
let mask = (bitLength % 8) ? 2 ** ((bitLength % 8) - 1) : 128;
const mask = bitLengthMod8 ? 2 ** (bitLengthMod8 - 1) : 128;
rndBytes[0] = rndBytes[0] | mask;
}
return rndBytes;