fixes
This commit is contained in:
parent
11a8a99aef
commit
b310877c7d
|
@ -170,6 +170,15 @@ Message.prototype.getLiteralData = function() {
|
||||||
return literal && literal.data || null;
|
return literal && literal.data || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filename from literal data packet
|
||||||
|
* @return {(String|null)} filename of literal data packet as string
|
||||||
|
*/
|
||||||
|
Message.prototype.getFilename = function() {
|
||||||
|
var literal = this.packets.findPacket(enums.packet.literal);
|
||||||
|
return literal && literal.getFilename() || null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get literal data as text
|
* Get literal data as text
|
||||||
* @return {(String|null)} literal body of the message interpreted as text
|
* @return {(String|null)} literal body of the message interpreted as text
|
||||||
|
|
|
@ -105,11 +105,12 @@ function encryptMessage(keys, data, passwords, params) {
|
||||||
msg = msg.encrypt(keys, passwords);
|
msg = msg.encrypt(keys, passwords);
|
||||||
|
|
||||||
if(packets) {
|
if(packets) {
|
||||||
var arr = [];
|
|
||||||
var dataIndex = msg.packets.indexOfTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected)[0];
|
var dataIndex = msg.packets.indexOfTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected)[0];
|
||||||
arr.push(msg.packets.slice(0,dataIndex).write()); // Keys
|
var obj = {
|
||||||
arr.push(msg.packets.slice(dataIndex,msg.packets.length).write()); // Data
|
keys: msg.packets.slice(0,dataIndex).write(),
|
||||||
return arr;
|
data: msg.packets.slice(dataIndex,msg.packets.length).write()
|
||||||
|
};
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return armor.encode(enums.armor.message, msg.packets.write());
|
return armor.encode(enums.armor.message, msg.packets.write());
|
||||||
|
@ -195,7 +196,7 @@ function decryptMessage(privateKey, msg, params) {
|
||||||
if(binary) {
|
if(binary) {
|
||||||
var obj = {
|
var obj = {
|
||||||
data: msg.getLiteralData(),
|
data: msg.getLiteralData(),
|
||||||
filename: msg.filename
|
filename: msg.getFilename()
|
||||||
};
|
};
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ describe('Basic', function() {
|
||||||
openpgp.encryptMessage([pubKey], plaintext, [password1, password2], params).then(function(encrypted) {
|
openpgp.encryptMessage([pubKey], plaintext, [password1, password2], params).then(function(encrypted) {
|
||||||
|
|
||||||
expect(encrypted).to.exist;
|
expect(encrypted).to.exist;
|
||||||
encrypted = encrypted.join('');
|
encrypted = encrypted.keys+encrypted.data;
|
||||||
encrypted = openpgp.armor.encode(openpgp.enums.armor.message, encrypted);
|
encrypted = openpgp.armor.encode(openpgp.enums.armor.message, encrypted);
|
||||||
message = openpgp.message.readArmored(encrypted);
|
message = openpgp.message.readArmored(encrypted);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user