tests
This commit is contained in:
parent
50940b2a1e
commit
b9d175d998
|
@ -41,7 +41,7 @@ export default {
|
|||
integrity_protect: true, // use integrity protection for symmetric encryption
|
||||
ignore_mdc_error: false, // fail on decrypt if message is not integrity protected
|
||||
checksum_required: false, // do not throw error when armor is missing a checksum
|
||||
verify_expired_keys: false, // allow signature verification with expired keys
|
||||
verify_expired_keys: true, // allow signature verification with expired keys
|
||||
rsa_blinding: true,
|
||||
use_native: true, // use native node.js crypto and Web Crypto apis (if available)
|
||||
zero_copy: false, // use transferable objects between the Web Worker and main thread
|
||||
|
|
|
@ -299,11 +299,10 @@ Key.prototype.armor = function() {
|
|||
*/
|
||||
Key.prototype.getSigningKeyPacket = function(keyId, allowExpired=false) {
|
||||
var primaryUser = this.getPrimaryUser(allowExpired);
|
||||
var verifyStatus = this.verifyPrimaryKey(allowExpired);
|
||||
if (primaryUser &&
|
||||
isValidSigningKeyPacket(this.primaryKey, primaryUser.selfCertificate) &&
|
||||
(!keyId || this.primaryKey.getKeyId().equals(keyId)) &&
|
||||
verifyStatus === enums.keyStatus.valid) {
|
||||
this.verifyPrimaryKey(allowExpired) === enums.keyStatus.valid) {
|
||||
return this.primaryKey;
|
||||
}
|
||||
if (this.subKeys) {
|
||||
|
@ -924,11 +923,11 @@ SubKey.prototype.isValidEncryptionKey = function(primaryKey) {
|
|||
/**
|
||||
* Returns true if the subkey can be used for signing of data
|
||||
* @param {module:packet/secret_key|module:packet/public_key} primaryKey The primary key packet
|
||||
* @param {Boolean} allowExpired allows signature verification with expired keys
|
||||
* @return {Boolean}
|
||||
*/
|
||||
SubKey.prototype.isValidSigningKey = function(primaryKey) {
|
||||
var verifyStatus = this.verify(primaryKey, config.verify_expired_keys);
|
||||
if(verifyStatus !== enums.keyStatus.valid) {
|
||||
SubKey.prototype.isValidSigningKey = function(primaryKey, allowExpired=false) {
|
||||
if(this.verify(primaryKey, allowExpired) !== enums.keyStatus.valid) {
|
||||
return false;
|
||||
}
|
||||
for(var i = 0; i < this.bindingSignatures.length; i++) {
|
||||
|
|
|
@ -257,6 +257,83 @@ describe("Signature", function() {
|
|||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var pub_expired =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Comment: GPGTools - https://gpgtools.org',
|
||||
'',
|
||||
'mQINBFpcwc8BEAC3ywtlTJ1inmifeTrC85b2j+WRySworAUKobk/jmswSoLt720R',
|
||||
'1J211Uu7IW7UBReoEhfNq+M0CAaoTxT7XPvd2O8lyn/RMAlnmFC0x3pyGrRYyRFd',
|
||||
'ZuGaWsFdHT/hCOeXOHv7sV/UWjL4wfeSlGqGWzHy4QH718HOQciZ7UHcS5J9B09W',
|
||||
't4TWcY+rTwl2GoFWLBHYCZZLnsQhvJqUTEHc63j+WV5M6oPNDNzqXa545ktss4Bq',
|
||||
'L7efeMtAThDlMg4vmodNkHYu0g+RqsGb1kwBkCznrNpYNETqgalhn5fZ6uV2RaDR',
|
||||
'WwFOm7ujGwQCzLSHcoDh4zqtWKkImMBEnwTFo0GTgXTTz0T565l5uqUvZ9UkJLXc',
|
||||
'IKWpfzHPUPOCstTaVNcCiTw+nwu4BvvOVgOWridKirpxks9uvihnzcAyR5ey212q',
|
||||
'HkFW1464qss4b9b4W399/KbOQ8Ngr1kUUeAoK13x7QKTmTwjE1Qt66370nFjk9Go',
|
||||
'k0Z0Of90oxQXx2/8g4gufpoMloTNdK/pMzPd+KfePpiVKoxmFTWOqmYgiX/4YcKi',
|
||||
'nQsJf++D9xsmAN6v9Ay1RqKmxiJgcuDvqcZ+FJdGatlpKfyEEsDRjAtMXSgw3BpH',
|
||||
'xsfPViEsVblmSQBPvuloKbp8kNPsJe3MW0fLSWjSuNDppx+OJX6xq1MNkQARAQAB',
|
||||
'tBlzdW5ueSA8c3VubnlAc3Vubnkuc3Vubnk+iQJUBBMBCgA+AhsDBQsJCAcDBRUK',
|
||||
'CQgLBRYCAwEAAh4BAhe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D0inC74',
|
||||
'5XZ36mUR2U0jLN0IaSAmQp+Dxh87S1SxhoA6qi0mYroSSngR68y880nq5xIgBjQr',
|
||||
'uoCHfcE/toiLkT8Zyjv7AMXsfuRFsW5VGkRuOceMgK+UPijEK/yAzbGTrj8hCrMM',
|
||||
'K/M0OXg9T1W2kzILkVjpj2PyY5MQjoWQEzFRbDrjdXHBuSvyf+SI02QvG2KdOuvv',
|
||||
'G6TOw3dj+jf1VgJBkNpt6NCIfXYQczuv8HSzqwtstQoHsIpdz7FjKaXR1fqr+Ikl',
|
||||
'1Ze66O/1dHY4rt0l0IoMxHL93P3plUiy7wflxuSwLthPybAu7I4QGPC8qP0vm2Cm',
|
||||
'2g==',
|
||||
'=X7/F',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var msg_sig_expired =
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Comment: GPGTools - https://gpgtools.org',
|
||||
'',
|
||||
'owEBWwKk/ZANAwAKAeyAexA3gWZ0AawUYgloZWxsby50eHRaX2WpaGVsbG+JAjME',
|
||||
'AAEKAB0WIQTxcIn7ZRrhwd51IZbsgHsQN4FmdAUCWl9lqQAKCRDsgHsQN4FmdCln',
|
||||
'D/44x1bcrOXg+DbRStSrC75wFa+cvPEmaTZyqN6d7qlQCMxOcPlq6lbZ74QWfEq7',
|
||||
'i1ZYHp4AU8jALw0QqBQQE5FvABleQKpVfY22s83Bqy+P0DB9ntpD+t+oZrxGCLmL',
|
||||
'MbZJNFnGro48gHt+/OQKLuftiVwE2opHfgogVKNL74FmYA0hMItdzpn4OPNFkP8t',
|
||||
'Iq/m0hkXlTAKqBPITVLv1FN16v+Sm1iC317eP/HOTYqVZdJN3svVF8ZBfg29a8p6',
|
||||
'6nl67fZhXgrt0OB6KSNIZEwMTWjFAqi365mtTssqAA0un94+cQ/WvAC5QcMM8g5S',
|
||||
'i3G7vny9AsXor+GDU1z7UDWs3wBV4mVRdj7bBIS6PK+6oe012aNpRObcI2bU2BT/',
|
||||
'H/7uHZWfwEmpfvH9RVZgoeETA3vSx7MDrNyDt3gwv2hxOHEd7nnVQ3EKG33173o1',
|
||||
'/5/oEmn2USujKGhHJ2Zo3aWNRuUWZlvBaYw+PwB2R0UiuJbi0KofNYPssNdpw4sg',
|
||||
'Qs7Nb2/Ilo1zn5bDh+WDrUrn6zHKAfBytBPpwPFWPZ8W10HUlC5vMZSKH5/UZhj5',
|
||||
'kLlUC1zKjFPpRhO27ImTJuImil4lR2/CFjB1duG3JGJQaYIq8RFJOjvTVY29wl0i',
|
||||
'pFy6y1Ofv2lLHB9K7N7dvvee2nvpUMkLEL52oFQ6Jc7sdg==',
|
||||
'=Q4tk',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
it('Testing signature checking on CAST5-enciphered message', function() {
|
||||
var priv_key = openpgp.key.readArmored(priv_key_arm1).keys[0];
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm1).keys[0];
|
||||
|
@ -583,6 +660,32 @@ describe("Signature", function() {
|
|||
|
||||
});
|
||||
|
||||
it('Verify test with expired verification public key and verify_expired_keys set to false', function() {
|
||||
openpgp.config.verify_expired_keys = false;
|
||||
var pubKey = openpgp.key.readArmored(pub_expired).keys[0];
|
||||
var message = openpgp.message.readArmored(msg_sig_expired);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:message }).then(function(verified) {
|
||||
expect(verified).to.exist;
|
||||
expect(verified.signatures).to.have.length(1);
|
||||
expect(verified.signatures[0].valid).to.not.be.true;
|
||||
expect(verified.signatures[0].signature.packets.length).to.equal(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('Verify test with expired verification public key and verify_expired_keys set to true', function() {
|
||||
openpgp.config.verify_expired_keys = true;
|
||||
var pubKey = openpgp.key.readArmored(pub_expired).keys[0];
|
||||
var message = openpgp.message.readArmored(msg_sig_expired);
|
||||
return openpgp.verify({ publicKeys:[pubKey], message:message }).then(function(verified) {
|
||||
expect(verified).to.exist;
|
||||
expect(verified.signatures).to.have.length(1);
|
||||
expect(verified.signatures[0].valid).to.be.true;
|
||||
expect(verified.signatures[0].signature.packets.length).to.equal(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('Verify primary key revocation signature', function(done) {
|
||||
var pubKey = openpgp.key.readArmored(pub_revoked).keys[0];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user