diff --git a/src/message.js b/src/message.js index 04009b55..2d9adf48 100644 --- a/src/message.js +++ b/src/message.js @@ -245,10 +245,10 @@ Message.prototype.getText = function() { * @param {Array} keys (optional) public key(s) for message encryption * @param {Array} passwords (optional) password(s) for message encryption * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } - * @param {Boolean} useWildcard (optional) use a key ID of 0 instead of the public key IDs + * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs * @return {Message} new message with encrypted content */ -Message.prototype.encrypt = function(keys, passwords, sessionKey, useWildcard=false) { +Message.prototype.encrypt = function(keys, passwords, sessionKey, wildcard=false) { let symAlgo, msg, symEncryptedPacket; return Promise.resolve().then(async () => { if (sessionKey) { @@ -269,7 +269,7 @@ Message.prototype.encrypt = function(keys, passwords, sessionKey, useWildcard=fa sessionKey = crypto.generateSessionKey(symAlgo); } - msg = await encryptSessionKey(sessionKey, symAlgo, keys, passwords, useWildcard); + msg = await encryptSessionKey(sessionKey, symAlgo, keys, passwords, wildcard); if (config.aead_protect) { symEncryptedPacket = new packet.SymEncryptedAEADProtected(); @@ -301,10 +301,10 @@ Message.prototype.encrypt = function(keys, passwords, sessionKey, useWildcard=fa * @param {String} symAlgo session key algorithm * @param {Array} publicKeys (optional) public key(s) for message encryption * @param {Array} passwords (optional) for message encryption - * @param {Boolean} useWildcard (optional) use a key ID of 0 instead of the public key IDs + * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs * @return {Message} new message with encrypted content */ -export function encryptSessionKey(sessionKey, symAlgo, publicKeys, passwords, useWildcard=false) { +export function encryptSessionKey(sessionKey, symAlgo, publicKeys, passwords, wildcard=false) { var results, packetlist = new packet.List(); return Promise.resolve().then(async () => { @@ -316,7 +316,7 @@ export function encryptSessionKey(sessionKey, symAlgo, publicKeys, passwords, us throw new Error('Could not find valid key packet for encryption in key ' + key.primaryKey.getKeyId().toHex()); } var pkESKeyPacket = new packet.PublicKeyEncryptedSessionKey(); - pkESKeyPacket.publicKeyId = useWildcard ? type_keyid.wildcard() : encryptionKeyPacket.getKeyId(); + pkESKeyPacket.publicKeyId = wildcard ? type_keyid.wildcard() : encryptionKeyPacket.getKeyId(); pkESKeyPacket.publicKeyAlgorithm = encryptionKeyPacket.algorithm; pkESKeyPacket.sessionKey = sessionKey; pkESKeyPacket.sessionKeyAlgorithm = symAlgo; diff --git a/src/openpgp.js b/src/openpgp.js index f0cc7892..e2476a15 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -196,17 +196,17 @@ export function decryptKey({ privateKey, passphrase }) { * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) * @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} useWildcard (optional) use a key ID of 0 instead of the public key IDs + * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs * @return {Promise} encrypted (and optionally signed message) in the form: * {data: ASCII armored message if 'armor' is true, * message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true} * @static */ -export function encrypt({ data, publicKeys, privateKeys, passwords, sessionKey, filename, armor=true, detached=false, signature=null, returnSessionKey=false, useWildcard=false}) { +export function encrypt({ data, publicKeys, privateKeys, passwords, sessionKey, filename, armor=true, detached=false, signature=null, returnSessionKey=false, wildcard=false}) { checkData(data); 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, publicKeys, privateKeys, passwords, sessionKey, filename, armor, detached, signature, returnSessionKey, useWildcard }); + return asyncProxy.delegate('encrypt', { data, publicKeys, privateKeys, passwords, sessionKey, filename, armor, detached, signature, returnSessionKey, wildcard }); } var result = {}; return Promise.resolve().then(async function() { @@ -223,7 +223,7 @@ export function encrypt({ data, publicKeys, privateKeys, passwords, sessionKey, message = await message.sign(privateKeys, signature); } } - return message.encrypt(publicKeys, passwords, sessionKey, useWildcard); + return message.encrypt(publicKeys, passwords, sessionKey, wildcard); }).then(encrypted => { if (armor) { @@ -363,20 +363,20 @@ export function verify({ message, publicKeys, signature=null }) { * @param {String} algorithm algorithm of the symmetric session key e.g. 'aes128' or 'aes256' * @param {Key|Array} publicKeys (optional) array of public keys or single key, used to encrypt the key * @param {String|Array} passwords (optional) passwords for the message - * @param {Boolean} useWildcard (optional) use a key ID of 0 instead of the public key IDs + * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs * @return {Promise} the encrypted session key packets contained in a message object * @static */ -export function encryptSessionKey({ data, algorithm, publicKeys, passwords, useWildcard=false }) { +export function encryptSessionKey({ data, algorithm, publicKeys, passwords, wildcard=false }) { checkBinary(data); checkString(algorithm, 'algorithm'); publicKeys = toArray(publicKeys); passwords = toArray(passwords); if (asyncProxy) { // use web worker if available - return asyncProxy.delegate('encryptSessionKey', { data, algorithm, publicKeys, passwords, useWildcard }); + return asyncProxy.delegate('encryptSessionKey', { data, algorithm, publicKeys, passwords, wildcard }); } return Promise.resolve().then(async function() { - return { message: await messageLib.encryptSessionKey(data, algorithm, publicKeys, passwords, useWildcard) }; + return { message: await messageLib.encryptSessionKey(data, algorithm, publicKeys, passwords, wildcard) }; }).catch(onError.bind(null, 'Error encrypting session key')); } diff --git a/test/general/openpgp.js b/test/general/openpgp.js index a86fc46b..5bd11f81 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -730,7 +730,7 @@ describe('OpenPGP.js public api tests', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, - useWildcard: true + wildcard: true }; var decOpt = { privateKeys: privateKey.keys @@ -753,7 +753,7 @@ describe('OpenPGP.js public api tests', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, - useWildcard: true + wildcard: true }; var decOpt = { privateKeys: [privKeyDE, privateKey.keys[0]]