fix: modulus zero byte handling

This commit is contained in:
Vladislav Hristov 2019-10-30 10:53:03 +02:00
parent 1320f6f21d
commit 1c1f112ff5

View File

@ -126,8 +126,9 @@ module.exports = (xml, keys) => ({
const type = lastChild(keyNodes[i].parentNode).textContent; const type = lastChild(keyNodes[i].parentNode).textContent;
const modulus = xpath.select(".//*[local-name(.)='Modulus']", keyNodes[i])[0].textContent; const modulus = xpath.select(".//*[local-name(.)='Modulus']", keyNodes[i])[0].textContent;
const exponent = xpath.select(".//*[local-name(.)='Exponent']", keyNodes[i])[0].textContent; const exponent = xpath.select(".//*[local-name(.)='Exponent']", keyNodes[i])[0].textContent;
const modulusBuffer = Buffer.from(modulus, 'base64');
const mod = new BN(Buffer.from(modulus, 'base64'), 2).toBuffer(); const mod = new BN(Buffer.from(modulus, 'base64'), 2).toBuffer('be', modulusBuffer.length);
const exp = new BN(Buffer.from(exponent, 'base64')).toNumber(); const exp = new BN(Buffer.from(exponent, 'base64')).toNumber();
bankKeys[`bank${type}`] = { mod, exp }; bankKeys[`bank${type}`] = { mod, exp };