Replace data
with message
parameter in encrypt() and sign()
When encrypting/signing a stream, this allows you to indicate whether it's a stream of Strings or Uint8Arrays (using message.fromText or message.fromBinary, respectively.) When signing text, this allows you to control whether to create a cleartext message or a regular armored text message. When creating a detached signature, it allows you to control whether it's "meant for" (verifying against) a cleartext message. A cleartext message has trailing whitespace trimmed before signing. This fixes the case of passing a detached signature from sign() to encrypt(). Since encrypt() doesn't create a cleartext message, the signature would be invalid if the text contained lines with trailing whitespace.
This commit is contained in:
parent
95413cc6ed
commit
2b30ab9c8f
|
@ -719,7 +719,9 @@ export function fromText(text, filename, date=new Date(), type='utf8') {
|
|||
}
|
||||
const literalDataPacketlist = new packet.List();
|
||||
literalDataPacketlist.push(literalDataPacket);
|
||||
return new Message(literalDataPacketlist);
|
||||
const message = new Message(literalDataPacketlist);
|
||||
message.fromStream = util.isStream(text);
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -743,5 +745,7 @@ export function fromBinary(bytes, filename, date=new Date(), type='binary') {
|
|||
}
|
||||
const literalDataPacketlist = new packet.List();
|
||||
literalDataPacketlist.push(literalDataPacket);
|
||||
return new Message(literalDataPacketlist);
|
||||
const message = new Message(literalDataPacketlist);
|
||||
message.fromStream = util.isStream(bytes);
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -274,13 +274,11 @@ export function encryptKey({ privateKey, passphrase }) {
|
|||
/**
|
||||
* Encrypts message text/data with public keys, passwords or both at once. At least either public keys or passwords
|
||||
* must be specified. If private keys are specified, those will be used to sign the message.
|
||||
* @param {String|Uint8Array} data text/data to be encrypted as JavaScript binary string or Uint8Array
|
||||
* @param {utf8|binary|text|mime} dataType (optional) data packet type
|
||||
* @param {Message} message message to be encrypted as created by openpgp.message.fromText or openpgp.message.fromBinary
|
||||
* @param {Key|Array<Key>} publicKeys (optional) array of keys or single key, used to encrypt the message
|
||||
* @param {Key|Array<Key>} privateKeys (optional) private keys for signing. If omitted message will not be signed
|
||||
* @param {String|Array<String>} passwords (optional) array of passwords or a single password to encrypt the message
|
||||
* @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String }
|
||||
* @param {String} filename (optional) a filename for the literal data packet
|
||||
* @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config
|
||||
* @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects
|
||||
* @param {Boolean} asStream (optional) whether to return data as a ReadableStream. Defaults to true if data is a Stream.
|
||||
|
@ -288,7 +286,7 @@ export function encryptKey({ privateKey, passphrase }) {
|
|||
* @param {Signature} signature (optional) a detached signature to add to the encrypted message
|
||||
* @param {Boolean} returnSessionKey (optional) if the unencrypted session key should be added to returned object
|
||||
* @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs
|
||||
* @param {Date} date (optional) override the creation date of the message and the message signature
|
||||
* @param {Date} date (optional) override the creation date of the message signature
|
||||
* @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' }
|
||||
* @param {Object} toUserId (optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' }
|
||||
* @returns {Promise<Object>} encrypted (and optionally signed message) in the form:
|
||||
|
@ -297,15 +295,14 @@ export function encryptKey({ privateKey, passphrase }) {
|
|||
* @async
|
||||
* @static
|
||||
*/
|
||||
export function encrypt({ data, dataType, publicKeys, privateKeys, passwords, sessionKey, filename, compression=config.compression, armor=true, asStream=util.isStream(data), detached=false, signature=null, returnSessionKey=false, wildcard=false, date=new Date(), fromUserId={}, toUserId={} }) {
|
||||
checkData(data); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords);
|
||||
export function encrypt({ message, publicKeys, privateKeys, passwords, sessionKey, compression=config.compression, armor=true, asStream=message&&message.fromStream, detached=false, signature=null, returnSessionKey=false, wildcard=false, date=new Date(), fromUserId={}, toUserId={} }) {
|
||||
checkMessage(message); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords);
|
||||
|
||||
if (!nativeAEAD() && asyncProxy) { // use web worker if web crypto apis are not supported
|
||||
return asyncProxy.delegate('encrypt', { data, dataType, publicKeys, privateKeys, passwords, sessionKey, filename, compression, armor, asStream, detached, signature, returnSessionKey, wildcard, date, fromUserId, toUserId });
|
||||
return asyncProxy.delegate('encrypt', { message, publicKeys, privateKeys, passwords, sessionKey, compression, armor, asStream, detached, signature, returnSessionKey, wildcard, date, fromUserId, toUserId });
|
||||
}
|
||||
const result = {};
|
||||
return Promise.resolve().then(async function() {
|
||||
let message = createMessage(data, filename, date, dataType);
|
||||
if (!privateKeys) {
|
||||
privateKeys = [];
|
||||
}
|
||||
|
@ -351,7 +348,7 @@ export function encrypt({ data, dataType, publicKeys, privateKeys, passwords, se
|
|||
* @async
|
||||
* @static
|
||||
*/
|
||||
export function decrypt({ message, privateKeys, passwords, sessionKeys, publicKeys, format='utf8', asStream=message.fromStream, signature=null, date=new Date() }) {
|
||||
export function decrypt({ message, privateKeys, passwords, sessionKeys, publicKeys, format='utf8', asStream=message&&message.fromStream, signature=null, date=new Date() }) {
|
||||
checkMessage(message); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords); sessionKeys = toArray(sessionKeys);
|
||||
|
||||
if (!nativeAEAD() && asyncProxy) { // use web worker if web crypto apis are not supported
|
||||
|
@ -401,13 +398,12 @@ export function decrypt({ message, privateKeys, passwords, sessionKeys, publicKe
|
|||
|
||||
/**
|
||||
* Signs a cleartext message.
|
||||
* @param {String | Uint8Array} data cleartext input to be signed
|
||||
* @param {utf8|binary|text|mime} dataType (optional) data packet type
|
||||
* @param {CleartextMessage | Message} message (cleartext) message to be signed
|
||||
* @param {Key|Array<Key>} privateKeys array of keys or single key with decrypted secret key data to sign cleartext
|
||||
* @param {Boolean} armor (optional) if the return value should be ascii armored or the message object
|
||||
* @param {Boolean} asStream (optional) whether to return data as a ReadableStream. Defaults to true if data is a Stream.
|
||||
* @param {Boolean} detached (optional) if the return value should contain a detached signature
|
||||
* @param {Date} date (optional) override the creation date signature
|
||||
* @param {Date} date (optional) override the creation date of the signature
|
||||
* @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' }
|
||||
* @returns {Promise<Object>} signed cleartext in the form:
|
||||
* {data: ASCII armored message if 'armor' is true,
|
||||
|
@ -415,20 +411,18 @@ export function decrypt({ message, privateKeys, passwords, sessionKeys, publicKe
|
|||
* @async
|
||||
* @static
|
||||
*/
|
||||
export function sign({ data, dataType, privateKeys, armor=true, asStream=util.isStream(data), detached=false, date=new Date(), fromUserId={} }) {
|
||||
checkData(data);
|
||||
export function sign({ message, privateKeys, armor=true, asStream=message&&message.fromStream, detached=false, date=new Date(), fromUserId={} }) {
|
||||
checkCleartextOrMessage(message);
|
||||
privateKeys = toArray(privateKeys);
|
||||
|
||||
if (asyncProxy) { // use web worker if available
|
||||
return asyncProxy.delegate('sign', {
|
||||
data, dataType, privateKeys, armor, asStream, detached, date, fromUserId
|
||||
message, privateKeys, armor, asStream, detached, date, fromUserId
|
||||
});
|
||||
}
|
||||
|
||||
const result = {};
|
||||
return Promise.resolve().then(async function() {
|
||||
let message = util.isString(data) ? new CleartextMessage(data) : messageLib.fromBinary(data, dataType);
|
||||
|
||||
if (detached) {
|
||||
const signature = await message.signDetached(privateKeys, undefined, date, fromUserId);
|
||||
result.signature = armor ? await convertStream(signature.armor(), asStream) : signature;
|
||||
|
@ -457,7 +451,7 @@ export function sign({ data, dataType, privateKeys, armor=true, asStream=util.is
|
|||
* @async
|
||||
* @static
|
||||
*/
|
||||
export function verify({ message, publicKeys, asStream=message.fromStream, signature=null, date=new Date() }) {
|
||||
export function verify({ message, publicKeys, asStream=message&&message.fromStream, signature=null, date=new Date() }) {
|
||||
checkCleartextOrMessage(message);
|
||||
publicKeys = toArray(publicKeys);
|
||||
|
||||
|
@ -577,11 +571,6 @@ function checkBinary(data, name) {
|
|||
throw new Error('Parameter [' + (name || 'data') + '] must be of type Uint8Array');
|
||||
}
|
||||
}
|
||||
function checkData(data, name) {
|
||||
if (!util.isUint8Array(data) && !util.isString(data) && !util.isStream(data)) {
|
||||
throw new Error('Parameter [' + (name || 'data') + '] must be of type String, Uint8Array or ReadableStream');
|
||||
}
|
||||
}
|
||||
function checkMessage(message) {
|
||||
if (!(message instanceof messageLib.Message)) {
|
||||
throw new Error('Parameter [message] needs to be of type Message');
|
||||
|
@ -605,26 +594,6 @@ function toArray(param) {
|
|||
return param;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a message obejct either from a Uint8Array or a string.
|
||||
* @param {String|Uint8Array} data the payload for the message
|
||||
* @param {String} filename the literal data packet's filename
|
||||
* @param {Date} date the creation date of the package
|
||||
* @param {utf8|binary|text|mime} type (optional) data packet type
|
||||
* @returns {Message} a message object
|
||||
*/
|
||||
function createMessage(data, filename, date=new Date(), type) {
|
||||
let msg;
|
||||
if (util.isUint8Array(data) || util.isStream(data)) {
|
||||
msg = messageLib.fromBinary(data, filename, date, type);
|
||||
} else if (util.isString(data)) {
|
||||
msg = messageLib.fromText(data, filename, date, type);
|
||||
} else {
|
||||
throw new Error('Data must be of type String or Uint8Array');
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert data to or from Stream
|
||||
* @param {Object} data the data to convert
|
||||
|
|
|
@ -173,7 +173,7 @@ describe('Brainpool Cryptography', function () {
|
|||
});
|
||||
it('Sign message', async function () {
|
||||
const romeoPrivate = await load_priv_key('romeo');
|
||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], message: new openpgp.cleartext.CleartextMessage(data.romeo.message)});
|
||||
const romeoPublic = await load_pub_key('romeo');
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
||||
|
@ -197,7 +197,7 @@ describe('Brainpool Cryptography', function () {
|
|||
it('Encrypt and sign message', async function () {
|
||||
const romeoPrivate = await load_priv_key('romeo');
|
||||
const julietPublic = await load_pub_key('juliet');
|
||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.message.fromText(data.romeo.message)});
|
||||
|
||||
const message = await openpgp.message.readArmored(encrypted.data);
|
||||
const romeoPublic = await load_pub_key('romeo');
|
||||
|
@ -227,7 +227,7 @@ describe('Brainpool Cryptography', function () {
|
|||
return Promise.all([
|
||||
// Signing message
|
||||
openpgp.sign(
|
||||
{ data: testData, privateKeys: hi }
|
||||
{ message: new openpgp.cleartext.CleartextMessage(testData), privateKeys: hi }
|
||||
).then(async signed => {
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
// Verifying signed message
|
||||
|
@ -237,7 +237,7 @@ describe('Brainpool Cryptography', function () {
|
|||
).then(output => expect(output.signatures[0].valid).to.be.true),
|
||||
// Verifying detached signature
|
||||
openpgp.verify(
|
||||
{ message: openpgp.message.fromText(testData),
|
||||
{ message: new openpgp.cleartext.CleartextMessage(testData),
|
||||
publicKeys: pubHi,
|
||||
signature: await openpgp.signature.readArmored(signed.data) }
|
||||
).then(output => expect(output.signatures[0].valid).to.be.true)
|
||||
|
@ -245,7 +245,7 @@ describe('Brainpool Cryptography', function () {
|
|||
}),
|
||||
// Encrypting and signing
|
||||
openpgp.encrypt(
|
||||
{ data: testData2,
|
||||
{ message: openpgp.message.fromText(testData2),
|
||||
publicKeys: [pubBye],
|
||||
privateKeys: [hi] }
|
||||
).then(async encrypted => {
|
||||
|
|
|
@ -185,7 +185,7 @@ describe('Elliptic Curve Cryptography', function () {
|
|||
});
|
||||
it('Sign message', async function () {
|
||||
const romeoPrivate = await load_priv_key('romeo');
|
||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], message: new openpgp.cleartext.CleartextMessage(data.romeo.message)});
|
||||
const romeoPublic = await load_pub_key('romeo');
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
||||
|
@ -209,7 +209,7 @@ describe('Elliptic Curve Cryptography', function () {
|
|||
it('Encrypt and sign message', async function () {
|
||||
const romeoPrivate = await load_priv_key('romeo');
|
||||
const julietPublic = await load_pub_key('juliet');
|
||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.message.fromText(data.romeo.message)});
|
||||
|
||||
const message = await openpgp.message.readArmored(encrypted.data);
|
||||
const romeoPublic = await load_pub_key('romeo');
|
||||
|
@ -254,7 +254,7 @@ describe('Elliptic Curve Cryptography', function () {
|
|||
// Signing message
|
||||
|
||||
openpgp.sign(
|
||||
{ data: testData, privateKeys: hi }
|
||||
{ message: new openpgp.cleartext.CleartextMessage(testData), privateKeys: hi }
|
||||
).then(async signed => {
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
// Verifying signed message
|
||||
|
@ -264,7 +264,7 @@ describe('Elliptic Curve Cryptography', function () {
|
|||
).then(output => expect(output.signatures[0].valid).to.be.true),
|
||||
// Verifying detached signature
|
||||
openpgp.verify(
|
||||
{ message: openpgp.message.fromText(testData),
|
||||
{ message: new openpgp.cleartext.CleartextMessage(testData),
|
||||
publicKeys: pubHi,
|
||||
signature: await openpgp.signature.readArmored(signed.data) }
|
||||
).then(output => expect(output.signatures[0].valid).to.be.true)
|
||||
|
@ -272,7 +272,7 @@ describe('Elliptic Curve Cryptography', function () {
|
|||
}),
|
||||
// Encrypting and signing
|
||||
openpgp.encrypt(
|
||||
{ data: testData2,
|
||||
{ message: openpgp.message.fromText(testData2),
|
||||
publicKeys: [pubBye],
|
||||
privateKeys: [hi] }
|
||||
).then(async encrypted => {
|
||||
|
|
|
@ -1958,7 +1958,7 @@ VYGdb3eNlV8CfoEC
|
|||
await privateKey.decrypt('hello world');
|
||||
// Set second user to prefer aes128. We should select this user by default, since it was created later.
|
||||
publicKey.users[1].selfCertifications[0].preferredSymmetricAlgorithms = [openpgp.enums.symmetric.aes128];
|
||||
const encrypted = await openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, armor: false});
|
||||
const encrypted = await openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, armor: false});
|
||||
expect(encrypted.message.packets[0].sessionKeyAlgorithm).to.equal('aes128');
|
||||
});
|
||||
|
||||
|
@ -1970,7 +1970,7 @@ VYGdb3eNlV8CfoEC
|
|||
publicKey.users[0].selfCertifications[0].isPrimaryUserID = true;
|
||||
// Set first user to prefer aes128.
|
||||
publicKey.users[0].selfCertifications[0].preferredSymmetricAlgorithms = [openpgp.enums.symmetric.aes128];
|
||||
const encrypted = await openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, armor: false});
|
||||
const encrypted = await openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, armor: false});
|
||||
expect(encrypted.message.packets[0].sessionKeyAlgorithm).to.equal('aes128');
|
||||
});
|
||||
|
||||
|
@ -1982,9 +1982,9 @@ VYGdb3eNlV8CfoEC
|
|||
publicKey.users[0].selfCertifications[0].isPrimaryUserID = true;
|
||||
// Set second user to prefer aes128. We will select this user.
|
||||
publicKey.users[1].selfCertifications[0].preferredSymmetricAlgorithms = [openpgp.enums.symmetric.aes128];
|
||||
const encrypted = await openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, toUserId: {name: 'Test User', email: 'b@c.com'}, armor: false});
|
||||
const encrypted = await openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, toUserId: {name: 'Test User', email: 'b@c.com'}, armor: false});
|
||||
expect(encrypted.message.packets[0].sessionKeyAlgorithm).to.equal('aes128');
|
||||
await expect(openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, toUserId: {name: 'Test User', email: 'c@c.com'}, armor: false})).to.be.rejectedWith('Could not find user that matches that user ID');
|
||||
await expect(openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, toUserId: {name: 'Test User', email: 'c@c.com'}, armor: false})).to.be.rejectedWith('Could not find user that matches that user ID');
|
||||
});
|
||||
|
||||
it('Sign - specific user', async function() {
|
||||
|
@ -2000,11 +2000,11 @@ VYGdb3eNlV8CfoEC
|
|||
privateKey.users[0].userId.parse('Test User <b@c.com>');
|
||||
// Set second user to prefer aes128. We will select this user.
|
||||
privateKey.users[1].selfCertifications[0].preferredHashAlgorithms = [openpgp.enums.hash.sha512];
|
||||
const signed = await openpgp.sign({data: 'hello', privateKeys: privateKey, fromUserId: {name: 'Test McTestington', email: 'test@example.com'}, armor: false});
|
||||
const signed = await openpgp.sign({message: new openpgp.cleartext.CleartextMessage('hello'), privateKeys: privateKey, fromUserId: {name: 'Test McTestington', email: 'test@example.com'}, armor: false});
|
||||
expect(signed.message.signature.packets[0].hashAlgorithm).to.equal(openpgp.enums.hash.sha512);
|
||||
const encrypted = await openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, fromUserId: {name: 'Test McTestington', email: 'test@example.com'}, detached: true, armor: false});
|
||||
const encrypted = await openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, fromUserId: {name: 'Test McTestington', email: 'test@example.com'}, detached: true, armor: false});
|
||||
expect(encrypted.signature.packets[0].hashAlgorithm).to.equal(openpgp.enums.hash.sha512);
|
||||
await expect(openpgp.encrypt({data: 'hello', publicKeys: publicKey, privateKeys: privateKey, fromUserId: {name: 'Not Test McTestington', email: 'test@example.com'}, detached: true, armor: false})).to.be.rejectedWith('Could not find user that matches that user ID');
|
||||
await expect(openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: publicKey, privateKeys: privateKey, fromUserId: {name: 'Not Test McTestington', email: 'test@example.com'}, detached: true, armor: false})).to.be.rejectedWith('Could not find user that matches that user ID');
|
||||
});
|
||||
|
||||
it('Reformat key without passphrase', function() {
|
||||
|
@ -2071,7 +2071,7 @@ VYGdb3eNlV8CfoEC
|
|||
expect(newKey.users.length).to.equal(1);
|
||||
expect(newKey.users[0].userId.userid).to.equal(userId);
|
||||
expect(newKey.isDecrypted()).to.be.true;
|
||||
return openpgp.sign({data: 'hello', privateKeys: newKey, armor: true}).then(async function(signed) {
|
||||
return openpgp.sign({message: new openpgp.cleartext.CleartextMessage('hello'), privateKeys: newKey, armor: true}).then(async function(signed) {
|
||||
return openpgp.verify(
|
||||
{message: await openpgp.cleartext.readArmored(signed.data), publicKeys: newKey.toPublic()}
|
||||
).then(async function(verified) {
|
||||
|
@ -2117,7 +2117,7 @@ VYGdb3eNlV8CfoEC
|
|||
opt.userIds = userId2;
|
||||
return openpgp.reformatKey(opt).then(function(newKey) {
|
||||
newKey = newKey.key;
|
||||
return openpgp.encrypt({data: 'hello', publicKeys: newKey.toPublic(), privateKeys: newKey, armor: true}).then(async function(encrypted) {
|
||||
return openpgp.encrypt({message: openpgp.message.fromText('hello'), publicKeys: newKey.toPublic(), privateKeys: newKey, armor: true}).then(async function(encrypted) {
|
||||
return openpgp.decrypt({message: await openpgp.message.readArmored(encrypted.data), privateKeys: newKey, publicKeys: newKey.toPublic()}).then(function(decrypted) {
|
||||
expect(decrypted.data).to.equal('hello');
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
|
@ -2151,7 +2151,7 @@ VYGdb3eNlV8CfoEC
|
|||
|
||||
it('Reject encryption with revoked subkey', async function() {
|
||||
const key = (await openpgp.key.readArmored(pub_revoked_subkeys)).keys[0];
|
||||
return openpgp.encrypt({publicKeys: [key], data: 'random data'}).then(() => {
|
||||
return openpgp.encrypt({publicKeys: [key], message: openpgp.message.fromText('random data')}).then(() => {
|
||||
throw new Error('encryptSessionKey should not encrypt with revoked public key');
|
||||
}).catch(function(error) {
|
||||
expect(error.message).to.equal('Error encrypting message: Could not find valid key packet for encryption in key ' + key.getKeyId().toHex());
|
||||
|
@ -2160,7 +2160,7 @@ VYGdb3eNlV8CfoEC
|
|||
|
||||
it('Reject encryption with key revoked with appended revocation cert', async function() {
|
||||
const key = (await openpgp.key.readArmored(pub_revoked_with_cert)).keys[0];
|
||||
return openpgp.encrypt({publicKeys: [key], data: 'random data'}).then(() => {
|
||||
return openpgp.encrypt({publicKeys: [key], message: openpgp.message.fromText('random data')}).then(() => {
|
||||
throw new Error('encryptSessionKey should not encrypt with revoked public key');
|
||||
}).catch(function(error) {
|
||||
expect(error.message).to.equal('Error encrypting message: Could not find valid key packet for encryption in key ' + key.getKeyId().toHex());
|
||||
|
|
|
@ -736,7 +736,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
if (openpgp.getWorker()) { // init again to trigger config event
|
||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
}
|
||||
return openpgp.encrypt({ publicKeys:publicKey.keys, data:plaintext }).then(function(encrypted) {
|
||||
return openpgp.encrypt({ publicKeys:publicKey.keys, message:openpgp.message.fromText(plaintext) }).then(function(encrypted) {
|
||||
expect(encrypted.data).to.exist;
|
||||
expect(encrypted.data).not.to.match(/^Version:/);
|
||||
expect(encrypted.data).to.match(/Comment: different/);
|
||||
|
@ -779,7 +779,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('Calling decrypt with not decrypted key leads to exception', function() {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
const decOpt = {
|
||||
|
@ -859,7 +859,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('roundtrip workflow: encrypt, decryptSessionKeys, decrypt with pgp key pair', function () {
|
||||
let msgAsciiArmored;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
}).then(async function (encrypted) {
|
||||
msgAsciiArmored = encrypted.data;
|
||||
|
@ -883,7 +883,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const plaintext = 'space: \nspace and tab: \t\nno trailing space\n \ntab:\t\ntab and space:\t ';
|
||||
let msgAsciiArmored;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
}).then(async function (encrypted) {
|
||||
msgAsciiArmored = encrypted.data;
|
||||
|
@ -906,7 +906,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('roundtrip workflow: encrypt, decryptSessionKeys, decrypt with password', function () {
|
||||
let msgAsciiArmored;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: password1
|
||||
}).then(async function (encrypted) {
|
||||
msgAsciiArmored = encrypted.data;
|
||||
|
@ -929,7 +929,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('roundtrip workflow: encrypt with multiple passwords, decryptSessionKeys, decrypt with multiple passwords', function () {
|
||||
let msgAsciiArmored;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: [password1, password2]
|
||||
}).then(async function (encrypted) {
|
||||
msgAsciiArmored = encrypted.data;
|
||||
|
@ -952,7 +952,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('roundtrip workflow: encrypt twice with one password, decryptSessionKeys, only one session key', function () {
|
||||
let msgAsciiArmored;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: [password1, password1]
|
||||
}).then(async function (encrypted) {
|
||||
msgAsciiArmored = encrypted.data;
|
||||
|
@ -996,7 +996,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt then decrypt', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
const decOpt = {
|
||||
|
@ -1018,7 +1018,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
await privKeyDE.decrypt(passphrase);
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
const decOpt = {
|
||||
|
@ -1037,7 +1037,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt then decrypt with wildcard', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
wildcard: true
|
||||
};
|
||||
|
@ -1060,7 +1060,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
await privKeyDE.decrypt(passphrase);
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
wildcard: true
|
||||
};
|
||||
|
@ -1080,7 +1080,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt then decrypt using returned session key', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
returnSessionKey: true
|
||||
};
|
||||
|
@ -1105,7 +1105,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
algorithm: 'aes256'
|
||||
};
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
sessionKey: sessionKey,
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
|
@ -1128,7 +1128,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
algorithm: 'aes128'
|
||||
};
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
sessionKey: sessionKey,
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
|
@ -1147,7 +1147,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt/sign and decrypt/verify', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1170,7 +1170,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt/sign and decrypt/verify (no AEAD support)', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKeyNoAEAD.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1203,7 +1203,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const newPrivateKey = await openpgp.key.readArmored(newKey.privateKeyArmored);
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: newPublicKey.keys,
|
||||
privateKeys: newPrivateKey.keys
|
||||
};
|
||||
|
@ -1227,7 +1227,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt/sign and decrypt/verify with null string input', function () {
|
||||
const encOpt = {
|
||||
data: '',
|
||||
message: openpgp.message.fromText(''),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1249,7 +1249,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt/sign and decrypt/verify with detached signatures', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
|
@ -1273,13 +1273,13 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt and decrypt/verify with detached signature input and detached flag set for encryption', function () {
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
privateKeys: privateKey.keys[0],
|
||||
detached: true
|
||||
};
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
detached: true
|
||||
};
|
||||
|
@ -1312,13 +1312,13 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const pubKeyDE = (await openpgp.key.readArmored(pub_key_de)).keys[0];
|
||||
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
privateKeys: privKeyDE,
|
||||
detached: true
|
||||
};
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys[0]
|
||||
};
|
||||
|
@ -1350,13 +1350,13 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should fail to encrypt and decrypt/verify with detached signature input and detached flag set for encryption with wrong public key', async function () {
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
};
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
detached: true
|
||||
};
|
||||
|
@ -1384,13 +1384,13 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should fail to encrypt and decrypt/verify with detached signature as input and detached flag not set for encryption with wrong public key', async function () {
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
};
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
|
||||
|
@ -1416,7 +1416,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should fail to verify decrypted data with wrong public pgp key', async function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1438,7 +1438,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should fail to verify decrypted null string with wrong public pgp key', async function () {
|
||||
const encOpt = {
|
||||
data: '',
|
||||
message: openpgp.message.fromText(''),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1460,7 +1460,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should successfully decrypt signed message without public keys to verify', async function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
|
@ -1481,7 +1481,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should fail to verify decrypted data with wrong public pgp key with detached signatures', async function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
|
@ -1510,7 +1510,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const pubKeyDE = (await openpgp.key.readArmored(pub_key_de)).keys[0];
|
||||
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: publicKey.keys,
|
||||
privateKeys: [privateKey.keys[0], privKeyDE]
|
||||
};
|
||||
|
@ -1538,8 +1538,9 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and verify cleartext data', function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
const verifyOpt = {
|
||||
|
@ -1562,8 +1563,9 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const privKeyDE = (await openpgp.key.readArmored(priv_key_de)).keys[0];
|
||||
await privKeyDE.decrypt(passphrase);
|
||||
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: [privateKey.keys[0], privKeyDE]
|
||||
};
|
||||
const verifyOpt = {
|
||||
|
@ -1588,16 +1590,17 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and verify cleartext data with detached signatures', function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
};
|
||||
const verifyOpt = {
|
||||
message,
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
return openpgp.sign(signOpt).then(async function (signed) {
|
||||
verifyOpt.message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
verifyOpt.signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.verify(verifyOpt);
|
||||
}).then(async function (verified) {
|
||||
|
@ -1610,8 +1613,9 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and fail to verify cleartext data with wrong public pgp key', async function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys
|
||||
};
|
||||
const verifyOpt = {
|
||||
|
@ -1630,16 +1634,17 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and fail to verify cleartext data with wrong public pgp key with detached signature', async function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true
|
||||
};
|
||||
const verifyOpt = {
|
||||
message,
|
||||
publicKeys: (await openpgp.key.readArmored(wrong_pubkey)).keys
|
||||
};
|
||||
return openpgp.sign(signOpt).then(async function (signed) {
|
||||
verifyOpt.message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
verifyOpt.signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.verify(verifyOpt);
|
||||
}).then(async function (verified) {
|
||||
|
@ -1652,8 +1657,9 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and verify cleartext data and not armor', function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys,
|
||||
armor: false
|
||||
};
|
||||
|
@ -1674,17 +1680,18 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should sign and verify cleartext data and not armor with detached signatures', function () {
|
||||
const start = openpgp.util.normalizeDate();
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey.keys,
|
||||
detached: true,
|
||||
armor: false
|
||||
};
|
||||
const verifyOpt = {
|
||||
message,
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
return openpgp.sign(signOpt).then(function (signed) {
|
||||
verifyOpt.message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
verifyOpt.signature = signed.signature;
|
||||
return openpgp.verify(verifyOpt);
|
||||
}).then(async function (verified) {
|
||||
|
@ -1699,19 +1706,20 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
|
||||
it('should sign and verify cleartext data with a date in the past', function () {
|
||||
const message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
const past = new Date(2000);
|
||||
const signOpt = {
|
||||
data: plaintext,
|
||||
message,
|
||||
privateKeys: privateKey_1337.keys,
|
||||
detached: true,
|
||||
date: past
|
||||
};
|
||||
const verifyOpt = {
|
||||
message,
|
||||
publicKeys: publicKey_1337.keys,
|
||||
date: past
|
||||
};
|
||||
return openpgp.sign(signOpt).then(async function (signed) {
|
||||
verifyOpt.message = new openpgp.cleartext.CleartextMessage(plaintext);
|
||||
verifyOpt.signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.verify(verifyOpt).then(function (verified) {
|
||||
expect(+verified.signatures[0].signature.packets[0].created).to.equal(+past);
|
||||
|
@ -1738,7 +1746,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
||||
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
||||
const signOpt = {
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privateKey_2038_2045.keys,
|
||||
detached: true,
|
||||
date: future,
|
||||
|
@ -1765,7 +1773,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('should encrypt and decrypt cleartext data with a date in the future', function () {
|
||||
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
||||
const encryptOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext, undefined, future),
|
||||
publicKeys: publicKey_2038_2045.keys,
|
||||
date: future,
|
||||
armor: false
|
||||
|
@ -1790,7 +1798,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const past = new Date(2005, 5, 5, 5, 5, 5, 0);
|
||||
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
||||
const encryptOpt = {
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data, undefined, past),
|
||||
publicKeys: publicKey_2000_2008.keys,
|
||||
date: past,
|
||||
armor: false
|
||||
|
@ -1814,7 +1822,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('should sign, encrypt and decrypt, verify cleartext data with a date in the past', function () {
|
||||
const past = new Date(2005, 5, 5, 5, 5, 5, 0);
|
||||
const encryptOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext, undefined, past),
|
||||
publicKeys: publicKey_2000_2008.keys,
|
||||
privateKeys: privateKey_2000_2008.keys,
|
||||
date: past,
|
||||
|
@ -1841,7 +1849,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
||||
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
||||
const encryptOpt = {
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data, undefined, future),
|
||||
publicKeys: publicKey_2038_2045.keys,
|
||||
privateKeys: privateKey_2038_2045.keys,
|
||||
date: future,
|
||||
|
@ -1869,8 +1877,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
||||
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
||||
const encryptOpt = {
|
||||
data,
|
||||
dataType: 'mime',
|
||||
message: openpgp.message.fromBinary(data, undefined, future, 'mime'),
|
||||
publicKeys: publicKey_2038_2045.keys,
|
||||
privateKeys: privateKey_2038_2045.keys,
|
||||
date: future,
|
||||
|
@ -1899,7 +1906,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
key: privateKey.keys[0]
|
||||
}).then(function(revKey) {
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: revKey.publicKey
|
||||
}).then(function(encrypted) {
|
||||
throw new Error('Should not encrypt with revoked key');
|
||||
|
@ -1916,7 +1923,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
return privKeyDE.subKeys[0].revoke(privKeyDE.primaryKey).then(function(revSubKey) {
|
||||
pubKeyDE.subKeys[0] = revSubKey;
|
||||
return openpgp.encrypt({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
publicKeys: pubKeyDE
|
||||
}).then(function(encrypted) {
|
||||
throw new Error('Should not encrypt with revoked subkey');
|
||||
|
@ -1937,7 +1944,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
return openpgp.encrypt({
|
||||
publicKeys: pubKeyDE,
|
||||
privateKeys: privKeyDE,
|
||||
data: plaintext
|
||||
message: openpgp.message.fromText(plaintext)
|
||||
}).then(async function (encrypted) {
|
||||
return openpgp.decrypt({
|
||||
privateKeys: privKeyDE,
|
||||
|
@ -2023,7 +2030,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt and decrypt with one password', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: password1
|
||||
};
|
||||
const decOpt = {
|
||||
|
@ -2040,7 +2047,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt and decrypt with two passwords', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: [password1, password2]
|
||||
};
|
||||
const decOpt = {
|
||||
|
@ -2069,7 +2076,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('should encrypt and decrypt with password and not ascii armor', function () {
|
||||
const encOpt = {
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: password1,
|
||||
armor: false
|
||||
};
|
||||
|
@ -2088,7 +2095,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
it('should encrypt and decrypt with binary data and transferable objects', function () {
|
||||
openpgp.config.zero_copy = true; // activate transferable objects
|
||||
const encOpt = {
|
||||
data: new Uint8Array([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]),
|
||||
message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01])),
|
||||
passwords: password1,
|
||||
armor: false
|
||||
};
|
||||
|
@ -2101,7 +2108,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
return openpgp.decrypt(decOpt);
|
||||
}).then(function (decrypted) {
|
||||
if (openpgp.getWorker()) {
|
||||
expect(encOpt.data.byteLength).to.equal(0); // transferred buffer should be empty
|
||||
expect(encOpt.message.packets[0].data.byteLength).to.equal(0); // transferred buffer should be empty
|
||||
}
|
||||
expect(decrypted.data).to.deep.equal(new Uint8Array([0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]));
|
||||
expect(decrypted.signatures.length).to.equal(0);
|
||||
|
@ -2113,7 +2120,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
withCompression(function (modifyCompressionEncryptOptions, verifyCompressionDecrypted) {
|
||||
it('should encrypt and decrypt with one password', function () {
|
||||
const encOpt = modifyCompressionEncryptOptions({
|
||||
data: plaintext,
|
||||
message: openpgp.message.fromText(plaintext),
|
||||
passwords: password1
|
||||
});
|
||||
const decOpt = {
|
||||
|
@ -2144,7 +2151,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt(modifyCompressionEncryptOptions({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
}));
|
||||
|
||||
|
@ -2165,7 +2172,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
it('Error message should contain the original error message', function() {
|
||||
return openpgp.encrypt({
|
||||
data: new Uint8Array([0x01, 0x01, 0x01]),
|
||||
message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01])),
|
||||
passwords: null
|
||||
})
|
||||
.then(function() {
|
||||
|
|
|
@ -601,19 +601,19 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Sign text with openpgp.sign and verify with openpgp.verify leads to same string cleartext and valid signatures', async function() {
|
||||
const plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
const plaintext = 'short message\nnext line \n한국어/조선말';
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext }).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: new openpgp.cleartext.CleartextMessage(plaintext) }).then(async function(signed) {
|
||||
|
||||
const csMsg = await openpgp.cleartext.readArmored(signed.data);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:csMsg });
|
||||
|
||||
}).then(function(cleartextSig) {
|
||||
expect(cleartextSig).to.exist;
|
||||
expect(cleartextSig.data).to.equal(plaintext.replace(/\r/g,''));
|
||||
expect(cleartextSig.data).to.equal(openpgp.util.removeTrailingSpaces(plaintext.replace(/\r/g,'')));
|
||||
expect(cleartextSig.signatures).to.have.length(1);
|
||||
expect(cleartextSig.signatures[0].valid).to.be.true;
|
||||
expect(cleartextSig.signatures[0].signature.packets.length).to.equal(1);
|
||||
|
@ -626,7 +626,7 @@ yYDnCgA=
|
|||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext }).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: new openpgp.cleartext.CleartextMessage(plaintext) }).then(async function(signed) {
|
||||
|
||||
const csMsg = await openpgp.cleartext.readArmored(signed.data);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:csMsg });
|
||||
|
@ -646,7 +646,7 @@ yYDnCgA=
|
|||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext }).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: new openpgp.cleartext.CleartextMessage(plaintext) }).then(async function(signed) {
|
||||
|
||||
const csMsg = await openpgp.cleartext.readArmored(signed.data);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:csMsg });
|
||||
|
@ -661,12 +661,12 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - armored', async function() {
|
||||
const plaintext = openpgp.util.str_to_Uint8Array('short message\nnext line\n한국어/조선말');
|
||||
const plaintext = openpgp.util.str_to_Uint8Array('short message\nnext line \n한국어/조선말');
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext }).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.message.fromBinary(plaintext) }).then(async function(signed) {
|
||||
|
||||
const csMsg = await openpgp.message.readArmored(signed.data);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:csMsg });
|
||||
|
@ -681,12 +681,12 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - not armored', async function() {
|
||||
const plaintext = openpgp.util.str_to_Uint8Array('short message\nnext line\n한국어/조선말');
|
||||
const plaintext = openpgp.util.str_to_Uint8Array('short message\nnext line \n한국어/조선말');
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext, armor:false }).then(function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.message.fromBinary(plaintext), armor:false }).then(function(signed) {
|
||||
|
||||
const csMsg = signed.message;
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:csMsg });
|
||||
|
@ -701,11 +701,11 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Should verify cleartext message correctly when using a detached cleartext signature and binary literal data', async function () {
|
||||
const plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
const plaintext = 'short message\nnext line \n한국어/조선말';
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintext, detached: true}).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.message.fromText(plaintext), detached: true}).then(async function(signed) {
|
||||
const signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.message.fromBinary(openpgp.util.str_to_Uint8Array(openpgp.util.encode_utf8(plaintext))), signature: signature });
|
||||
}).then(function(cleartextSig) {
|
||||
|
@ -717,12 +717,12 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Should verify cleartext message correctly when using a detached binary signature and text literal data', async function () {
|
||||
const plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
const plaintext = 'short message\nnext line \n한국어/조선말';
|
||||
const plaintextArray = openpgp.util.str_to_Uint8Array(plaintext);
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await privKey.decrypt('hello world');
|
||||
return openpgp.sign({ privateKeys:[privKey], data:plaintextArray, detached: true}).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message:openpgp.message.fromBinary(plaintextArray), detached: true}).then(async function(signed) {
|
||||
const signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.message.fromText(plaintext), signature: signature });
|
||||
}).then(function(cleartextSig) {
|
||||
|
@ -734,13 +734,13 @@ yYDnCgA=
|
|||
});
|
||||
|
||||
it('Should verify encrypted cleartext message correctly when encrypting binary literal data with a canonical text signature', async function () {
|
||||
const plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
const plaintext = 'short message\nnext line \n한국어/조선말';
|
||||
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
|
||||
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
|
||||
await Promise.all([privKey.primaryKey.decrypt('hello world'), privKey.subKeys[0].keyPacket.decrypt('hello world')]);
|
||||
return openpgp.sign({ privateKeys:[privKey], data: plaintext, detached: true}).then(async function(signed) {
|
||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.message.fromText(plaintext), detached: true}).then(async function(signed) {
|
||||
const signature = await openpgp.signature.readArmored(signed.signature);
|
||||
return openpgp.encrypt({ data: openpgp.util.str_to_Uint8Array(openpgp.util.encode_utf8(plaintext)), publicKeys: [pubKey], signature })
|
||||
return openpgp.encrypt({ message: openpgp.message.fromBinary(openpgp.util.str_to_Uint8Array(openpgp.util.encode_utf8(plaintext))), publicKeys: [pubKey], signature })
|
||||
}).then(async ({ data }) => {
|
||||
const csMsg = await openpgp.message.readArmored(data);
|
||||
return openpgp.decrypt({ message: csMsg, privateKeys: [ privKey ], publicKeys: [ pubKey ] });
|
||||
|
|
|
@ -3,6 +3,7 @@ const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp
|
|||
const stub = require('sinon/lib/sinon/stub');
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
const input = require('./testInputs.js');
|
||||
|
||||
const { expect } = chai;
|
||||
|
||||
|
@ -85,7 +86,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
const msgAsciiArmored = await openpgp.stream.readToEnd(encrypted.data);
|
||||
|
@ -113,7 +114,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
expect(await openpgp.stream.getReader(openpgp.stream.clone(encrypted.data)).readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\r\n/);
|
||||
|
@ -148,7 +149,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
const reader = openpgp.stream.getReader(encrypted.data);
|
||||
|
@ -182,7 +183,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.sign({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privKey
|
||||
});
|
||||
const reader = openpgp.stream.getReader(encrypted.data);
|
||||
|
@ -208,7 +209,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
|
@ -244,7 +245,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
|
@ -289,7 +290,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
publicKeys: pubKey,
|
||||
privateKeys: privKey
|
||||
});
|
||||
|
@ -330,7 +331,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
|
@ -378,7 +379,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
publicKeys: pubKey,
|
||||
privateKeys: privKey
|
||||
});
|
||||
|
@ -427,7 +428,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
publicKeys: pubKey,
|
||||
privateKeys: privKey
|
||||
});
|
||||
|
@ -476,7 +477,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.sign({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privKey
|
||||
});
|
||||
|
||||
|
@ -520,7 +521,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
|
@ -541,6 +542,47 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
|
||||
it('Encrypt and decrypt larger text message roundtrip (draft04)', async function() {
|
||||
let aead_protectValue = openpgp.config.aead_protect;
|
||||
let aead_chunk_size_byteValue = openpgp.config.aead_chunk_size_byte;
|
||||
openpgp.config.aead_protect = true;
|
||||
openpgp.config.aead_chunk_size_byte = 0;
|
||||
try {
|
||||
let plaintext = [];
|
||||
let i = 0;
|
||||
const data = new ReadableStream({
|
||||
async pull(controller) {
|
||||
await new Promise(resolve => setTimeout(resolve, 10));
|
||||
if (i++ < 10) {
|
||||
let randomData = input.createSomeMessage();
|
||||
controller.enqueue(randomData);
|
||||
plaintext.push(randomData);
|
||||
} else {
|
||||
controller.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
message: openpgp.message.fromText(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
const msgAsciiArmored = encrypted.data;
|
||||
const message = await openpgp.message.readArmored(msgAsciiArmored);
|
||||
const decrypted = await openpgp.decrypt({
|
||||
passwords: ['test'],
|
||||
message
|
||||
});
|
||||
expect(util.isStream(decrypted.data)).to.be.true;
|
||||
expect(await openpgp.stream.getReader(openpgp.stream.clone(decrypted.data)).readBytes(50)).to.equal(plaintext[0]);
|
||||
if (i > 10) throw new Error('Data did not arrive early.');
|
||||
expect(await openpgp.stream.readToEnd(decrypted.data)).to.equal(util.concat(plaintext));
|
||||
} finally {
|
||||
openpgp.config.aead_protect = aead_protectValue;
|
||||
openpgp.config.aead_chunk_size_byte = aead_chunk_size_byteValue;
|
||||
}
|
||||
});
|
||||
|
||||
it('stream.transformPair()', async function() {
|
||||
let plaintext = [];
|
||||
let i = 0;
|
||||
|
@ -608,7 +650,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
|
||||
|
@ -661,7 +703,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.sign({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privKey
|
||||
});
|
||||
|
||||
|
@ -702,7 +744,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
const reader = openpgp.stream.getReader(encrypted.data);
|
||||
|
@ -732,7 +774,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.sign({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privKey
|
||||
});
|
||||
const reader = openpgp.stream.getReader(encrypted.data);
|
||||
|
@ -763,7 +805,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.encrypt({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
passwords: ['test'],
|
||||
});
|
||||
const msgAsciiArmored = encrypted.data;
|
||||
|
@ -810,7 +852,7 @@ describe('Streaming', function() {
|
|||
}
|
||||
});
|
||||
const encrypted = await openpgp.sign({
|
||||
data,
|
||||
message: openpgp.message.fromBinary(data),
|
||||
privateKeys: privKey
|
||||
});
|
||||
const msgAsciiArmored = encrypted.data;
|
||||
|
|
|
@ -172,7 +172,7 @@ describe('X25519 Cryptography', function () {
|
|||
const name = 'light';
|
||||
const randomData = input.createSomeMessage();
|
||||
const priv = await load_priv_key(name);
|
||||
const signed = await openpgp.sign({ privateKeys: [priv], data: randomData});
|
||||
const signed = await openpgp.sign({ privateKeys: [priv], message: new openpgp.cleartext.CleartextMessage(randomData)});
|
||||
const pub = await load_pub_key(name);
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
const result = await openpgp.verify({ publicKeys: [pub], message: msg});
|
||||
|
@ -199,7 +199,7 @@ describe('X25519 Cryptography', function () {
|
|||
const nightPublic = await load_pub_key('night');
|
||||
const lightPrivate = await load_priv_key('light');
|
||||
const randomData = input.createSomeMessage();
|
||||
const encrypted = await openpgp.encrypt({ publicKeys: [nightPublic], privateKeys: [lightPrivate], data: randomData });
|
||||
const encrypted = await openpgp.encrypt({ publicKeys: [nightPublic], privateKeys: [lightPrivate], message: openpgp.message.fromText(randomData) });
|
||||
|
||||
const message = await openpgp.message.readArmored(encrypted.data);
|
||||
const lightPublic = await load_pub_key('light');
|
||||
|
@ -276,7 +276,7 @@ describe('X25519 Cryptography', function () {
|
|||
}),
|
||||
// Signing message
|
||||
openpgp.sign(
|
||||
{ data: 'Hi, this is me, Hi!', privateKeys: hi }
|
||||
{ message: new openpgp.cleartext.CleartextMessage('Hi, this is me, Hi!'), privateKeys: hi }
|
||||
).then(async signed => {
|
||||
const msg = await openpgp.cleartext.readArmored(signed.data);
|
||||
// Verifying signed message
|
||||
|
@ -294,7 +294,7 @@ describe('X25519 Cryptography', function () {
|
|||
}),
|
||||
// Encrypting and signing
|
||||
openpgp.encrypt(
|
||||
{ data: 'Hi, Hi wrote this but only Bye can read it!',
|
||||
{ message: openpgp.message.fromText('Hi, Hi wrote this but only Bye can read it!'),
|
||||
publicKeys: [pubBye],
|
||||
privateKeys: [hi] }
|
||||
).then(async encrypted => {
|
||||
|
|
|
@ -52,7 +52,7 @@ function tests() {
|
|||
const worker = new Worker('../dist/openpgp.worker.js');
|
||||
const wProxy = new openpgp.AsyncProxy({ path:'../dist/openpgp.worker.js', workers: [worker] });
|
||||
|
||||
return wProxy.delegate('encrypt', { publicKeys:[pubKey], data:plaintext });
|
||||
return wProxy.delegate('encrypt', { publicKeys:[pubKey], message:openpgp.message.fromText(plaintext) });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user