diff --git a/src/js/operations/PGP.js b/src/js/operations/PGP.js index fe7e5c05..9aec200b 100755 --- a/src/js/operations/PGP.js +++ b/src/js/operations/PGP.js @@ -199,11 +199,16 @@ var PGP = { return reject("Could not read encrypted message: " + err); } + var packetContainingAlgorithms = message.packets.filterByTag( + openpgp.enums.packet.publicKeyEncryptedSessionKey + )[0]; + var verification = { verified: false, + pkAlgorithm: packetContainingAlgorithms.publicKeyAlgorithm, + sessionAlgorithm: packetContainingAlgorithms.sessionKeyAlgorithm, author: publicKeys[0].users[0].userId.userid, recipient: privateKeys[0].users[0].userId.userid, - date: "", keyID: "", message: "", }; @@ -224,9 +229,11 @@ var PGP = { "Verified: " + verification.verified, "Key ID: " + verification.keyID, "Encrypted for: " + verification.recipient, - "Signed on: " + verification.date, "Signed by: " + verification.author, - "Signed with: ", + "Signed with: " + + verification.pkAlgorithm + + "/" + + verification.sessionAlgorithm, "\n", decrypted.data, ].join("\n")); @@ -333,17 +340,22 @@ var PGP = { return reject("Could not read armoured signature or message: " + err); } + var packetContainingSignature = message.packets.filterByTag( + openpgp.enums.packet.signature + )[0]; var verification = { verified: false, + pkAlgorithm: publicKeys[0].primaryKey.algorithm, author: publicKeys[0].users[0].userId.userid, - date: "", + date: packetContainingSignature.created, keyID: "", message: "", }; Promise.resolve(message.verify(publicKeys)) .then(function(signatures) { + if (signatures && signatures.length) { verification.verified = !!signatures[0].valid; verification.keyID = signatures[0].keyid.toHex(); @@ -354,7 +366,7 @@ var PGP = { "Key ID: " + verification.keyID, "Signed on: " + verification.date, "Signed by: " + verification.author, - "Signed with: ", + "Signed with: " + verification.pkAlgorithm, "\n", input, ].join("\n")); @@ -433,10 +445,15 @@ var PGP = { return reject("Could not read input message: " + err); } + var packetContainingSignature = message.packets.filterByTag( + openpgp.enums.packet.signature + )[0]; + var verification = { verified: false, + pkAlgorithm: publicKeys[0].primaryKey.algorithm, author: publicKeys[0].users[0].userId.userid, - date: "", + date: packetContainingSignature.created, keyID: "", message: message.text, }; @@ -458,7 +475,7 @@ var PGP = { "Key ID: " + verification.keyID, "Signed on: " + verification.date, "Signed by: " + verification.author, - "Signed with: ", + "Signed with: " + verification.pkAlgorithm, "\n", verification.message, ].join("\n")); diff --git a/test/tests/operations/PGP.js b/test/tests/operations/PGP.js index 0ff2fd28..a437dc98 100644 --- a/test/tests/operations/PGP.js +++ b/test/tests/operations/PGP.js @@ -304,9 +304,8 @@ TestRegister.addTests([{ "Verified: true", "Key ID: " + alice.keyID, "Encrypted for: " + bob.name, - "Signed on: ", "Signed by: " + alice.name, - "Signed with: ", + "Signed with: rsa_encrypt_sign/aes256", "\n", input, ].join("\n"), @@ -338,9 +337,8 @@ TestRegister.addTests([{ expectedOutput: [ "Verified: true", "Key ID: " + keyPair.keyID, - "Signed on: ", "Signed by: " + keyPair.name, - "Signed with: ", + "Signed with: rsa_encrypt_sign", "\n", input, ].join("\n"), @@ -353,6 +351,16 @@ TestRegister.addTests([{ op: "Verify PGP Cleartext", args: [keyPair.pub], }, + { + op: "Find / Replace", + args: [ + {option: "Regex", string: "Signed on: .*\r?\n"}, + "", + true, + false, + false, + ], + }, ], }; })