Index: lib/rsa.js |
=================================================================== |
--- a/lib/rsa.js |
+++ b/lib/rsa.js |
@@ -99,20 +99,23 @@ |
} |
function readNode(curTempl) |
{ |
let type = next(); |
let len = readLength(); |
if ("type" in curTempl && curTempl.type != type) |
throw "Unexpected type"; |
- if ("content" in curTempl && curTempl.content != data.substr(pos, len)) |
+ if ("content" in curTempl && |
+ curTempl.content != data.substring(pos, pos + len)) |
+ { |
throw "Unexpected content"; |
+ } |
if ("out" in curTempl) |
- out[curTempl.out] = new BigInteger(data.substr(pos, len), 256); |
+ out[curTempl.out] = new BigInteger(data.substring(pos, pos + len), 256); |
if ("children" in curTempl) |
{ |
let i; |
let end; |
for (i = 0, end = pos + len; pos < end; i++) |
{ |
if (i >= curTempl.children.length) |
throw "Too many children"; |
@@ -188,17 +191,17 @@ |
if (next() != 1) |
throw "Wrong padding in signature digest"; |
while (next() == 255) {} |
if (digest.charCodeAt(pos - 1) != 0) |
throw "Wrong padding in signature digest"; |
// Rest is an ASN.1 structure, get the SHA1 hash from it and compare to |
// the real one |
- let {sha1} = readASN1(digest.substr(pos), signatureTemplate); |
+ let {sha1} = readASN1(digest.substring(pos), signatureTemplate); |
let expected = new BigInteger(rusha.digest(data), 16); |
return (sha1.compareTo(expected) == 0); |
} |
catch (e) |
{ |
console.warn("Invalid encrypted signature: " + e); |
return false; |
} |