How to use the jsbn function from node-forge

Find comprehensive JavaScript node-forge.jsbn code examples handpicked from public code repositorys.

4
5
6
7
8
9
10
11
12
13
{
    session.aesIV = generateIV();

    session.publicKey = forge.pki.rsa.setPublicKey(
        new forge.jsbn.BigInteger(keyModulus, 16),
        new forge.jsbn.BigInteger(keyExponent, 16)
    );
}

function cipher(session, data, { key, compress, disableIV } = {})
fork icon95
star icon14
watch icon1

+ 19 other calls in file

122
123
124
125
126
127
128
129
130
131
  var bytes = forge.util.decode64(
    (str + '==='.slice((str.length + 3) % 4))
      .replace(/\-/g, '+')
      .replace(/_/g, '/'));

  return new forge.jsbn.BigInteger(forge.util.bytesToHex(bytes), 16)
}

let rpk
if (jwkPubKey._key) {
fork icon30
star icon130
watch icon16

0
1
2
3
4
5
6
7
8
9
#!/usr/bin/env node

var fs = require("fs");
var forge = require('node-forge');
var debug = require('debug')('converter');
var BigInteger = forge.jsbn.BigInteger;


/*
* getField from asn.1
fork icon5
star icon4
watch icon5

217
218
219
220
221
222
223
224
225
226
227
228
};


function _bytesToBigInteger(bytes) {
    var buffer = forge.util.createBuffer(bytes);
    var hex = buffer.toHex();
    return new forge.jsbn.BigInteger(hex, 16);
}


keyczar_util._base64ToBn = function(s) {
    var decoded = keyczar_util.decodeBase64Url(s);
fork icon0
star icon0
watch icon0

30
31
32
33
34
35
36
37
38
39
40


function _rsa_encrypt(text, pubKey, modulus) {
  text = text.split('').reverse().join(''); // eslint-disable-line no-param-reassign
  const n = new forge.jsbn.BigInteger(modulus, 16);
  const e = new forge.jsbn.BigInteger(pubKey, 16);
  const b = new forge.jsbn.BigInteger(forge.util.bytesToHex(text), 16);
  const enc = b.modPow(e, n).toString(16).padStart(256, '0');
  return enc;
}

fork icon0
star icon0
watch icon0

+ 2 other calls in file

7
8
9
10
11
12
13
14
15
16
17
18
19
const mathematical = require('../../../src/mathematical');
const forge = require('node-forge');


module.exports = CommonTestData;


const BigInteger = forge.jsbn.BigInteger;


const _p = new BigInteger('18388150860058403802920178412529336901045699792821062607508310191219067488929344819011655681691429908099537898007051346381' +
	'3195401979139859203647659085471016920713495528166363693675446161613934552485057155482567306193272596584186000158109106046352639037376165933064' +
	'2991107222194099935594482476175383869987955168985814863206910604761983038024345803144240965961120000788895995343754304465559705608854777189131' +
fork icon0
star icon0
watch icon0

131
132
133
134
135
136
137
138
139
140
     it('load a leaf X.509 certificate into a new X509Certificate object and retrieve its contents', function () {
         // Load leaf certificate.
const leafCertificate = _certificateService.newX509Certificate(_leafCertificatePem);

// Check that expected fields can be retrieved from leaf certificate.
assert.isTrue(new BigInteger(leafCertificate.serialNumber, 16).equals(new forge.jsbn.BigInteger(_leafSerialNumber)));
const notBefore = leafCertificate.notBefore.getTime().toString().substring(0, EPOCH_TIME_LENGTH);
expect(notBefore).to.equal(_leafNotBefore);
const notAfter = leafCertificate.notAfter.getTime().toString().substring(0, EPOCH_TIME_LENGTH);
expect(notAfter).to.equal(_leafNotAfter);
fork icon0
star icon0
watch icon0

232
233
234
235
236
237
238
239
240
241
//console.log("vv: "+vv);
var authDataBytes = forge.util.hexToBytes(vv);
var clearSecureBytes = forge.util.createBuffer();

var rsa = forge.pki.rsa;
var modulos = new forge.jsbn.BigInteger(options.publicKeyModulus, 16);
var exp = new forge.jsbn.BigInteger(options.publicKeyExponent, 16);
var publicKey = rsa.setPublicKey(modulos, exp);

//var pexp = new forge.jsbn.BigInteger('', 16);
fork icon0
star icon0
watch icon0

+ 9 other calls in file