useWildcard -> wildcard
This commit is contained in:
parent
989ad5077e
commit
62015c2c8d
|
@ -245,10 +245,10 @@ Message.prototype.getText = function() {
|
||||||
* @param {Array<Key>} keys (optional) public key(s) for message encryption
|
* @param {Array<Key>} keys (optional) public key(s) for message encryption
|
||||||
* @param {Array<String>} passwords (optional) password(s) for message encryption
|
* @param {Array<String>} passwords (optional) password(s) for message encryption
|
||||||
* @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String }
|
* @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
|
* @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;
|
let symAlgo, msg, symEncryptedPacket;
|
||||||
return Promise.resolve().then(async () => {
|
return Promise.resolve().then(async () => {
|
||||||
if (sessionKey) {
|
if (sessionKey) {
|
||||||
|
@ -269,7 +269,7 @@ Message.prototype.encrypt = function(keys, passwords, sessionKey, useWildcard=fa
|
||||||
sessionKey = crypto.generateSessionKey(symAlgo);
|
sessionKey = crypto.generateSessionKey(symAlgo);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = await encryptSessionKey(sessionKey, symAlgo, keys, passwords, useWildcard);
|
msg = await encryptSessionKey(sessionKey, symAlgo, keys, passwords, wildcard);
|
||||||
|
|
||||||
if (config.aead_protect) {
|
if (config.aead_protect) {
|
||||||
symEncryptedPacket = new packet.SymEncryptedAEADProtected();
|
symEncryptedPacket = new packet.SymEncryptedAEADProtected();
|
||||||
|
@ -301,10 +301,10 @@ Message.prototype.encrypt = function(keys, passwords, sessionKey, useWildcard=fa
|
||||||
* @param {String} symAlgo session key algorithm
|
* @param {String} symAlgo session key algorithm
|
||||||
* @param {Array<Key>} publicKeys (optional) public key(s) for message encryption
|
* @param {Array<Key>} publicKeys (optional) public key(s) for message encryption
|
||||||
* @param {Array<String>} passwords (optional) for message encryption
|
* @param {Array<String>} 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
|
* @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();
|
var results, packetlist = new packet.List();
|
||||||
|
|
||||||
return Promise.resolve().then(async () => {
|
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());
|
throw new Error('Could not find valid key packet for encryption in key ' + key.primaryKey.getKeyId().toHex());
|
||||||
}
|
}
|
||||||
var pkESKeyPacket = new packet.PublicKeyEncryptedSessionKey();
|
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.publicKeyAlgorithm = encryptionKeyPacket.algorithm;
|
||||||
pkESKeyPacket.sessionKey = sessionKey;
|
pkESKeyPacket.sessionKey = sessionKey;
|
||||||
pkESKeyPacket.sessionKeyAlgorithm = symAlgo;
|
pkESKeyPacket.sessionKeyAlgorithm = symAlgo;
|
||||||
|
|
|
@ -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 {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 {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} 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<Object>} encrypted (and optionally signed message) in the form:
|
* @return {Promise<Object>} encrypted (and optionally signed message) in the form:
|
||||||
* {data: ASCII armored message if 'armor' is true,
|
* {data: ASCII armored message if 'armor' is true,
|
||||||
* message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true}
|
* message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true}
|
||||||
* @static
|
* @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);
|
checkData(data); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords);
|
||||||
|
|
||||||
if (!nativeAEAD() && asyncProxy) { // use web worker if web crypto apis are not supported
|
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 = {};
|
var result = {};
|
||||||
return Promise.resolve().then(async function() {
|
return Promise.resolve().then(async function() {
|
||||||
|
@ -223,7 +223,7 @@ export function encrypt({ data, publicKeys, privateKeys, passwords, sessionKey,
|
||||||
message = await message.sign(privateKeys, signature);
|
message = await message.sign(privateKeys, signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return message.encrypt(publicKeys, passwords, sessionKey, useWildcard);
|
return message.encrypt(publicKeys, passwords, sessionKey, wildcard);
|
||||||
|
|
||||||
}).then(encrypted => {
|
}).then(encrypted => {
|
||||||
if (armor) {
|
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 {String} algorithm algorithm of the symmetric session key e.g. 'aes128' or 'aes256'
|
||||||
* @param {Key|Array<Key>} publicKeys (optional) array of public keys or single key, used to encrypt the key
|
* @param {Key|Array<Key>} publicKeys (optional) array of public keys or single key, used to encrypt the key
|
||||||
* @param {String|Array<String>} passwords (optional) passwords for the message
|
* @param {String|Array<String>} 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<Message>} the encrypted session key packets contained in a message object
|
* @return {Promise<Message>} the encrypted session key packets contained in a message object
|
||||||
* @static
|
* @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);
|
checkBinary(data); checkString(algorithm, 'algorithm'); publicKeys = toArray(publicKeys); passwords = toArray(passwords);
|
||||||
|
|
||||||
if (asyncProxy) { // use web worker if available
|
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 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'));
|
}).catch(onError.bind(null, 'Error encrypting session key'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,7 +730,7 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
var encOpt = {
|
var encOpt = {
|
||||||
data: plaintext,
|
data: plaintext,
|
||||||
publicKeys: publicKey.keys,
|
publicKeys: publicKey.keys,
|
||||||
useWildcard: true
|
wildcard: true
|
||||||
};
|
};
|
||||||
var decOpt = {
|
var decOpt = {
|
||||||
privateKeys: privateKey.keys
|
privateKeys: privateKey.keys
|
||||||
|
@ -753,7 +753,7 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
var encOpt = {
|
var encOpt = {
|
||||||
data: plaintext,
|
data: plaintext,
|
||||||
publicKeys: publicKey.keys,
|
publicKeys: publicKey.keys,
|
||||||
useWildcard: true
|
wildcard: true
|
||||||
};
|
};
|
||||||
var decOpt = {
|
var decOpt = {
|
||||||
privateKeys: [privKeyDE, privateKey.keys[0]]
|
privateKeys: [privKeyDE, privateKey.keys[0]]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user