1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 10:52:17 -05:00

Use same signatures structure openpgp.js for clearSignedSignatures as detached

This commit is contained in:
Tankred Hase 2014-07-07 11:58:41 +02:00
parent 2b1ff2347c
commit 1b8e662769
2 changed files with 16 additions and 9 deletions

View File

@ -92,18 +92,25 @@ CleartextMessage.prototype.verify = function(keys) {
var literalDataPacket = new packet.Literal(); var literalDataPacket = new packet.Literal();
// we assume that cleartext signature is generated based on UTF8 cleartext // we assume that cleartext signature is generated based on UTF8 cleartext
literalDataPacket.setText(this.text); literalDataPacket.setText(this.text);
keys.forEach(function(key) { for (var i = 0; i < signatureList.length; i++) {
for (var i = 0; i < signatureList.length; i++) { var keyPacket = null;
var keyPacket = key.getKeyPacket([signatureList[i].issuerKeyId]); for (var j = 0; j < keys.length; j++) {
keyPacket = keys[j].getKeyPacket([signatureList[i].issuerKeyId]);
if (keyPacket) { if (keyPacket) {
var verifiedSig = {};
verifiedSig.keyid = signatureList[i].issuerKeyId;
verifiedSig.valid = signatureList[i].verify(keyPacket, literalDataPacket);
result.push(verifiedSig);
break; break;
} }
} }
});
var verifiedSig = {};
if (keyPacket) {
verifiedSig.keyid = signatureList[i].issuerKeyId;
verifiedSig.valid = signatureList[i].verify(keyPacket, literalDataPacket);
} else {
verifiedSig.keyid = signatureList[i].issuerKeyId;
verifiedSig.valid = null;
}
result.push(verifiedSig);
}
return result; return result;
}; };

View File

@ -377,7 +377,7 @@ define(function(require) {
done(); done();
}); });
}); });
it.skip('should be null for wrong public key', function(done) { it('should be null for wrong public key', function(done) {
pgp.verifyClearSignedMessage(clearsigned, wrongPubkey, function(err, signaturesValid) { pgp.verifyClearSignedMessage(clearsigned, wrongPubkey, function(err, signaturesValid) {
expect(err).to.not.exist; expect(err).to.not.exist;
expect(signaturesValid).to.be.null; expect(signaturesValid).to.be.null;