From 3d2c0d784e9f0d8e92d57fe1d0a348145645d1b3 Mon Sep 17 00:00:00 2001 From: Bart Butler Date: Fri, 22 Dec 2017 22:17:36 -0800 Subject: [PATCH] add null string test --- test/general/openpgp.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/general/openpgp.js b/test/general/openpgp.js index bffa4608..c7d0b904 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -917,6 +917,27 @@ describe('OpenPGP.js public api tests', function() { }); }); + it('should fail to verify decrypted null string with wrong public pgp key', function() { + var encOpt = { + data: '', + publicKeys: publicKey.keys, + privateKeys: privateKey.keys + }; + var decOpt = { + privateKey: privateKey.keys[0], + publicKeys: openpgp.key.readArmored(wrong_pubkey).keys + }; + return openpgp.encrypt(encOpt).then(function(encrypted) { + decOpt.message = openpgp.message.readArmored(encrypted.data); + return openpgp.decrypt(decOpt); + }).then(function(decrypted) { + expect(decrypted.data).to.equal(''); + expect(decrypted.signatures[0].valid).to.be.null; + expect(decrypted.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex()); + expect(decrypted.signatures[0].signature.packets.length).to.equal(1); + }); + }); + it('should successfully decrypt signed message without public keys to verify', function() { var encOpt = { data: plaintext,