diff --git a/lib/crypto/MGF1.js b/lib/crypto/MGF1.js index d68a691..0a7aeed 100644 --- a/lib/crypto/MGF1.js +++ b/lib/crypto/MGF1.js @@ -1,13 +1,13 @@ 'use strict'; const crypto = require('crypto'); -const BN = require('bn.js'); + +const BigNumber = require('../BigNumber.js'); const MFG_LEN = 32; const divceil = (a, b) => ~~(((a + b) - 1) / b); // eslint-disable-line no-bitwise -const rjust = (string, width, padding) => { - padding = padding || ' '; +const rjust = (string, width, padding = ' ') => { padding = padding.substr(0, 1); if (string.length < width) return padding.repeat(width - string.length) + string; @@ -26,7 +26,7 @@ const i2osp = (x, len) => { if (x >= 256 ** len) throw new Error('Integer too large'); - return Buffer.from(rjust((Buffer.from((new BN(x)).toArray('be', 4)).toString()).replace(/\x00/gi, ''), len, '\x00')); // eslint-disable-line no-control-regex + return Buffer.from(rjust(new BigNumber(x).toBEBuffer(4).toString().replace(/\x00/gi, ''), len, '\x00')); // eslint-disable-line no-control-regex }; module.exports = {