Fix bug in message.decryptSessionKey where it would return this (msg obj)
Cleanup message code
This commit is contained in:
parent
55110c3409
commit
8d82a18c19
|
@ -91,7 +91,10 @@ Message.prototype.getSigningKeyIds = function() {
|
|||
*/
|
||||
Message.prototype.decrypt = function(privateKey) {
|
||||
var keyObj = this.decryptSessionKey(privateKey);
|
||||
if (keyObj) {
|
||||
if (!keyObj) {
|
||||
// nothing to decrypt return unmodified message
|
||||
return this;
|
||||
}
|
||||
var symEncryptedPacketlist = this.packets.filterByTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected);
|
||||
if (symEncryptedPacketlist.length !== 0) {
|
||||
var symEncryptedPacket = symEncryptedPacketlist[0];
|
||||
|
@ -101,7 +104,6 @@ Message.prototype.decrypt = function(privateKey) {
|
|||
symEncryptedPacket.packets = new packet.List();
|
||||
return resultMsg;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -126,16 +128,15 @@ Message.prototype.decryptSessionKey = function(privateKey) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!keyPacket) {
|
||||
throw new Error('No symmetrically encrypted session key packet found.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
var encryptionKeyIds = this.getEncryptionKeyIds();
|
||||
if (!encryptionKeyIds.length) {
|
||||
// nothing to decrypt return unmodified message
|
||||
return this;
|
||||
// nothing to decrypt
|
||||
return;
|
||||
}
|
||||
var privateKeyPacket = privateKey.getKeyPacket(encryptionKeyIds);
|
||||
if (!privateKeyPacket.isDecrypted) {
|
||||
|
@ -199,11 +200,9 @@ Message.prototype.encrypt = function(keys, passwords) {
|
|||
var symAlgo;
|
||||
if (keys) {
|
||||
symAlgo = keyModule.getPreferredSymAlgo(keys);
|
||||
}
|
||||
else if(passwords) {
|
||||
} else if (passwords) {
|
||||
symAlgo = config.encryption_cipher;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('No keys or passwords');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user