How to use the openpgp.config function in openpgp

To help you get started, we’ve selected a few openpgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github autocrypt / autocrypt-js / test / util.js View on Github external
setup: function (fromAddr, cb) {
    var crypt = autocrypt({storage: memdb({valueEncoding: 'json'})})
    openpgp.initWorker({ path: 'openpgp.worker.js' }) // set the relative web worker path
    openpgp.config.aead_protect = true // activate fast AES-GCM mode (not yet OpenPGP standard)

    openpgp.generateKey({
      userIds: [{ name: 'Jon Smith', email: fromAddr }],
      numBits: 1096,
      passphrase: 'super long and hard to guess'
    }
    ).then((key) => cb(crypt, decode(key.publicKeyArmored), done)
  ).catch((err) => { throw err })

    function done (cb) {
      crypt.storage.close(cb)
    }
  },
  decode: decode
github ProtonMail / WebClient / src / libraries / pmcrypto.js View on Github external
/*
 * Be VERY careful about changing this file. It is used in both the browser JS package and in the node.js encryption server
 * Just because your changes work in the browser does not mean they work in the encryption server!
 */

if (typeof module !== 'undefined' && module.exports) {
    // node.js
    /* eslint { "no-global-assign": "off", "import/no-extraneous-dependencies": "off", "import/no-unresolved": "off", "global-require" : "off" } */
    btoa = require('btoa');
    atob = require('atob');
    Promise = require('es6-promise').Promise;
    openpgp = require('openpgp');
} else {
    // Browser
    openpgp.config.integrity_protect = true;

    /*
     * The safari tab seems to crash sometimes when using a webworker. This is a bug that was filed to Apple.
     * But until Apple fixes this bug we can turn off the webworker to prevent this from happening.
     * As soon as Apple fixes their bug we should use the webworker again, as it can causes the browser to hang
     * when the user has a lot of addresses/public keys.
     */
    const browsers = ['Safari', 'Mobile Safari'];
    if(!_.contains(browsers, $.ua.browser.name)) {
        openpgp.initWorker({path: 'openpgp.worker.min.js'});
    }
}

openpgp.config.integrity_protect = true;
openpgp.config.use_native = true;
github redhat-developer-tooling / developer-platform-install / browser / services / openpgp.js View on Github external
const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp

openpgp.config.aead_protect = true; // activate fast AES-GCM mode (not yet OpenPGP standard)

/**
 * Gets ASCII armored clearsign message and returns object
 * {
 *  text - text from the message
 *  valid - verification status
 *  error - error occured during verification
 * }
 */
function loadSignedText(keyText, armoredText) {
  return Promise.resolve().then(()=>{
    let options = {
      message: openpgp.cleartext.readArmored(armoredText), // parse armored message
      publicKeys: openpgp.key.readArmored(keyText).keys   // for verification
    };
    return openpgp.verify(options).then((verified)=>{
github isomorphic-git / isomorphic-git / src / models / PGP.js View on Github external
import * as openpgp from 'openpgp'

openpgp.config.aead_protect = false
openpgp.config.prefer_hash_algorithm = 2 // SHA1
var hkp = new openpgp.HKP('https://pgp.mit.edu')
var hkp2 = new openpgp.HKP('http://keys.gnupg.net')
var keyring = new openpgp.Keyring()

// Print a key
function printKey () {
  const keyid = printKeyid(this.primaryKey.getKeyId())
  const userid = printUser(this.getPrimaryUser().user)
  return keyid + ' ' + userid
}
// openpgp.key.toString = printKey

function printKeyid (keyid) {
  return keyid.toHex()
}
github breach / breach_core / lib / auto_updater.js View on Github external
function(cb_) {
        common.log.out('[auto_updater] Verifying: ' + tmp + '.tar.gz...');

        try {
          /* Get keys from keyring                                          */
          /* The keyring is stored in openpgp.store/openpgp-public-keys, we */
          /* explicitly specify the path here.                             */
          pgp.config.node_store = 
            path.resolve(__dirname, '..', 'openpgp.store');
          var keyring = new pgp.Keyring(),
          keys = keyring.getAllKeys();

          if(keys.length <= 0) {
            return cb_(common.err('Unexpected keyring size',
                                  'auto_updater:invalid_keyring'));
          }
        }
        catch(err) {
          return cb_(err);
        }

        /* Make sure that all the keys in the keyring are valid. At a later */
        /* point we may want to allow invalid keys so long as the update is */
        /* not signed with these.                                           */
github isomorphic-git / isomorphic-git / src / models / PGP.js View on Github external
import * as openpgp from 'openpgp'

openpgp.config.aead_protect = false
openpgp.config.prefer_hash_algorithm = 2 // SHA1
var hkp = new openpgp.HKP('https://pgp.mit.edu')
var hkp2 = new openpgp.HKP('http://keys.gnupg.net')
var keyring = new openpgp.Keyring()

// Print a key
function printKey () {
  const keyid = printKeyid(this.primaryKey.getKeyId())
  const userid = printUser(this.getPrimaryUser().user)
  return keyid + ' ' + userid
}
// openpgp.key.toString = printKey

function printKeyid (keyid) {
  return keyid.toHex()
}
// openpgp.Keyid.prototype.toString = openpgp.Keyid.prototype.toHex
github OriginProtocol / origin / dapps / shop / scripts / genKey.js View on Github external
const openpgp = require('openpgp')
const inquirer = require('inquirer')

openpgp.config.show_comment = false
openpgp.config.show_version = false

async function generate(name, passphrase) {
  const key = await openpgp.generateKey({
    userIds: [{ name, email: `${name.toLowerCase()}@example.com` }],
    curve: 'ed25519',
    passphrase
  })
  console.log('Public key:')
  console.log(key.publicKeyArmored)
  console.log('\nPrivate key:')
  console.log(key.privateKeyArmored)

  console.log('Public key:')
  console.log(JSON.stringify(key.publicKeyArmored).replace(/\\r/g, ''))
  console.log('\nPrivate key:')
github OriginProtocol / origin / dapps / shop / scripts / genKey.js View on Github external
const openpgp = require('openpgp')
const inquirer = require('inquirer')

openpgp.config.show_comment = false
openpgp.config.show_version = false

async function generate(name, passphrase) {
  const key = await openpgp.generateKey({
    userIds: [{ name, email: `${name.toLowerCase()}@example.com` }],
    curve: 'ed25519',
    passphrase
  })
  console.log('Public key:')
  console.log(key.publicKeyArmored)
  console.log('\nPrivate key:')
  console.log(key.privateKeyArmored)

  console.log('Public key:')
  console.log(JSON.stringify(key.publicKeyArmored).replace(/\\r/g, ''))
  console.log('\nPrivate key:')
  console.log(JSON.stringify(key.privateKeyArmored).replace(/\\r/g, ''))
github NEEOInc / neeo-sdk / src / lib / expressBrainDriver / crypto / index.ts View on Github external
function configOpenPgp() {
  openpgp.config.show_version = openpgp.config.show_comment = false;
}