Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SRP6JavascriptClientSession.prototype.fromHex = function(s) {
"use strict";
return new BigInteger(""+s, 16); // jdk1.7 rhino requires string concat
};
/* jshint ignore:end */
runFromFiletimeToUnix: function(input, args) {
let units = args[0];
input = new BigInteger(input).subtract(new BigInteger("116444736000000000"));
if (units === "Seconds (s)"){
input = input.divide(new BigInteger("10000000"));
} else if (units === "Milliseconds (ms)") {
input = input.divide(new BigInteger("10000"));
} else if (units === "Microseconds (μs)") {
input = input.divide(new BigInteger("10"));
} else if (units === "Nanoseconds (ns)") {
input = input.multiply(new BigInteger("100"));
} else {
throw "Unrecognised unit";
}
return input.toString();
},
runToFiletimeFromUnix: function(input, args) {
let units = args[0];
input = new BigInteger(input);
if (units === "Seconds (s)"){
input = input.multiply(new BigInteger("10000000"));
} else if (units === "Milliseconds (ms)") {
input = input.multiply(new BigInteger("10000"));
} else if (units === "Microseconds (μs)") {
input = input.multiply(new BigInteger("10"));
} else if (units === "Nanoseconds (ns)") {
input = input.divide(new BigInteger("100"));
} else {
throw "Unrecognised unit";
}
return input.add(new BigInteger("116444736000000000")).toString();
},
'this source, the node jsbn lib is required.'));
}
var d = new bigInt(key.part.d.data);
var buf;
if (!key.part.dmodp) {
var p = new bigInt(key.part.p.data);
var dmodp = d.mod(p.subtract(1));
buf = bigintToMpBuf(dmodp);
key.part.dmodp = {name: 'dmodp', data: buf};
key.parts.push(key.part.dmodp);
}
if (!key.part.dmodq) {
var q = new bigInt(key.part.q.data);
var dmodq = d.mod(q.subtract(1));
buf = bigintToMpBuf(dmodq);
key.part.dmodq = {name: 'dmodq', data: buf};
key.parts.push(key.part.dmodq);
}
}
Address6.prototype.possibleSubnets = function (optionalSubnetSize) {
if (optionalSubnetSize === undefined) {
optionalSubnetSize = 128;
}
var availableBits = constants6.BITS - this.subnetMask;
var subnetBits = Math.abs(optionalSubnetSize - constants6.BITS);
var subnetPowers = availableBits - subnetBits;
if (subnetPowers < 0) {
return '0';
}
return addCommas(new BigInteger('2', 10).pow(subnetPowers).toString(10));
};
function _bi(value, base) {
if (base !== undefined) {
if (base === 256) {
return _bi(utils.string2bytes(value));
}
return new BigInteger(value, base);
} else if (typeof value === 'string') {
return new BigInteger(value, 10);
} else if ((value instanceof Array) || (value instanceof Uint8Array)
|| Buffer.isBuffer(value)) {
return new BigInteger(value);
} else if (typeof value === 'number') {
return new BigInteger(value.toString(), 10);
} else {
throw "Can't convert " + value + " to BigInteger";
}
}
Address6.prototype.getBits = function (start, end) {
return new BigInteger(this.getBitsBase2(start, end), 2);
};
function bytesToAtom(bytes) {
var byt, parts = [];
for ( var i = bytes.length - 1; i >= 0; --i ) {
byt = bytes[i] & 0xff;
parts.push(byt < 16 ? ("0" + byt.toString(16)) : byt.toString(16));
}
return new noun.Atom.Atom(new BigInteger(parts.join(''), 16));
}
const BigInteger = require("jsbn").BigInteger;
const ipv4 = new ipAddress.Address4(ipRange);
if (!ipv4.isValid()) {
throw new Error(`Invalid IP address range: ${ipRange}`);
}
const newSubnetMask = ipv4.subnetMask + newBits;
if (newSubnetMask > 32) {
throw new Error(`Requested ${newBits} new bits, but ` +
`only ${32 - ipv4.subnetMask} are available.`);
}
const addressBI = ipv4.bigInteger();
const newAddressBase = Math.pow(2, 32 - newSubnetMask);
const netNumBI = new BigInteger(netNum.toString());
const newAddressBI = addressBI.add(new BigInteger(newAddressBase.toString()).multiply(netNumBI));
const newAddress = ipAddress.Address4.fromBigInteger(newAddressBI).address;
return `${newAddress}/${newSubnetMask}`;
}
const ipv4 = new ipAddress.Address4(ipRange);
if (!ipv4.isValid()) {
throw new Error(`Invalid IP address range: ${ipRange}`);
}
const newSubnetMask = ipv4.subnetMask + newBits;
if (newSubnetMask > 32) {
throw new Error(`Requested ${newBits} new bits, but ` +
`only ${32 - ipv4.subnetMask} are available.`);
}
const addressBI = ipv4.bigInteger();
const newAddressBase = Math.pow(2, 32 - newSubnetMask);
const netNumBI = new BigInteger(netNum.toString());
const newAddressBI = addressBI.add(new BigInteger(newAddressBase.toString()).multiply(netNumBI));
const newAddress = ipAddress.Address4.fromBigInteger(newAddressBI).address;
return `${newAddress}/${newSubnetMask}`;
}