Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
openpgp.cleartext.readArmored("");
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
openpgp.crypto;
// API update with no documentation
openpgp.crypto.cfb.decrypt("", "", "", true);
openpgp.crypto.cfb.encrypt("", "", "", true);
// Function removed from openpgp.crypto.cfb
// openpgp.crypto.cfb.mdc({}, "", "");
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
openpgp.crypto.random.getRandomBN(mpi, mpi);
openpgp.crypto.random.getRandomBytes(0);
// function removed from openpgp.crypto.random
// openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
// openpgp.crypto.random.getSecureRandom(0, 1);
openpgp.crypto.signature.sign(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
openpgp.key.generate(keyoptions);
openpgp.key.readArmored("");
openpgp.message.fromBinary(new Uint8Array([0x01, 0x02, 0x03]));
openpgp.message.fromText("");
return publicKey.keys[0].primaryKey.getFingerprint()/* as string*/
})
// Open PGP Tests
var keyoptions: openpgp.KeyOptions;
var mpi: openpgp.type.mpi.MPI;
var mpis: Array;
openpgp.encoding.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
openpgp.encoding.armor.dearmor("");
openpgp.cleartext.readArmored("");
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
openpgp.crypto
// API update with no documentation
openpgp.crypto.cfb.decrypt("", "", "", true);
openpgp.crypto.cfb.encrypt("", "", "", true);
// Function removed from openpgp.crypto.cfb
// openpgp.crypto.cfb.mdc({}, "", "");
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
openpgp.crypto.random.getRandomBN(mpi, mpi);
var mpis: Array;
openpgp.encoding.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
openpgp.encoding.armor.dearmor("");
openpgp.cleartext.readArmored("");
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
openpgp.crypto
// API update with no documentation
openpgp.crypto.cfb.decrypt("", "", "", true);
openpgp.crypto.cfb.encrypt("", "", "", true);
// Function removed from openpgp.crypto.cfb
// openpgp.crypto.cfb.mdc({}, "", "");
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
openpgp.crypto.random.getRandomBN(mpi, mpi);
openpgp.crypto.random.getRandomBytes(0);
// function removed from openpgp.crypto.random
// openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
// openpgp.crypto.random.getSecureRandom(0, 1);
openpgp.crypto.signature.sign(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
return publicKey.keys[0].primaryKey.getFingerprint()/* as string*/
})
// Open PGP Tests
const keyoptions: openpgp.KeyOptions = null;
const mpi: openpgp.type.mpi.MPI = null;
const mpis: openpgp.type.mpi.MPI[] = [];
openpgp.encoding.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
openpgp.encoding.armor.dearmor("");
openpgp.cleartext.readArmored("");
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
openpgp.crypto;
// API update with no documentation
openpgp.crypto.cfb.decrypt("", "", "", true);
openpgp.crypto.cfb.encrypt("", "", "", true);
// Function removed from openpgp.crypto.cfb
// openpgp.crypto.cfb.mdc({}, "", "");
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
openpgp.crypto.random.getRandomBN(mpi, mpi);
.then((randomKey) => {
if (randomKey.length === 0) {
return Promise.reject(new Error('Random key is empty'));
}
oldEncMessage = binaryStringToArray(decode_utf8_base64(oldEncMessage));
let data;
try {
// cutoff time for enabling multilanguage support
if (messageTime > 1399086120) {
data = decode_utf8_base64(arrayToBinaryString(openpgp.crypto.cfb.decrypt('aes256', randomKey, oldEncMessage, true)));
} else {
data = arrayToBinaryString(openpgp.crypto.cfb.decrypt('aes256', randomKey, oldEncMessage, true));
}
} catch (err) {
return Promise.reject(err);
}
return { data, signature: 0 };
}));
});
'use strict';
var openpgp = require('openpgp'),
util = openpgp.util,
MD5 = openpgp.crypto.hash.md5,
chai = require('chai'),
expect = chai.expect;
it('MD5 with test vectors from RFC 1321', function(done) {
expect(util.hexstrdump(MD5('')), 'MD5("") = d41d8cd98f00b204e9800998ecf8427e').to.equal('d41d8cd98f00b204e9800998ecf8427e');
expect(util.hexstrdump(MD5('abc')), 'MD5("a") = 0cc175b9c0f1b6a831c399e269772661').to.equal('900150983cd24fb0d6963f7d28e17f72');
expect(util.hexstrdump(MD5('message digest')), 'MD5("message digest") = f96b697d7cb7938d525a2f31aaf161d0').to.equal('f96b697d7cb7938d525a2f31aaf161d0');
expect(util.hexstrdump(MD5('abcdefghijklmnopqrstuvwxyz')), 'MD5("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b').to.equal('c3fcd3d76192e4007dfb496cca67e13b');
expect(util.hexstrdump(MD5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')), 'MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = d174ab98d277d9f5a5611c2c9f419d9f').to.equal('d174ab98d277d9f5a5611c2c9f419d9f');
expect(util.hexstrdump(MD5('12345678901234567890123456789012345678901234567890123456789012345678901234567890')), 'MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a').to.equal('57edf4a22be3c955ac49da2e2107b67a');
done();
});
'use strict';
var openpgp = require('openpgp'),
util = openpgp.util,
hash = openpgp.crypto.hash,
chai = require('chai'),
expect = chai.expect;
it('SHA* with test vectors from NIST FIPS 180-2', function(done) {
expect(util.hexstrdump(hash.sha1('abc')), 'hash.sha1("abc") = a9993e364706816aba3e25717850c26c9cd0d89d').to.equal('a9993e364706816aba3e25717850c26c9cd0d89d');
expect(util.hexstrdump(hash.sha1('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 84983e441c3bd26ebaae4aa1f95129e5e54670f1').to.equal('84983e441c3bd26ebaae4aa1f95129e5e54670f1');
expect(util.hexstrdump(hash.sha224('abc')), 'hash.sha224("abc") = 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7').to.equal('23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7');
expect(util.hexstrdump(hash.sha224('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha224("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525').to.equal('75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525');
expect(util.hexstrdump(hash.sha256('abc')), 'hash.sha256("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad').to.equal('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad');
expect(util.hexstrdump(hash.sha256('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1').to.equal('248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1');
expect(util.hexstrdump(hash.sha384('abc')), 'hash.sha384("abc") = cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7').to.equal('cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7');
expect(util.hexstrdump(hash.sha384('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha384("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b').to.equal('3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b');
expect(util.hexstrdump(hash.sha512('abc')), 'hash.sha512("abc") = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f').to.equal('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f');
expect(util.hexstrdump(hash.sha512('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha512("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445').to.equal('204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445');
done();
});
function test_cast(input, key, output) {
var cast5 = new openpgp.crypto.cipher.cast5(util.bin2str(key));
var result = util.bin2str(cast5.encrypt(input));
return util.hexstrdump(result) == util.hexstrdump(util.bin2str(output));
}
function TFencrypt(block, key) {
var tf = new openpgp.crypto.cipher.twofish(key);
return tf.encrypt(block);
}
function test_bf(input, key, output) {
var blowfish = new openpgp.crypto.cipher.blowfish(util.bin2str(key));
var result = util.bin2str(blowfish.encrypt(input));
return (util.hexstrdump(result) == util.hexstrdump(util.bin2str(output)));
}