From 1c1f112ff57530a5bfca310bd981ee69949cd526 Mon Sep 17 00:00:00 2001 From: Vladislav Hristov Date: Wed, 30 Oct 2019 10:53:03 +0200 Subject: [PATCH] fix: modulus zero byte handling --- lib/orders/H004/response.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/orders/H004/response.js b/lib/orders/H004/response.js index 66239df..eddaa3b 100644 --- a/lib/orders/H004/response.js +++ b/lib/orders/H004/response.js @@ -126,8 +126,9 @@ module.exports = (xml, keys) => ({ const type = lastChild(keyNodes[i].parentNode).textContent; const modulus = xpath.select(".//*[local-name(.)='Modulus']", 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(); bankKeys[`bank${type}`] = { mod, exp };