How to use the publicKeyFromPem function from node-forge

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

4
5
6
7
8
9
10
11
12
13
var utils   = require('./utils');
var pki     = require('node-forge').pki;

function encryptKeyInfoWithScheme(symmetricKey, options, scheme, callback) {
  try {
    var rsa_pub = pki.publicKeyFromPem(options.rsa_pub);
    var encrypted = rsa_pub.encrypt(symmetricKey.toString('binary'), scheme);
    var base64EncodedEncryptedKey = new Buffer(encrypted, 'binary').toString('base64');

    var params = {
fork icon54
star icon0
watch icon2

334
335
336
337
338
339
340
341
342
343
let modulusLength;
if (publicKeyObj.algorithm) {
  modulusLength = publicKeyObj.algorithm.modulusLength;
} else {
  // fall back to node-forge
  const pubKeyData = pki.publicKeyFromPem(publicKeyPem.toString());
  modulusLength = pubKeyData.n.bitLength();
}

if (keyType === "rsa" && modulusLength < 1024) {
fork icon10
star icon78
watch icon9

+ 70 other calls in file