You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
function bnpFromNumber(a, b, c) {
if ("number" == typeof b) {
// new BigInteger(int,int,RNG)
if (a < 2) this.fromInt(1);
else {
this.fromNumber(a, c);
if (!this.testBit(a - 1)) // force MSB set
this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
if (this.isEven()) this.dAddOffset(1, 0); // force odd
while (!this.isProbablePrime(b)) {
this.dAddOffset(2, 0);
if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
}
}
}
else {
// new BigInteger(int,RNG)
var x = new Array(),
t = a & 7;
x.length = (a >> 3) + 1;
b.nextBytes(x);
if (t > 0) x[0] &= ((1 << t) - 1);
else x[0] = 0;
this.fromString(x, 256);
}
}
Explanation
If the argument b is of type number, it will crash when running line 769 b.nextBytes(x) since number don't have method nextBytes/1
Steps to product the bug
var key = cryptico.generateRSAKey("test",2048);
key.generate(2048,3)
test case output
> key = lib.default.generateRSAKey("test",2048); key.generate(2048,3)
TypeError: Cannot read property 'nextBytes' of undefined
at BigInteger.bnpFromNumber [as fromNumber] (/home/beenotung/workspace/github.com/beenotung/typestub-cryptico/node_modules/cryptico/lib/cryptico.js:769:10)
at BigInteger.bnpFromNumber [as fromNumber] (/home/beenotung/workspace/github.com/beenotung/typestub-cryptico/node_modules/cryptico/lib/cryptico.js:754:18)
at new BigInteger (/home/beenotung/workspace/github.com/beenotung/typestub-cryptico/node_modules/cryptico/lib/cryptico.js:12:51)
at RSAKey.RSAGenerate [as generate] (/home/beenotung/workspace/github.com/beenotung/typestub-cryptico/node_modules/cryptico/lib/cryptico.js:2228:14)
at repl:1:52
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:440:10)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug location
file cryptico/lib/cryptico.js at line 749
Explanation
If the argument
b
is of typenumber
, it will crash when running line 769b.nextBytes(x)
since number don't have methodnextBytes/1
Steps to product the bug
test case output
The text was updated successfully, but these errors were encountered: