Port general tests to chai/mocha
This commit is contained in:
parent
8449062191
commit
e5e1675615
|
@ -1464,7 +1464,7 @@ var config = function() {
|
|||
this.integrity_protect = true;
|
||||
this.keyserver = "keyserver.linux.it"; // "pgp.mit.edu:11371"
|
||||
|
||||
this.versionstring = "OpenPGP.js v0.0.1.20131222";
|
||||
this.versionstring = "OpenPGP.js VERSION";
|
||||
this.commentstring = "http://openpgpjs.org";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
require('./ci-quick.js');
|
||||
require('./general');
|
||||
|
|
|
@ -1,148 +1,203 @@
|
|||
var unit = require('../unit.js');
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
unit.register("Key generation/encryption/decryption", function() {
|
||||
var openpgp = require('openpgp');
|
||||
var result = [];
|
||||
var testHelper = function(passphrase, userid, message) {
|
||||
var key = openpgp.generateKeyPair(openpgp.enums.publicKey.rsa_encrypt_sign, 512,
|
||||
userid, passphrase);
|
||||
'use strict';
|
||||
|
||||
var info = '\npassphrase: ' + passphrase + '\n'
|
||||
+ 'userid: ' + userid + '\n'
|
||||
+ 'message: ' + message;
|
||||
var expect = chai.expect;
|
||||
|
||||
var privKey = openpgp.key.readArmored(key.privateKeyArmored).keys[0];
|
||||
describe('Basic tests', function() {
|
||||
|
||||
var encrypted = openpgp.encryptMessage([privKey], message);
|
||||
describe("Key generation/encryption/decryption", function() {
|
||||
var testHelper = function(passphrase, userid, message) {
|
||||
var key = openpgp.generateKeyPair(openpgp.enums.publicKey.rsa_encrypt_sign, 512, userid, passphrase);
|
||||
expect(key).to.exist;
|
||||
expect(key.key).to.exist;
|
||||
expect(key.privateKeyArmored).to.exist;
|
||||
expect(key.publicKeyArmored).to.exist;
|
||||
|
||||
var msg = openpgp.message.readArmored(encrypted);
|
||||
var info = '\npassphrase: ' + passphrase + '\n' + 'userid: ' + userid + '\n' + 'message: ' + message;
|
||||
|
||||
var keyids = msg.getEncryptionKeyIds();
|
||||
var privKeys = openpgp.key.readArmored(key.privateKeyArmored);
|
||||
|
||||
privKey.decryptKeyPacket(keyids, passphrase);
|
||||
expect(privKeys).to.exist;
|
||||
expect(privKeys.err).to.not.exist;
|
||||
expect(privKeys.keys).to.have.length(1);
|
||||
|
||||
var privKey = privKeys.keys[0];
|
||||
|
||||
expect(privKey).to.exist;
|
||||
|
||||
var encrypted = openpgp.encryptMessage([privKey], message);
|
||||
|
||||
expect(encrypted).to.exist;
|
||||
|
||||
var msg = openpgp.message.readArmored(encrypted);
|
||||
|
||||
expect(msg).to.exist;
|
||||
|
||||
var keyids = msg.getEncryptionKeyIds();
|
||||
|
||||
expect(keyids).to.exist;
|
||||
|
||||
var success = privKey.decryptKeyPacket(keyids, passphrase);
|
||||
|
||||
expect(success).to.be.true;
|
||||
|
||||
try {
|
||||
var decrypted = openpgp.decryptMessage(privKey, msg);
|
||||
return new unit.result(message + ' == ' + decrypted + info, message == decrypted);
|
||||
} catch (e) {
|
||||
return new unit.result("Exception on decrypt of private key packet!" + info, false);
|
||||
}
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(message);
|
||||
};
|
||||
|
||||
};
|
||||
it('ASCII Text', function (done) {
|
||||
testHelper('password', 'Test McTestington <test@example.com>', 'hello world');
|
||||
done();
|
||||
});
|
||||
it('Unicode Text', function (done) {
|
||||
testHelper('●●●●', '♔♔♔♔ <test@example.com>', 'łäóć');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
result.push(testHelper('password', 'Test McTestington <test@example.com>', 'hello world'));
|
||||
result.push(testHelper('●●●●', '♔♔♔♔ <test@example.com>', 'łäóć'));
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
unit.register("Message encryption/decryption", function() {
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
var result = [];
|
||||
|
||||
var pub_key =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'',
|
||||
'mI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ck0X',
|
||||
'W748sl/tc3qiKPMJ+0AkMF7Pjhmh9nxqE9+QCEl7qinFqqBLjuzgUhBU4QlwX1GD',
|
||||
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
||||
'hz3tYjKhoFTKEIq3y3Pp',
|
||||
'=h/aX',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
var priv_key =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'Pwd: hello world',
|
||||
'',
|
||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||
'/nyBej9vZSRcaW5VpNNj0iA+c1/w2FPf84zNsTzvDmuMaNHFUzky4/vkYuZra//3',
|
||||
'+Ri7CF8RawSYQ/4IRbC9zqdBlzniyfQOW7Dp/LYe8eibnDSrmkQem0G0jwARAQAB',
|
||||
'/gMDAu7L//czBpE40p1ZqO8K3k7UejemjsQqc7kOqnlDYd1Z6/3NEA/UM30Siipr',
|
||||
'KjdIFY5+hp0hcs6EiiNq0PDfm/W2j+7HfrZ5kpeQVxDek4irezYZrl7JS2xezaLv',
|
||||
'k0Fv/6fxasnFtjOM6Qbstu67s5Gpl9y06ZxbP3VpT62+Xeibn/swWrfiJjuGEEhM',
|
||||
'bgnsMpHtzAz/L8y6KSzViG/05hBaqrvk3/GeEA6nE+o0+0a6r0LYLTemmq6FbaA1',
|
||||
'PHo+x7k7oFcBFUUeSzgx78GckuPwqr2mNfeF+IuSRnrlpZl3kcbHASPAOfEkyMXS',
|
||||
'sWGE7grCAjbyQyM3OEXTSyqnehvGS/1RdB6kDDxGwgE/QFbwNyEh6K4eaaAThW2j',
|
||||
'IEEI0WEnRkPi9fXyxhFsCLSI1XhqTaq7iDNqJTxE+AX2b9ZuZX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ZJzCJhFaQ9dp+2EnjN5auNCNbaI',
|
||||
'beFJRHFf9cha8p3hh+AK54NRCT++B2MXYf+TPwqX88jYMBv8kk8vYUgo8128r1zQ',
|
||||
'EzjviQE9BBgBAgAJBQJSYS9OAhsuAKgJEEpjYTpNbkCUnSAEGQECAAYFAlJhL04A',
|
||||
'CgkQ4IT3RGwgLJe6ogQA2aaJEIBIXtgrs+8WSJ4k3DN4rRXcXaUZf667pjdD9nF2',
|
||||
'3BzjFH6Z78JIGaxRHJdM7b05aE8YuzM8f3NIlT0F0OLq/TI2muYU9f/U2DQBuf+w',
|
||||
'KTB62+PELVgi9MsXC1Qv/u/o1LZtmmxTFFOD35xKsxZZI2OJj2pQpqObW27M8Nlc',
|
||||
'BQQAw2YA3fFc38qPK+PY4rZyTRdbvjyyX+1zeqIo8wn7QCQwXs+OGaH2fGoT35AI',
|
||||
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||
'=lw5e',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
|
||||
var key = openpgp.key.readArmored(pub_key).keys[0];
|
||||
|
||||
var encrypted = openpgp.encryptMessage([key], plaintext);
|
||||
|
||||
var message = openpgp.message.readArmored(encrypted);
|
||||
|
||||
var privKey = openpgp.key.readArmored(priv_key).keys[0];
|
||||
|
||||
// get key IDs the message is encrypted for
|
||||
var keyids = message.getEncryptionKeyIds();
|
||||
|
||||
// decrypt only required key packets
|
||||
var success = privKey.decryptKeyPacket(keyids, 'hello what?')
|
||||
|
||||
result.push(new unit.result('Decrypting key packet with wrong password returns false', !success));
|
||||
|
||||
var decrypted, error;
|
||||
try {
|
||||
decrypted = openpgp.decryptMessage(privKey, message);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
result.push(new unit.result('Calling decryptMessage with not decrypted key packet leads to exception: \'' + (error || '') + '\'', error));
|
||||
|
||||
success = privKey.decryptKeyPacket(keyids, 'hello world');
|
||||
|
||||
result.push(new unit.result('Decrypting key packet with correct password returns true', success));
|
||||
|
||||
decrypted = openpgp.decryptMessage(privKey, message);
|
||||
|
||||
result.push(new unit.result('Encrypt plain text and afterwards decrypt leads to same result', plaintext == decrypted));
|
||||
|
||||
return result;
|
||||
describe("Message encryption/decryption", function() {
|
||||
var pub_key =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'',
|
||||
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
||||
'fIF6P29lJFxpblWk02PSID5zX/DYU9/zjM2xPO8Oa4xo0cVTOTLj++Ri5mtr//f5',
|
||||
'GLsIXxFrBJhD/ghFsL3Op0GXOeLJ9A5bsOn8th7x6JucNKuaRB6bQbSPABEBAAG0',
|
||||
'JFRlc3QgTWNUZXN0aW5ndG9uIDx0ZXN0QGV4YW1wbGUuY29tPoi5BBMBAgAjBQJS',
|
||||
'YS9OAhsvBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQSmNhOk1uQJQwDAP6',
|
||||
'AgrTyqkRlJVqz2pb46TfbDM2TDF7o9CBnBzIGoxBhlRwpqALz7z2kxBDmwpQa+ki',
|
||||
'Bq3jZN/UosY9y8bhwMAlnrDY9jP1gdCo+H0sD48CdXybblNwaYpwqC8VSpDdTndf',
|
||||
'9j2wE/weihGp/DAdy/2kyBCaiOY1sjhUfJ1GogF49rC4jQRSYS9OAQQA6R/PtBFa',
|
||||
'JaT4jq10yqASk4sqwVMsc6HcifM5lSdxzExFP74naUMMyEsKHP53QxTF0Grqusag',
|
||||
'Qg/ZtgT0CN1HUM152y7ACOdp1giKjpMzOTQClqCoclyvWOFB+L/SwGEIJf7LSCEr',
|
||||
'woBuJifJc8xAVr0XX0JthoW+uP91eTQ3XpsAEQEAAYkBPQQYAQIACQUCUmEvTgIb',
|
||||
'LgCoCRBKY2E6TW5AlJ0gBBkBAgAGBQJSYS9OAAoJEOCE90RsICyXuqIEANmmiRCA',
|
||||
'SF7YK7PvFkieJNwzeK0V3F2lGX+uu6Y3Q/Zxdtwc4xR+me/CSBmsURyXTO29OWhP',
|
||||
'GLszPH9zSJU9BdDi6v0yNprmFPX/1Ng0Abn/sCkwetvjxC1YIvTLFwtUL/7v6NS2',
|
||||
'bZpsUxRTg9+cSrMWWSNjiY9qUKajm1tuzPDZXAUEAMNmAN3xXN/Kjyvj2OK2ck0X',
|
||||
'W748sl/tc3qiKPMJ+0AkMF7Pjhmh9nxqE9+QCEl7qinFqqBLjuzgUhBU4QlwX1GD',
|
||||
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
||||
'hz3tYjKhoFTKEIq3y3Pp',
|
||||
'=h/aX',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
var priv_key =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'Pwd: hello world',
|
||||
'',
|
||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||
'/nyBej9vZSRcaW5VpNNj0iA+c1/w2FPf84zNsTzvDmuMaNHFUzky4/vkYuZra//3',
|
||||
'+Ri7CF8RawSYQ/4IRbC9zqdBlzniyfQOW7Dp/LYe8eibnDSrmkQem0G0jwARAQAB',
|
||||
'/gMDAu7L//czBpE40p1ZqO8K3k7UejemjsQqc7kOqnlDYd1Z6/3NEA/UM30Siipr',
|
||||
'KjdIFY5+hp0hcs6EiiNq0PDfm/W2j+7HfrZ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ok2E8R9/4VS0490xKZIa5y2I/K8thVhqk96Z8Kbt7MRMC1WLHgC',
|
||||
'qJvkeQCI6PrFM0PUIPLHAQtDJYKtaLXxYuexcAdKzZj3FHdtLNWCooK6n3vJlL1c',
|
||||
'WjZcHJ1PH7USlj1jup4XfxsbziuysRUSyXkjn92GZLm+64vCIiwhqAYoizF2NHHG',
|
||||
'hRTN4gQzxrxgkeVchl+ag7DkQUDANIIVI+A63JeLJgWJiH1fbYlwESByHW+zBFNt',
|
||||
'qStjfIOhjrfNIc3RvsggbDdWQLcbxmLZj4sB0ydPSgRKoaUdRHJY0S4vp9ouKOtl',
|
||||
'2au/P1BP3bhD0fDXl91oeheYth+MSmsJFDg/vZJzCJhFaQ9dp+2EnjN5auNCNbaI',
|
||||
'beFJRHFf9cha8p3hh+AK54NRCT++B2MXYf+TPwqX88jYMBv8kk8vYUgo8128r1zQ',
|
||||
'EzjviQE9BBgBAgAJBQJSYS9OAhsuAKgJEEpjYTpNbkCUnSAEGQECAAYFAlJhL04A',
|
||||
'CgkQ4IT3RGwgLJe6ogQA2aaJEIBIXtgrs+8WSJ4k3DN4rRXcXaUZf667pjdD9nF2',
|
||||
'3BzjFH6Z78JIGaxRHJdM7b05aE8YuzM8f3NIlT0F0OLq/TI2muYU9f/U2DQBuf+w',
|
||||
'KTB62+PELVgi9MsXC1Qv/u/o1LZtmmxTFFOD35xKsxZZI2OJj2pQpqObW27M8Nlc',
|
||||
'BQQAw2YA3fFc38qPK+PY4rZyTRdbvjyyX+1zeqIo8wn7QCQwXs+OGaH2fGoT35AI',
|
||||
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||
'=lw5e',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
|
||||
var privKey, message, keyids;
|
||||
|
||||
it('Test initialization', function (done) {
|
||||
var pubKeys = openpgp.key.readArmored(pub_key);
|
||||
|
||||
expect(pubKeys).to.exist;
|
||||
expect(pubKeys.err).to.not.exist;
|
||||
expect(pubKeys.keys).to.have.length(1);
|
||||
|
||||
var pubKey = pubKeys.keys[0];
|
||||
|
||||
expect(pubKey).to.exist;
|
||||
|
||||
var encrypted = openpgp.encryptMessage([pubKey], plaintext);
|
||||
|
||||
expect(encrypted).to.exist;
|
||||
|
||||
message = openpgp.message.readArmored(encrypted);
|
||||
|
||||
expect(message).to.exist;
|
||||
|
||||
var privKeys = openpgp.key.readArmored(priv_key);
|
||||
|
||||
expect(privKeys).to.exist;
|
||||
expect(privKeys.err).to.not.exist;
|
||||
expect(privKeys.keys).to.have.length(1);
|
||||
|
||||
privKey = privKeys.keys[0];
|
||||
|
||||
expect(privKey).to.exist;
|
||||
|
||||
// get key IDs the message is encrypted for
|
||||
keyids = message.getEncryptionKeyIds();
|
||||
|
||||
expect(keyids).to.exist;
|
||||
expect(keyids).to.have.length(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Decrypting key packet with wrong password returns false', function (done) {
|
||||
// decrypt only required key packets
|
||||
var success = privKey.decryptKeyPacket(keyids, 'hello what?');
|
||||
|
||||
expect(success).to.be.false;
|
||||
done();
|
||||
});
|
||||
|
||||
var decrypted, error;
|
||||
|
||||
it('Calling decryptMessage with not decrypted key packet leads to exception', function (done) {
|
||||
function exceptionTest() {
|
||||
decrypted = openpgp.decryptMessage(privKey, message);
|
||||
}
|
||||
|
||||
expect(exceptionTest).to.throw(Error);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Decrypting key packet with correct password returns true', function (done) {
|
||||
var success = privKey.decryptKeyPacket(keyids, 'hello world');
|
||||
|
||||
expect(success).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Encrypt plain text and afterwards decrypt leads to same result', function (done) {
|
||||
decrypted = openpgp.decryptMessage(privKey, message);
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
8
test/general/index.js
Normal file
8
test/general/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
describe('General tests', function () {
|
||||
require('./basic.js');
|
||||
require('./key.js');
|
||||
require('./keyring.js');
|
||||
require('./packet.js');
|
||||
require('./signature.js');
|
||||
});
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
var unit = require('../unit.js');
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
unit.register("Key testing", function() {
|
||||
var openpgp = require('openpgp');
|
||||
'use strict';
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
describe('Key tests', function() {
|
||||
var twoKeys =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
|
@ -218,49 +220,77 @@ unit.register("Key testing", function() {
|
|||
'=e8xo',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
it('Parsing armored text with two keys', function(done) {
|
||||
var pubKeys = openpgp.key.readArmored(twoKeys);
|
||||
expect(pubKeys).to.exist;
|
||||
expect(pubKeys.err).to.not.exist;
|
||||
expect(pubKeys.keys).to.have.length(2);
|
||||
expect(pubKeys.keys[0].getKeyPacket().getKeyId().toHex()).to.equal('4a63613a4d6e4094');
|
||||
expect(pubKeys.keys[1].getKeyPacket().getKeyId().toHex()).to.equal('dbf223e870534df4');
|
||||
done();
|
||||
});
|
||||
|
||||
it('Testing key ID and fingerprint for V3 and V4 keys', function(done) {
|
||||
var pubKeysV4 = openpgp.key.readArmored(twoKeys);
|
||||
expect(pubKeysV4).to.exist;
|
||||
expect(pubKeysV4.err).to.not.exist;
|
||||
expect(pubKeysV4.keys).to.have.length(2);
|
||||
|
||||
var tests = [function() {
|
||||
var pubKey = openpgp.key.readArmored(twoKeys);
|
||||
var verified = !pubKey.err && pubKey.keys.length == 2 &&
|
||||
pubKey.keys[0].getKeyPacket().getKeyId().toHex() == '4a63613a4d6e4094' &&
|
||||
pubKey.keys[1].getKeyPacket().getKeyId().toHex() == 'dbf223e870534df4';
|
||||
return new unit.result("Parsing armored text with two keys", verified);
|
||||
var pubKeyV4 = pubKeysV4.keys[0];
|
||||
expect(pubKeyV4).to.exist;
|
||||
|
||||
},function() {
|
||||
var pubKeyV4 = openpgp.key.readArmored(twoKeys).keys[0];
|
||||
var pubKeyV3 = openpgp.key.readArmored(pub_v3).keys[0];
|
||||
var verified = pubKeyV4.getKeyPacket().getKeyId().toHex() == '4a63613a4d6e4094' &&
|
||||
openpgp.util.hexstrdump(pubKeyV4.getKeyPacket().getFingerprint()) == 'f470e50dcb1ad5f1e64e08644a63613a4d6e4094' &&
|
||||
pubKeyV3.getKeyPacket().getKeyId().toHex() == 'e5b7a014a237ba9d' &&
|
||||
openpgp.util.hexstrdump(pubKeyV3.getKeyPacket().getFingerprint()) == 'a44fcee620436a443bc4913640ab3e49';
|
||||
var pubKeysV3 = openpgp.key.readArmored(pub_v3)
|
||||
|
||||
return new unit.result("Testing key ID and fingerprint for V3 and V4 keys", verified);
|
||||
expect(pubKeysV3).to.exist;
|
||||
expect(pubKeysV3.err).to.not.exist;
|
||||
expect(pubKeysV3.keys).to.have.length(1);
|
||||
|
||||
var pubKeyV3 = pubKeysV3.keys[0];
|
||||
expect(pubKeyV3).to.exist;
|
||||
|
||||
expect(pubKeyV4.getKeyPacket().getKeyId().toHex()).to.equal('4a63613a4d6e4094');
|
||||
expect(openpgp.util.hexstrdump(pubKeyV4.getKeyPacket().getFingerprint())).to.equal('f470e50dcb1ad5f1e64e08644a63613a4d6e4094');
|
||||
expect(pubKeyV3.getKeyPacket().getKeyId().toHex()).to.equal('e5b7a014a237ba9d');
|
||||
expect(openpgp.util.hexstrdump(pubKeyV3.getKeyPacket().getFingerprint())).to.equal('a44fcee620436a443bc4913640ab3e49');
|
||||
done();
|
||||
});
|
||||
|
||||
it('Testing key method getSubkeyPackets', function(done) {
|
||||
var pubKeys = openpgp.key.readArmored(pub_sig_test)
|
||||
|
||||
expect(pubKeys).to.exist;
|
||||
expect(pubKeys.err).to.not.exist;
|
||||
expect(pubKeys.keys).to.have.length(1);
|
||||
|
||||
var pubKey = pubKeys.keys[0];
|
||||
expect(pubKey).to.exist;
|
||||
|
||||
},function() {
|
||||
var pubKey = openpgp.key.readArmored(pub_sig_test).keys[0];
|
||||
var packetlist = new openpgp.packet.list();
|
||||
|
||||
packetlist.read(openpgp.armor.decode(pub_sig_test).data);
|
||||
|
||||
var subkeys = pubKey.getSubkeyPackets();
|
||||
var verified = subkeys.length == 2 &&
|
||||
subkeys[0].getKeyId().equals(packetlist[8].getKeyId()) &&
|
||||
subkeys[1].getKeyId().equals(packetlist[11].getKeyId());
|
||||
return new unit.result("Testing key method getSubkeyPackets", verified);
|
||||
expect(subkeys).to.exist;
|
||||
expect(subkeys).to.have.length(2);
|
||||
expect(subkeys[0].getKeyId().equals(packetlist[8].getKeyId())).to.be.true;
|
||||
expect(subkeys[1].getKeyId().equals(packetlist[11].getKeyId())).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify status of revoked subkey', function(done) {
|
||||
var pubKeys = openpgp.key.readArmored(pub_sig_test);
|
||||
expect(pubKeys).to.exist;
|
||||
expect(pubKeys.err).to.not.exist;
|
||||
expect(pubKeys.keys).to.have.length(1);
|
||||
|
||||
var pubKey = pubKeys.keys[0];
|
||||
expect(pubKey).to.exist;
|
||||
expect(pubKey.subKeys).to.exist;
|
||||
expect(pubKey.subKeys).to.have.length(2);
|
||||
|
||||
},function() {
|
||||
var pubKey = openpgp.key.readArmored(pub_sig_test).keys[0];
|
||||
var status = pubKey.subKeys[0].verify(pubKey.primaryKey);
|
||||
return new unit.result("Verify status of revoked subkey", status == openpgp.enums.keyStatus.revoked);
|
||||
|
||||
}];
|
||||
|
||||
var results = [];
|
||||
|
||||
for(var i in tests) {
|
||||
results.push(tests[i]());
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
expect(status).to.equal(openpgp.enums.keyStatus.revoked);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
var unit = require('../unit.js');
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
unit.register("Keyring testing", function() {
|
||||
var openpgp = require('openpgp');
|
||||
var keyringClass = new require('keyring');
|
||||
var keyring = new keyringClass();
|
||||
var result = [];
|
||||
'use strict';
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("Keyring testing", function() {
|
||||
var keyring = new (new require('keyring'))();
|
||||
|
||||
keyring.init();
|
||||
keyring.importKey([
|
||||
|
@ -49,14 +50,19 @@ unit.register("Keyring testing", function() {
|
|||
'=WaSx',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join("\n"));
|
||||
var signingKeyIds = msg2.getSigningKeyIds();
|
||||
var key = keyring.getKeysForKeyId(signingKeyIds[0].toHex());
|
||||
var verified = msg2.verify(key);
|
||||
result[2] = new unit.result("Testing keyring getKeysForKeyId method",
|
||||
key !== null &&
|
||||
key.length == 1 &&
|
||||
verified[0].valid);
|
||||
return result;
|
||||
|
||||
it('Testing keyring getKeysForKeyId method', function (done) {
|
||||
var signingKeyIds = msg2.getSigningKeyIds();
|
||||
var key = keyring.getKeysForKeyId(signingKeyIds[0].toHex());
|
||||
expect(key).to.exist;
|
||||
expect(key).to.have.length(1);
|
||||
|
||||
var verified = msg2.verify(key);
|
||||
expect(verified).to.exist;
|
||||
expect(verified).to.have.length(1);
|
||||
expect(verified[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
var unit = require('../unit.js');
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
unit.register("Packet testing", function() {
|
||||
'use strict';
|
||||
|
||||
var openpgp = require('openpgp');
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("Packet testing", function() {
|
||||
var armored_key =
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
|
@ -41,8 +42,7 @@ unit.register("Packet testing", function() {
|
|||
'=KXkj\n' +
|
||||
'-----END PGP PRIVATE KEY BLOCK-----';
|
||||
|
||||
|
||||
var tests = [function() {
|
||||
it('Symmetrically encrypted packet', function(done) {
|
||||
var message = new openpgp.packet.list();
|
||||
|
||||
var literal = new openpgp.packet.literal();
|
||||
|
@ -57,17 +57,16 @@ unit.register("Packet testing", function() {
|
|||
|
||||
enc.encrypt(algo, key);
|
||||
|
||||
|
||||
|
||||
var msg2 = new openpgp.packet.list();
|
||||
msg2.read(message.write());
|
||||
|
||||
msg2[0].decrypt(algo, key);
|
||||
|
||||
return new unit.result('Symmetrically encrypted packet',
|
||||
msg2[0].packets[0].data == literal.data);
|
||||
expect(msg2[0].packets[0].data).to.equal(literal.data);
|
||||
done();
|
||||
});
|
||||
|
||||
}, function() {
|
||||
it('Sym. encrypted integrity protected packet', function(done) {
|
||||
var key = '12345678901234567890123456789012',
|
||||
algo = 'aes256';
|
||||
|
||||
|
@ -80,19 +79,17 @@ unit.register("Packet testing", function() {
|
|||
enc.packets.push(literal);
|
||||
enc.encrypt(algo, key);
|
||||
|
||||
|
||||
|
||||
var msg2 = new openpgp.packet.list();
|
||||
msg2.read(msg.write());
|
||||
|
||||
msg2[0].decrypt(algo, key);
|
||||
|
||||
return new unit.result('Sym. encrypted integrity protected packet',
|
||||
msg2[0].packets[0].data == literal.data);
|
||||
|
||||
}, function() {
|
||||
|
||||
var msg =
|
||||
expect(msg2[0].packets[0].data).to.equal(literal.data);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Sym encrypted session key with a compressed packet', function(done) {
|
||||
var msg =
|
||||
'-----BEGIN PGP MESSAGE-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
'\n' +
|
||||
|
@ -101,8 +98,6 @@ unit.register("Packet testing", function() {
|
|||
'=VZ0/\n' +
|
||||
'-----END PGP MESSAGE-----';
|
||||
|
||||
|
||||
|
||||
var msgbytes = openpgp.armor.decode(msg).data;
|
||||
|
||||
var parsed = new openpgp.packet.list();
|
||||
|
@ -116,11 +111,11 @@ unit.register("Packet testing", function() {
|
|||
|
||||
var result = compressed.packets[0].data;
|
||||
|
||||
return new unit.result('Sym encrypted session key with a compressed packet',
|
||||
result == 'Hello world!\n');
|
||||
expect(result).to.equal('Hello world!\n');
|
||||
done();
|
||||
});
|
||||
|
||||
}, function() {
|
||||
|
||||
it('Public key encrypted symmetric key packet', function(done) {
|
||||
var rsa = new openpgp.crypto.publicKey.rsa(),
|
||||
mpi = rsa.generate(512, "10001")
|
||||
|
||||
|
@ -148,10 +143,12 @@ unit.register("Packet testing", function() {
|
|||
|
||||
msg2[0].decrypt({ mpi: mpi });
|
||||
|
||||
return new unit.result('Public key encrypted symmetric key packet',
|
||||
msg2[0].sessionKey == enc.sessionKey &&
|
||||
msg2[0].sessionKeyAlgorithm == enc.sessionKeyAlgorithm);
|
||||
}, function() {
|
||||
expect(msg2[0].sessionKey).to.equal(enc.sessionKey);
|
||||
expect(msg2[0].sessionKeyAlgorithm).to.equal(enc.sessionKeyAlgorithm);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Secret key packet (reading, unencrpted)', function(done) {
|
||||
var armored_key =
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
|
@ -174,7 +171,7 @@ unit.register("Packet testing", function() {
|
|||
'=lKiS\n' +
|
||||
'-----END PGP PRIVATE KEY BLOCK-----';
|
||||
|
||||
key = new openpgp.packet.list();
|
||||
var key = new openpgp.packet.list();
|
||||
key.read(openpgp.armor.decode(armored_key).data);
|
||||
key = key[0];
|
||||
|
||||
|
@ -190,10 +187,11 @@ unit.register("Packet testing", function() {
|
|||
|
||||
enc.decrypt(key);
|
||||
|
||||
return new unit.result('Secret key packet (reading, unencrpted)',
|
||||
enc.sessionKey == secret);
|
||||
}, function() {
|
||||
expect(enc.sessionKey).to.equal(secret);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Public key encrypted packet (reading, GPG)', function(done) {
|
||||
var armored_key =
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
|
@ -254,11 +252,11 @@ unit.register("Packet testing", function() {
|
|||
|
||||
var text = msg[1].packets[0].packets[0].data;
|
||||
|
||||
expect(text).to.equal('Hello world!');
|
||||
done();
|
||||
});
|
||||
|
||||
return new unit.result('Public key encrypted packet (reading, GPG)',
|
||||
text == 'Hello world!');
|
||||
}, function() {
|
||||
|
||||
it('Sym encrypted session key reading/writing', function(done) {
|
||||
var passphrase = 'hello',
|
||||
algo = 'aes256';
|
||||
|
||||
|
@ -287,11 +285,11 @@ unit.register("Packet testing", function() {
|
|||
var key2 = msg2[0].sessionKey;
|
||||
msg2[1].decrypt(msg2[0].sessionKeyAlgorithm, key2);
|
||||
|
||||
expect(msg2[1].packets[0].data).to.equal(literal.data);
|
||||
done();
|
||||
});
|
||||
|
||||
return new unit.result('Sym encrypted session key reading/writing',
|
||||
msg2[1].packets[0].data == literal.data);
|
||||
|
||||
}, function() {
|
||||
it('Secret key encryption/decryption test', function(done) {
|
||||
var armored_msg =
|
||||
'-----BEGIN PGP MESSAGE-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
|
@ -317,13 +315,11 @@ unit.register("Packet testing", function() {
|
|||
|
||||
var text = msg[1].packets[0].packets[0].data;
|
||||
|
||||
expect(text).to.equal('Hello world!');
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
return new unit.result('Secret key encryption/decryption test',
|
||||
text == 'Hello world!');
|
||||
}, function() {
|
||||
|
||||
|
||||
it('Secret key reading with signature verification.', function(done) {
|
||||
var key = new openpgp.packet.list();
|
||||
key.read(openpgp.armor.decode(armored_key).data);
|
||||
|
||||
|
@ -337,14 +333,14 @@ unit.register("Packet testing", function() {
|
|||
verified = verified && key[4].verify(key[0],
|
||||
{
|
||||
key: key[0],
|
||||
bind: key[3],
|
||||
})
|
||||
bind: key[3]
|
||||
});
|
||||
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
return new unit.result('Secret key reading with signature verification.',
|
||||
verified == true);
|
||||
}, function() {
|
||||
|
||||
it('Reading a signed, encrypted message.', function(done) {
|
||||
var armored_msg =
|
||||
'-----BEGIN PGP MESSAGE-----\n' +
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)\n' +
|
||||
|
@ -368,21 +364,18 @@ unit.register("Packet testing", function() {
|
|||
var msg = new openpgp.packet.list();
|
||||
msg.read(openpgp.armor.decode(armored_msg).data);
|
||||
|
||||
|
||||
msg[0].decrypt(key[3]);
|
||||
msg[1].decrypt(msg[0].sessionKeyAlgorithm, msg[0].sessionKey);
|
||||
|
||||
var payload = msg[1].packets[0].packets
|
||||
|
||||
|
||||
|
||||
var verified = payload[2].verify(key[0], payload[1]);
|
||||
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
return new unit.result('Reading a signed, encrypted message.',
|
||||
verified == true);
|
||||
}, function() {
|
||||
it('Writing and encryption of a secret key packet.', function(done) {
|
||||
var key = new openpgp.packet.list();
|
||||
key.push(new openpgp.packet.secret_key);
|
||||
|
||||
|
@ -408,11 +401,11 @@ unit.register("Packet testing", function() {
|
|||
key2.read(raw);
|
||||
key2[0].decrypt('hello');
|
||||
|
||||
|
||||
return new unit.result('Writing and encryptio of a secret key packet.',
|
||||
key[0].mpi.toString() == key2[0].mpi.toString());
|
||||
}, function() {
|
||||
expect(key[0].mpi.toString()).to.equal(key2[0].mpi.toString());
|
||||
done();
|
||||
});
|
||||
|
||||
it('Writing and verification of a signature packet.', function(done) {
|
||||
var key = new openpgp.packet.secret_key();
|
||||
|
||||
var rsa = new openpgp.crypto.publicKey.rsa,
|
||||
|
@ -449,22 +442,8 @@ unit.register("Packet testing", function() {
|
|||
signed2.read(raw);
|
||||
|
||||
var verified = signed2[1].verify(key, signed2[0]);
|
||||
|
||||
|
||||
return new unit.result('Writing and verification of a signature packet.',
|
||||
verified == true);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
tests.reverse();
|
||||
|
||||
var results = [];
|
||||
|
||||
for(var i in tests) {
|
||||
results.push(tests[i]());
|
||||
}
|
||||
|
||||
|
||||
return results;
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,76 +1,80 @@
|
|||
var unit = require('../unit.js');
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
unit.register("Signature testing", function() {
|
||||
var openpgp = require('openpgp');
|
||||
'use strict';
|
||||
|
||||
var priv_key_arm1 =
|
||||
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'lQHhBFERnrMRBADmM0hIfkI3yosjgbWo9v0Lnr3CCE+8KsMszgVS+hBu0XfGraKm',
|
||||
'ivcA2aaJimHqVYOP7gEnwFAxHBBpeTJcu5wzCFyJwEYqVeS3nnaIhBPplSF14Duf',
|
||||
'i6bB9RV7KxVAg6aunmM2tAutqC+a0y2rDaf7jkJoZ9gWJe2zI+vraD6fiwCgxvHo',
|
||||
'3IgULB9RqIqpLoMgXfcjC+cD/1jeJlKRm+n71ryYwT/ECKsspFz7S36z6q3XyS8Q',
|
||||
'QfrsUz2p1fbFicvJwIOJ8B20J/N2/nit4P0gBUTUxv3QEa7XCM/56/xrGkyBzscW',
|
||||
'AzBoy/AK9K7GN6z13RozuAS60F1xO7MQc6Yi2VU3eASDQEKiyL/Ubf/s/rkZ+sGj',
|
||||
'yJizBACtwCbQzA+z9XBZNUat5NPgcZz5Qeh1nwF9Nxnr6pyBv7tkrLh/3gxRGHqG',
|
||||
'063dMbUk8pmUcJzBUyRsNiIPDoEUsLjY5zmZZmp/waAhpREsnK29WLCbqLdpUors',
|
||||
'c1JJBsObkA1IM8TZY8YUmvsMEvBLCCanuKpclZZXqeRAeOHJ0v4DAwK8WfuTe5B+',
|
||||
'M2BOOeZbN8BpfiA1l//fMMHLRS3UvbLBv4P1+4SyvhyYTR7M76Q0xPc03MFOWHL+',
|
||||
'S9VumbQWVGVzdDIgPHRlc3QyQHRlc3QuY29tPohiBBMRAgAiBQJREZ6zAhsDBgsJ',
|
||||
'CAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRARJ5QDyxae+MXNAKCzWSDR3tMrTrDb',
|
||||
'TAri73N1Xb3j1ACfSl9y+SAah2q7GvmiR1+6+/ekqJGdAVgEURGesxAEANlpMZjW',
|
||||
'33jMxlKHDdyRFXtKOq8RreXhq00plorHbgz9zFEWm4VF53+E/KGnmHGyY5Cy8TKy',
|
||||
'ZjaueZZ9XuG0huZg5If68irFfNZtxdA26jv8//PdZ0Uj+X6J3RVa2peMLDDswTYL',
|
||||
'OL1ZO1fxdtDD40fdAiIZ1QyjwEG0APtz41EfAAMFBAC5/dtgBBPtHe8UjDBaUe4n',
|
||||
'NzHuUBBp6XE+H7eqHNFCuZAJ7yqJLGVHNIaQR419cNy08/OO/+YUQ7rg78LxjFiv',
|
||||
'CH7IzhfU+6yvELSbgRMicY6EnAP2GT+b1+MtFNa3lBGtBHcJla52c2rTAHthYZWk',
|
||||
'fT5R5DnJuQ2cJHBMS9HWyP4DAwK8WfuTe5B+M2C7a/YJSUv6SexdGCaiaTcAm6g/',
|
||||
'PvA6hw/FLzIEP67QcQSSTmhftQIwnddt4S4MyJJH3U4fJaFfYQ1zCniYJohJBBgR',
|
||||
'AgAJBQJREZ6zAhsMAAoJEBEnlAPLFp74QbMAn3V4857xwnO9/+vzIVnL93W3k0/8',
|
||||
'AKC8omYPPomN1E/UJFfXdLDIMi5LoA==',
|
||||
'=LSrW',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||
].join("\n");
|
||||
var pub_key_arm1 =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'mQGiBFERlw4RBAD6Bmcf2w1dtUmtCLkdxeqZLArk3vYoQAjdibxA3gXVyur7fsWb',
|
||||
'ro0jVbBHqOCtC6jDxE2l52NP9+tTlWeVMaqqNvUE47LSaPq2DGI8Wx1Rj6bF3mTs',
|
||||
'obYEwhGbGh/MhJnME9AHODarvk8AZbzo0+k1EwrBWF6dTUBPfqO7rGU2ewCg80WV',
|
||||
'x5pt3evj8rRK3jQ8SMKTNRsD/1PhTdxdZTdXARAFzcW1VaaruWW0Rr1+XHKKwDCz',
|
||||
'i7HE76SO9qjnQfZCZG75CdQxI0h8GFeN3zsDqmhob2iSz2aJ1krtjM+iZ1FBFd57',
|
||||
'OqCV6wmk5IT0RBN12ZzMS19YvzN/ONXHrmTZlKExd9Mh9RKLeVNw+bf6JsKQEzcY',
|
||||
'JzFkBACX9X+hDYchO/2hiTwx4iOO9Fhsuh7eIWumB3gt+aUpm1jrSbas/QLTymmk',
|
||||
'uZuQVXI4NtnlvzlNgWv4L5s5RU5WqNGG7WSaKNdcrvJZRC2dgbUJt04J5CKrWp6R',
|
||||
'aIYal/81Ut1778lU01PEt563TcQnUBlnjU5OR25KhfSeN5CZY7QUVGVzdCA8dGVz',
|
||||
'dEB0ZXN0LmNvbT6IYgQTEQIAIgUCURGXDgIbAwYLCQgHAwIGFQgCCQoLBBYCAwEC',
|
||||
'HgECF4AACgkQikDlZK/UvLSspgCfcNaOpTg1W2ucR1JwBbBGvaERfuMAnRgt3/rs',
|
||||
'EplqEakMckCtikEnpxYe',
|
||||
'=b2Ln',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join("\n");
|
||||
var msg_arm1 =
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'hQEOA1N4OCSSjECBEAP/diDJCQn4e88193PgqhbfAkohk9RQ0v0MPnXpJbCRTHKO',
|
||||
'8r9nxiAr/TQv4ZOingXdAp2JZEoE9pXxZ3r1UWew04czxmgJ8FP1ztZYWVFAWFVi',
|
||||
'Tj930TBD7L1fY/MD4fK6xjEG7z5GT8k4tn4mLm/PpWMbarIglfMopTy1M/py2cID',
|
||||
'/2Sj7Ikh3UFiG+zm4sViYc5roNbMy8ixeoKixxi99Mx8INa2cxNfqbabjblFyc0Z',
|
||||
'BwmbIc+ZiY2meRNI5y/tk0gRD7hT84IXGGl6/mH00bsX/kkWdKGeTvz8s5G8RDHa',
|
||||
'Za4HgLbXItkX/QarvRS9kvkD01ujHfj+1ZvgmOBttNfP0p8BQLIICqvg1eYD9aPB',
|
||||
'+GtOZ2F3+k5VyBL5yIn/s65SBjNO8Fqs3aL0x+p7s1cfUzx8J8a8nWpqq/qIQIqg',
|
||||
'ZJH6MZRKuQwscwH6NWgsSVwcnVCAXnYOpbHxFQ+j7RbF/+uiuqU+DFH/Rd5pik8b',
|
||||
'0Dqnp0yfefrkjQ0nuvubgB6Rv89mHpnvuJfFJRInpg4lrHwLvRwdpN2HDozFHcKK',
|
||||
'aOU=',
|
||||
'=4iGt',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join("\n");
|
||||
var expect = chai.expect;
|
||||
|
||||
var priv_key_arm2 =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
describe("Signature testing", function() {
|
||||
var priv_key_arm1 =
|
||||
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'lQHhBFERnrMRBADmM0hIfkI3yosjgbWo9v0Lnr3CCE+8KsMszgVS+hBu0XfGraKm',
|
||||
'ivcA2aaJimHqVYOP7gEnwFAxHBBpeTJcu5wzCFyJwEYqVeS3nnaIhBPplSF14Duf',
|
||||
'i6bB9RV7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
||||
'CH7IzhfU+6yvELSbgRMicY6EnAP2GT+b1+MtFNa3lBGtBHcJla52c2rTAHthYZWk',
|
||||
'fT5R5DnJuQ2cJHBMS9HWyP4DAwK8WfuTe5B+M2C7a/YJSUv6SexdGCaiaTcAm6g/',
|
||||
'PvA6hw/FLzIEP67QcQSSTmhftQIwnddt4S4MyJJH3U4fJaFfYQ1zCniYJohJBBgR',
|
||||
'AgAJBQJREZ6zAhsMAAoJEBEnlAPLFp74QbMAn3V4857xwnO9/+vzIVnL93W3k0/8',
|
||||
'AKC8omYPPomN1E/UJFfXdLDIMi5LoA==',
|
||||
'=LSrW',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||
].join("\n");
|
||||
|
||||
var pub_key_arm1 =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'mQGiBFERlw4RBAD6Bmcf2w1dtUmtCLkdxeqZLArk3vYoQAjdibxA3gXVyur7fsWb',
|
||||
'ro0jVbBHqOCtC6jDxE2l52NP9+tTlWeVMaqqNvUE47LSaPq2DGI8Wx1Rj6bF3mTs',
|
||||
'obYEwhGbGh/MhJnME9AHODarvk8AZbzo0+k1EwrBWF6dTUBPfqO7rGU2ewCg80WV',
|
||||
'x5pt3evj8rRK3jQ8SMKTNRsD/1PhTdxdZTdXARAFzcW1VaaruWW0Rr1+XHKKwDCz',
|
||||
'i7HE76SO9qjnQfZCZG75CdQxI0h8GFeN3zsDqmhob2iSz2aJ1krtjM+iZ1FBFd57',
|
||||
'OqCV6wmk5IT0RBN12ZzMS19YvzN/ONXHrmTZlKExd9Mh9RKLeVNw+bf6JsKQEzcY',
|
||||
'JzFkBACX9X+hDYchO/2hiTwx4iOO9Fhsuh7eIWumB3gt+aUpm1jrSbas/QLTymmk',
|
||||
'uZuQVXI4NtnlvzlNgWv4L5s5RU5WqNGG7WSaKNdcrvJZRC2dgbUJt04J5CKrWp6R',
|
||||
'aIYal/81Ut1778lU01PEt563TcQnUBlnjU5OR25KhfSeN5CZY7QUVGVzdCA8dGVz',
|
||||
'dEB0ZXN0LmNvbT6IYgQTEQIAIgUCURGXDgIbAwYLCQgHAwIGFQgCCQoLBBYCAwEC',
|
||||
'HgECF4AACgkQikDlZK/UvLSspgCfcNaOpTg1W2ucR1JwBbBGvaERfuMAnRgt3/rs',
|
||||
'EplqEakMckCtikEnpxYe',
|
||||
'=b2Ln',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join("\n");
|
||||
|
||||
var msg_arm1 =
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'hQEOA1N4OCSSjECBEAP/diDJCQn4e88193PgqhbfAkohk9RQ0v0MPnXpJbCRTHKO',
|
||||
'8r9nxiAr/TQv4ZOingXdAp2JZEoE9pXxZ3r1UWew04czxmgJ8FP1ztZYWVFAWFVi',
|
||||
'Tj930TBD7L1fY/MD4fK6xjEG7z5GT8k4tn4mLm/PpWMbarIglfMopTy1M/py2cID',
|
||||
'/2Sj7Ikh3UFiG+zm4sViYc5roNbMy8ixeoKixxi99Mx8INa2cxNfqbabjblFyc0Z',
|
||||
'BwmbIc+ZiY2meRNI5y/tk0gRD7hT84IXGGl6/mH00bsX/kkWdKGeTvz8s5G8RDHa',
|
||||
'Za4HgLbXItkX/QarvRS9kvkD01ujHfj+1ZvgmOBttNfP0p8BQLIICqvg1eYD9aPB',
|
||||
'+GtOZ2F3+k5VyBL5yIn/s65SBjNO8Fqs3aL0x+p7s1cfUzx8J8a8nWpqq/qIQIqg',
|
||||
'ZJH6MZRKuQwscwH6NWgsSVwcnVCAXnYOpbHxFQ+j7RbF/+uiuqU+DFH/Rd5pik8b',
|
||||
'0Dqnp0yfefrkjQ0nuvubgB6Rv89mHpnvuJfFJRInpg4lrHwLvRwdpN2HDozFHcKK',
|
||||
'aOU=',
|
||||
'=4iGt',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join("\n");
|
||||
|
||||
var priv_key_arm2 =
|
||||
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'Pwd: hello world',
|
||||
|
@ -109,10 +113,11 @@ unit.register("Signature testing", function() {
|
|||
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||
'=lw5e',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var pub_key_arm2 =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
var pub_key_arm2 =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'Type: RSA/RSA',
|
||||
'',
|
||||
|
@ -135,10 +140,11 @@ unit.register("Signature testing", function() {
|
|||
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
||||
'hz3tYjKhoFTKEIq3y3Pp',
|
||||
'=h/aX',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var pub_key_arm3 =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
var pub_key_arm3 =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'mQENBFKV0FUBCACtZliApy01KBGbGNB36YGH4lpr+5KoqF1I8A5IT0YeNjyGisOk',
|
||||
|
@ -167,10 +173,11 @@ var pub_key_arm3 =
|
|||
'znN6qtN5gMlGY1ofWDY+I02gO4qzaZ/FxRZfittCw7v5dmQYKot9qRi2Kx3Fvw+h',
|
||||
'ivFBpC4TWgppFBnJJnAsFXZJQcejMW4nEmOViRQXY8N8PepQmgsu',
|
||||
'=ummy',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var pub_revoked =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
var pub_revoked =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'mQENBFKpincBCADhZjIihK15f3l+j87JgeLp9eUTSbn+g3gOFSR73TOMyBHMPt8O',
|
||||
|
@ -219,10 +226,11 @@ var pub_revoked =
|
|||
'jgvGbcTzxnvrRmDevmJUdXBSAE11OYQuDGlhgFCU0o9cdX+k+QqP5wNycXhoJ+yk',
|
||||
'pMiJM+NJAQ==',
|
||||
'=ok+o',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
var pub_v3 =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
var pub_v3 =
|
||||
[ '-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: SKS 1.1.3',
|
||||
'',
|
||||
'mQENAy9J/w4AAAEIALBDDD4vWqG/Jg59ghhMYAa+E7ECCTv2At8hxsM5cMP8P9sMLjs+GMfD',
|
||||
|
@ -248,64 +256,66 @@ var pub_v3 =
|
|||
'O+Ag4qwKKH+y/ke9CeZL6AnrU9c0pux150dHsDeHtpTPyInkjgKI7BofprydvpiFNd0nlAi4',
|
||||
'J4SAEYr3q92Qn/IiKpnLgo6Ls/GFb7q6y1O/2LL8PC2zrYU=',
|
||||
'=eoGb',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join('\n');
|
||||
|
||||
|
||||
var tests = [function() {
|
||||
it('Testing signature checking on CAST5-enciphered message', function(done) {
|
||||
var priv_key = openpgp.key.readArmored(priv_key_arm1).keys[0];
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm1).keys[0];
|
||||
var msg = openpgp.message.readArmored(msg_arm1);
|
||||
priv_key.decrypt("abcd");
|
||||
var decrypted = openpgp.decryptAndVerifyMessage(priv_key, [pub_key], msg);
|
||||
var verified = decrypted && decrypted.signatures[0].valid;
|
||||
return new unit.result("Testing signature checking on CAST5-enciphered message",
|
||||
verified);
|
||||
|
||||
}, function() {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Testing GnuPG stripped-key extensions', function(done) {
|
||||
// exercises the GnuPG s2k type 1001 extension:
|
||||
// the secrets on the primary key have been stripped.
|
||||
var priv_key_gnupg_ext = openpgp.key.readArmored([
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'lQGqBFERnrMRBADmM0hIfkI3yosjgbWo9v0Lnr3CCE+8KsMszgVS+hBu0XfGraKm',
|
||||
'ivcA2aaJimHqVYOP7gEnwFAxHBBpeTJcu5wzCFyJwEYqVeS3nnaIhBPplSF14Duf',
|
||||
'i6bB9RV7KxVAg6aunmM2tAutqC+a0y2rDaf7jkJoZ9gWJe2zI+vraD6fiwCgxvHo',
|
||||
'3IgULB9RqIqpLoMgXfcjC+cD/1jeJlKRm+n71ryYwT/ECKsspFz7S36z6q3XyS8Q',
|
||||
'QfrsUz2p1fbFicvJwIOJ8B20J/N2/nit4P0gBUTUxv3QEa7XCM/56/xrGkyBzscW',
|
||||
'AzBoy/AK9K7GN6z13RozuAS60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',
|
||||
'=GQsY',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----',
|
||||
].join("\n")).keys[0];
|
||||
var priv_key_gnupg_ext = openpgp.key.readArmored(
|
||||
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'lQGqBFERnrMRBADmM0hIfkI3yosjgbWo9v0Lnr3CCE+8KsMszgVS+hBu0XfGraKm',
|
||||
'ivcA2aaJimHqVYOP7gEnwFAxHBBpeTJcu5wzCFyJwEYqVeS3nnaIhBPplSF14Duf',
|
||||
'i6bB9RV7KxVAg6aunmM2tAutqC+a0y2rDaf7jkJoZ9gWJe2zI+vraD6fiwCgxvHo',
|
||||
'3IgULB9RqIqpLoMgXfcjC+cD/1jeJlKRm+n71ryYwT/ECKsspFz7S36z6q3XyS8Q',
|
||||
'QfrsUz2p1fbFicvJwIOJ8B20J/N2/nit4P0gBUTUxv3QEa7XCM/56/xrGkyBzscW',
|
||||
'AzBoy/AK9K7GN6z13RozuAS60F1xO7MQc6Yi2VU3eASDQEKiyL/Ubf/s/rkZ+sGj',
|
||||
'yJizBACtwCbQzA+z9XBZNUat5NPgcZz5Qeh1nwF9Nxnr6pyBv7tkrLh/3gxRGHqG',
|
||||
'063dMbUk8pmUcJzBUyRsNiIPDoEUsLjY5zmZZmp/waAhpREsnK29WLCbqLdpUors',
|
||||
'c1JJBsObkA1IM8TZY8YUmvsMEvBLCCanuKpclZZXqeRAeOHJ0v4DZQJHTlUBtBZU',
|
||||
'ZXN0MiA8dGVzdDJAdGVzdC5jb20+iGIEExECACIFAlERnrMCGwMGCwkIBwMCBhUI',
|
||||
'AgkKCwQWAgMBAh4BAheAAAoJEBEnlAPLFp74xc0AoLNZINHe0ytOsNtMCuLvc3Vd',
|
||||
'vePUAJ9KX3L5IBqHarsa+aJHX7r796SokZ0BWARREZ6zEAQA2WkxmNbfeMzGUocN',
|
||||
'3JEVe0o6rxGt5eGrTSmWisduDP3MURabhUXnf4T8oaeYcbJjkLLxMrJmNq55ln1e',
|
||||
'4bSG5mDkh/ryKsV81m3F0DbqO/z/891nRSP5fondFVral4wsMOzBNgs4vVk7V/F2',
|
||||
'0MPjR90CIhnVDKPAQbQA+3PjUR8AAwUEALn922AEE+0d7xSMMFpR7ic3Me5QEGnp',
|
||||
'cT4ft6oc0UK5kAnvKoksZUc0hpBHjX1w3LTz847/5hRDuuDvwvGMWK8IfsjOF9T7',
|
||||
'rK8QtJuBEyJxjoScA/YZP5vX4y0U1reUEa0EdwmVrnZzatMAe2FhlaR9PlHkOcm5',
|
||||
'DZwkcExL0dbI/gMDArxZ+5N7kH4zYLtr9glJS/pJ7F0YJqJpNwCbqD8+8DqHD8Uv',
|
||||
'MgQ/rtBxBJJOaF+1AjCd123hLgzIkkfdTh8loV9hDXMKeJgmiEkEGBECAAkFAlER',
|
||||
'nrMCGwwACgkQESeUA8sWnvhBswCfdXjznvHCc73/6/MhWcv3dbeTT/wAoLyiZg8+',
|
||||
'iY3UT9QkV9d0sMgyLkug',
|
||||
'=GQsY',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||
].join("\n")).keys[0];
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm1).keys[0];
|
||||
var msg = openpgp.message.readArmored(msg_arm1);
|
||||
|
||||
priv_key_gnupg_ext.subKeys[0].subKey.decrypt("abcd");
|
||||
msg = msg.decrypt(priv_key_gnupg_ext);
|
||||
var verified = msg.verify([pub_key]);
|
||||
return new unit.result("Testing GnuPG stripped-key extensions",
|
||||
verified[0].valid);
|
||||
|
||||
}, function() {
|
||||
expect(verified).to.exist;
|
||||
expect(verified).to.have.length(1);
|
||||
expect(verified[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify V4 signature. Hash: SHA1. PK: RSA. Signature Type: 0x00 (binary document)', function(done) {
|
||||
var signedArmor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMwMT4oOW7S46CznTGNeZJLCWpFSVBU3ZGF2fkF5Uo5KYWFyemp3LlAUUV',
|
||||
|
@ -314,16 +324,21 @@ var pub_v3 =
|
|||
'cw6U57n3/Z4X0pEZ68C5/o/6NpPICD7fuEOz3936raZ6wXGzueY8pfPnVjY0ajAc',
|
||||
'PtJzvvqj+ubYaT1sK9wWhd9lL3/V+9Zuua9QjOWC22buchsCroh8fLoZAA==',
|
||||
'=VH8F',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
var sMsg = openpgp.message.readArmored(signedArmor);
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm2).keys[0];
|
||||
var verified = sMsg.verify([pub_key]);
|
||||
return new unit.result("Verify V4 signature. Hash: SHA1. PK: RSA. Signature Type: 0x00 (binary document)", verified[0].valid);
|
||||
}, function() {
|
||||
expect(verified).to.exist;
|
||||
expect(verified).to.have.length(1);
|
||||
expect(verified[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify V3 signature. Hash: MD5. PK: RSA. Signature Type: 0x01 (text document)', function(done) {
|
||||
var signedArmor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMyMj4oOW7S46CznTG09YlLCWpFSVBU47xFGfkF5Uo5KYWFyemp/Jy5QGF',
|
||||
|
@ -332,16 +347,21 @@ var pub_v3 =
|
|||
'aPJyvm9TTpobW/O+P1n2THLS4UCvWt12Oa2lJ04GLwk/bDF1u+8ZpfPCpsxLVzcs',
|
||||
'ZGtbq/f23XxV/jkL47hr3s3Ic4yoZTW4oZO27GYf37TPp9L3VboCAA==',
|
||||
'=pa6B',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
var sMsg = openpgp.message.readArmored(signedArmor);
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm2).keys[0];
|
||||
var verified = sMsg.verify([pub_key]);
|
||||
return new unit.result("Verify V3 signature. Hash: MD5. PK: RSA. Signature Type: 0x01 (text document)", verified[0].valid);
|
||||
}, function() {
|
||||
expect(verified).to.exist;
|
||||
expect(verified).to.have.length(1);
|
||||
expect(verified[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify signature of signed and encrypted message from GPG2 with openpgp.decryptAndVerifyMessage', function(done) {
|
||||
var msg_armor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'hIwD4IT3RGwgLJcBBADEBdm+GEW7IV1K/Bykg0nB0WYO08ai7/8/+Y/O9xu6RiU0',
|
||||
|
@ -354,7 +374,8 @@ var pub_v3 =
|
|||
'ifxyV4zia9RvaCUY8vXGM+gQJ3NNXx2LkZA3kWUEyxFVL1Vl/XUQY0M6U+uccSk4',
|
||||
'eMXm6eyEWDcj0lBRckqKoKo1w/uan11jPuHsnRz6jO9DsuKEz79UDgI=',
|
||||
'=cFi7',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
var esMsg = openpgp.message.readArmored(msg_armor);
|
||||
|
@ -365,27 +386,32 @@ var pub_v3 =
|
|||
privKey.decryptKeyPacket(keyids, 'hello world');
|
||||
|
||||
var decrypted = openpgp.decryptAndVerifyMessage(privKey, [pubKey], esMsg);
|
||||
var verified = decrypted.text == plaintext && decrypted.signatures[0].valid;
|
||||
|
||||
return new unit.result("Verify signature of signed and encrypted message from GPG2 with openpgp.decryptAndVerifyMessage", verified);
|
||||
}, function() {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted.text).to.equal(plaintext);
|
||||
expect(decrypted.signatures).to.have.length(1);
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify signature of signed and encrypted message from PGP 10.3.0 with openpgp.decryptAndVerifyMessage', function(done) {
|
||||
var msg_armor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: Encryption Desktop 10.3.0 (Build 9307)',
|
||||
'Charset: utf-8',
|
||||
'',
|
||||
'qANQR1DBjAPghPdEbCAslwED/2S4oNvCjO5TdLUMMUuVOQc8fi6c5XIBu7Y09fEX',
|
||||
'Jm/UrkDHVgmPojLGBDF0CYENNZOVrNfpahY7A3r4HPzGucBzCO1uxuUIKjhtNAAM',
|
||||
'mjD939ernjooOZrM6xDuRaX8adG0LSxpNaVJGxXd/EdlmKDJbYDI6aJ5INrUxzAR',
|
||||
'DAqw0sBSAXgRWgiH6IIiAo5y5WFEDEN9sGStaEQT2wd32kX73M4iZuMt/GM2agiB',
|
||||
'sWb7yLcNHiJ/3OnTfDg9+T543kFq9FlwFbwqygO/wm9e/kgMBq0ZsFOfV+GRtXep',
|
||||
'3qNbJsmzGvdqiUHb/+hkdE191jaSVcO/zaMW4N0Vc1IwIEhZ8I9+9bKwusdVhHT5',
|
||||
'MySnhIogv+0Ilag/aY+UiCt+Zcie69T7Eix48fC/VVW5w3INf1T2CMmDm5ZLZFRN',
|
||||
'oyqzb9Vsgu1gS7SCb6qTbnbV9PlSyU4wJB6siX8hz/U0urokT5se3uYRjiV0KbkA',
|
||||
'zl1/r/wCrmwX4Gl9VN9+33cQgYZAlJLsRw8N82GhbVweZS8qwv24GQ==',
|
||||
'=nx90',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: Encryption Desktop 10.3.0 (Build 9307)',
|
||||
'Charset: utf-8',
|
||||
'',
|
||||
'qANQR1DBjAPghPdEbCAslwED/2S4oNvCjO5TdLUMMUuVOQc8fi6c5XIBu7Y09fEX',
|
||||
'Jm/UrkDHVgmPojLGBDF0CYENNZOVrNfpahY7A3r4HPzGucBzCO1uxuUIKjhtNAAM',
|
||||
'mjD939ernjooOZrM6xDuRaX8adG0LSxpNaVJGxXd/EdlmKDJbYDI6aJ5INrUxzAR',
|
||||
'DAqw0sBSAXgRWgiH6IIiAo5y5WFEDEN9sGStaEQT2wd32kX73M4iZuMt/GM2agiB',
|
||||
'sWb7yLcNHiJ/3OnTfDg9+T543kFq9FlwFbwqygO/wm9e/kgMBq0ZsFOfV+GRtXep',
|
||||
'3qNbJsmzGvdqiUHb/+hkdE191jaSVcO/zaMW4N0Vc1IwIEhZ8I9+9bKwusdVhHT5',
|
||||
'MySnhIogv+0Ilag/aY+UiCt+Zcie69T7Eix48fC/VVW5w3INf1T2CMmDm5ZLZFRN',
|
||||
'oyqzb9Vsgu1gS7SCb6qTbnbV9PlSyU4wJB6siX8hz/U0urokT5se3uYRjiV0KbkA',
|
||||
'zl1/r/wCrmwX4Gl9VN9+33cQgYZAlJLsRw8N82GhbVweZS8qwv24GQ==',
|
||||
'=nx90',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말\n\n';
|
||||
var esMsg = openpgp.message.readArmored(msg_armor);
|
||||
|
@ -396,28 +422,33 @@ var pub_v3 =
|
|||
privKey.decryptKeyPacket(keyids, 'hello world');
|
||||
|
||||
var decrypted = openpgp.decryptAndVerifyMessage(privKey, [pubKey], esMsg);
|
||||
var verified = decrypted.text == plaintext && decrypted.signatures[0].valid;
|
||||
|
||||
return new unit.result("Verify signature of signed and encrypted message from PGP 10.3.0 with openpgp.decryptAndVerifyMessage", verified);
|
||||
}, function() {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted.text).to.equal(plaintext);
|
||||
expect(decrypted.signatures).to.have.length(1);
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify signed message with two one pass signatures', function(done) {
|
||||
var msg_armor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMwMF4+5Pyi4Jg3y8ME8DcBy3fXXIUdKYzrjFNYilJrSgJmsXDXJyRX1Si',
|
||||
'kJtaXJyYnsqVBxRVyMnMS+V6O3XOq61r30zbov9m4YY3LQteL5/QMYeFgZGDgY2V',
|
||||
'CaSRgYtTAGZiYxYLwySbQk07ptZel6gmjrKyBWsyWdkOG3oscLBdIpXXfDdb6fNv',
|
||||
'8ULN5L1ed+xNo79P2dBotWud6vn7e9dtLJ7o12PunnvEz8gyyvP4/As/los0xsnZ',
|
||||
'H+8ublrhvGtLxJUZuUKZO6QdHq2Nepuw8OrfiMXPBDQXXpV2q11Ze+rD3lndgv/C',
|
||||
'bJQNOhll0J0H839jFvt/16m20h/ZmDoWqJywapnypjdIjcXr+7rJFess40yenV7Q',
|
||||
'2LSu/EX6Aq29x+dv+GPUMfuhTNE3viWWUR4PD6T7XfmdViUwmSf8fkRNUn/t3a2n',
|
||||
'cq46Xr36seCor/OLp0atSZwHrjx2SU5zPLheZn+zw/0d1/YZnD7AEeP9s/Cuycyv',
|
||||
'CZ5HZNKufvB8fsh+dfdSXW0GfqkPfxk36Vw8ufpjaoZDyt2nxxg/6D4KS3UvZzv3',
|
||||
'axdLZ9yd0OJNZv4P501If24W4vTGz6nI7Ser8Yd2PiOvE5MWMT0wLZQ+zPX1sv0/',
|
||||
's8PvkyWmVM0O0fB/ZSHovHNNPffDg/rWhzOmXQ9/7vTn477F+aWm5sYzJ75/BQA=',
|
||||
'=+L0S',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
[ '-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMwMF4+5Pyi4Jg3y8ME8DcBy3fXXIUdKYzrjFNYilJrSgJmsXDXJyRX1Si',
|
||||
'kJtaXJyYnsqVBxRVyMnMS+V6O3XOq61r30zbov9m4YY3LQteL5/QMYeFgZGDgY2V',
|
||||
'CaSRgYtTAGZiYxYLwySbQk07ptZel6gmjrKyBWsyWdkOG3oscLBdIpXXfDdb6fNv',
|
||||
'8ULN5L1ed+xNo79P2dBotWud6vn7e9dtLJ7o12PunnvEz8gyyvP4/As/los0xsnZ',
|
||||
'H+8ublrhvGtLxJUZuUKZO6QdHq2Nepuw8OrfiMXPBDQXXpV2q11Ze+rD3lndgv/C',
|
||||
'bJQNOhll0J0H839jFvt/16m20h/ZmDoWqJywapnypjdIjcXr+7rJFess40yenV7Q',
|
||||
'2LSu/EX6Aq29x+dv+GPUMfuhTNE3viWWUR4PD6T7XfmdViUwmSf8fkRNUn/t3a2n',
|
||||
'cq46Xr36seCor/OLp0atSZwHrjx2SU5zPLheZn+zw/0d1/YZnD7AEeP9s/Cuycyv',
|
||||
'CZ5HZNKufvB8fsh+dfdSXW0GfqkPfxk36Vw8ufpjaoZDyt2nxxg/6D4KS3UvZzv3',
|
||||
'axdLZ9yd0OJNZv4P501If24W4vTGz6nI7Ser8Yd2PiOvE5MWMT0wLZQ+zPX1sv0/',
|
||||
's8PvkyWmVM0O0fB/ZSHovHNNPffDg/rWhzOmXQ9/7vTn477F+aWm5sYzJ75/BQA=',
|
||||
'=+L0S',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
var sMsg = openpgp.message.readArmored(msg_armor);
|
||||
|
@ -426,39 +457,44 @@ var pub_v3 =
|
|||
|
||||
var keyids = sMsg.getSigningKeyIds();
|
||||
|
||||
var verified = pubKey2.getPublicKeyPacket(keyids) !== null && pubKey3.getPublicKeyPacket(keyids) !== null;
|
||||
expect(pubKey2.getPublicKeyPacket(keyids)).to.exist;
|
||||
expect(pubKey3.getPublicKeyPacket(keyids)).to.exist;
|
||||
|
||||
verified = verified && sMsg.getText() == plaintext;
|
||||
expect(sMsg.getText()).to.equal(plaintext);
|
||||
|
||||
var verifiedSig = sMsg.verify([pubKey2, pubKey3]);
|
||||
|
||||
verified = verified && verifiedSig[0].valid && verifiedSig[1].valid;
|
||||
|
||||
return new unit.result("Verify signed message with two one pass signatures", verified);
|
||||
}, function() {
|
||||
expect(verifiedSig).to.exist;
|
||||
expect(verifiedSig).to.have.length(2);
|
||||
expect(verifiedSig[0].valid).to.be.true;
|
||||
expect(verifiedSig[1].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify cleartext signed message with two signatures with openpgp.verifyClearSignedMessage', function(done) {
|
||||
var msg_armor =
|
||||
['-----BEGIN PGP SIGNED MESSAGE-----',
|
||||
'Hash: SHA256',
|
||||
'',
|
||||
'short message',
|
||||
'next line',
|
||||
'한국어/조선말',
|
||||
'-----BEGIN PGP SIGNATURE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'iJwEAQEIAAYFAlKcju8ACgkQ4IT3RGwgLJci6gP/dCmIraUa6AGpJxzGfK+jYpjl',
|
||||
'G0KunFyGmyPxeJVnPi2bBp3EPIbiayQ71CcDe9DKpF046tora07AA9eo+/YbvJ9P',
|
||||
'PWeScw3oj/ejsmKQoDBGzyDMFUphevnhgc5lENjovJqmiu6FKjNmADTxcZ/qFTOq',
|
||||
'44EWTgdW3IqXFkNpKjeJARwEAQEIAAYFAlKcju8ACgkQ2/Ij6HBTTfQi6gf9HxhE',
|
||||
'ycLDhQ8iyC090TaYwsDytScU2vOMiI5rJCy2tfDV0pfn+UekYGMnKxZTpwtmno1j',
|
||||
'mVOlieENszz5IcehS5TYwk4lmRFjoba+Z8qwPEYhYxP29GMbmRIsH811sQHFTigo',
|
||||
'LI2t4pSSSUpAiXd9y6KtvkWcGGn8IfkNHCEHPh1ov28QvH0+ByIiKYK5N6ZB8hEo',
|
||||
'0uMYhKQPVJdPCvMkAxQCRPw84EvmxuJ0HMCeSB9tHQXpz5un2m8D9yiGpBQPnqlW',
|
||||
'vCCq7fgaUz8ksxvQ9bSwv0iIIbbBdTP7Z8y2c1Oof6NDl7irH+QCeNT7IIGs8Smn',
|
||||
'BEzv/FqkQAhjy3Krxg==',
|
||||
'=3Pkl',
|
||||
'-----END PGP SIGNATURE-----'].join('\n');
|
||||
[ '-----BEGIN PGP SIGNED MESSAGE-----',
|
||||
'Hash: SHA256',
|
||||
'',
|
||||
'short message',
|
||||
'next line',
|
||||
'한국어/조선말',
|
||||
'-----BEGIN PGP SIGNATURE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'iJwEAQEIAAYFAlKcju8ACgkQ4IT3RGwgLJci6gP/dCmIraUa6AGpJxzGfK+jYpjl',
|
||||
'G0KunFyGmyPxeJVnPi2bBp3EPIbiayQ71CcDe9DKpF046tora07AA9eo+/YbvJ9P',
|
||||
'PWeScw3oj/ejsmKQoDBGzyDMFUphevnhgc5lENjovJqmiu6FKjNmADTxcZ/qFTOq',
|
||||
'44EWTgdW3IqXFkNpKjeJARwEAQEIAAYFAlKcju8ACgkQ2/Ij6HBTTfQi6gf9HxhE',
|
||||
'ycLDhQ8iyC090TaYwsDytScU2vOMiI5rJCy2tfDV0pfn+UekYGMnKxZTpwtmno1j',
|
||||
'mVOlieENszz5IcehS5TYwk4lmRFjoba+Z8qwPEYhYxP29GMbmRIsH811sQHFTigo',
|
||||
'LI2t4pSSSUpAiXd9y6KtvkWcGGn8IfkNHCEHPh1ov28QvH0+ByIiKYK5N6ZB8hEo',
|
||||
'0uMYhKQPVJdPCvMkAxQCRPw84EvmxuJ0HMCeSB9tHQXpz5un2m8D9yiGpBQPnqlW',
|
||||
'vCCq7fgaUz8ksxvQ9bSwv0iIIbbBdTP7Z8y2c1Oof6NDl7irH+QCeNT7IIGs8Smn',
|
||||
'BEzv/FqkQAhjy3Krxg==',
|
||||
'=3Pkl',
|
||||
'-----END PGP SIGNATURE-----'
|
||||
].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
var csMsg = openpgp.cleartext.readArmored(msg_armor);
|
||||
|
@ -467,17 +503,20 @@ var pub_v3 =
|
|||
|
||||
var keyids = csMsg.getSigningKeyIds();
|
||||
|
||||
var verified = pubKey2.getPublicKeyPacket(keyids) !== null && pubKey3.getPublicKeyPacket(keyids) !== null;
|
||||
expect(pubKey2.getPublicKeyPacket(keyids)).to.exist;
|
||||
expect(pubKey3.getPublicKeyPacket(keyids)).to.exist;
|
||||
|
||||
var cleartextSig = openpgp.verifyClearSignedMessage([pubKey2, pubKey3], csMsg);
|
||||
|
||||
verified = verified && cleartextSig.text == plaintext;
|
||||
|
||||
verified = verified && cleartextSig.signatures[0].valid && cleartextSig.signatures[1].valid;
|
||||
|
||||
return new unit.result("Verify cleartext signed message with two signatures with openpgp.verifyClearSignedMessage", verified);
|
||||
}, function() {
|
||||
expect(cleartextSig).to.exist;
|
||||
expect(cleartextSig.text).to.equal(plaintext);
|
||||
expect(cleartextSig.signatures).to.have.length(2);
|
||||
expect(cleartextSig.signatures[0].valid).to.be.true;
|
||||
expect(cleartextSig.signatures[1].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Sign text with openpgp.signClearMessage and verify with openpgp.verifyClearSignedMessage leads to same cleartext and valid signatures', function(done) {
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0];
|
||||
var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0];
|
||||
|
@ -489,48 +528,46 @@ var pub_v3 =
|
|||
|
||||
var cleartextSig = openpgp.verifyClearSignedMessage([pubKey], csMsg);
|
||||
|
||||
var verified = cleartextSig.text == plaintext.replace(/\r/g,'');
|
||||
|
||||
verified = verified && cleartextSig.signatures[0].valid;
|
||||
|
||||
return new unit.result("Sign text with openpgp.signClearMessage and verify with openpgp.verifyClearSignedMessage leads to same cleartext and valid signatures", verified);
|
||||
}, function() {
|
||||
expect(cleartextSig).to.exist;
|
||||
expect(cleartextSig.text).to.equal(plaintext.replace(/\r/g,''));
|
||||
expect(cleartextSig.signatures).to.have.length(1);
|
||||
expect(cleartextSig.signatures[0].valid).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify primary key revocation signature', function(done) {
|
||||
var pubKey = openpgp.key.readArmored(pub_revoked).keys[0];
|
||||
|
||||
var verified = pubKey.revocationSignature.verify(pubKey.primaryKey, {key: pubKey.primaryKey});
|
||||
|
||||
return new unit.result("Verify primary key revocation signature", verified);
|
||||
}, function() {
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify subkey revocation signature', function(done) {
|
||||
var pubKey = openpgp.key.readArmored(pub_revoked).keys[0];
|
||||
|
||||
var verified = pubKey.subKeys[0].revocationSignature.verify(pubKey.primaryKey, {key: pubKey.subKeys[0].subKey});
|
||||
|
||||
return new unit.result("Verify subkey revocation signature", verified);
|
||||
}, function() {
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify key expiration date', function(done) {
|
||||
var pubKey = openpgp.key.readArmored(pub_revoked).keys[0];
|
||||
|
||||
var verified = !pubKey.users[0].selfCertifications[0].keyNeverExpires &&
|
||||
pubKey.users[0].selfCertifications[0].keyExpirationTime == 5*365*24*60*60;
|
||||
|
||||
return new unit.result("Verify key expiration date", verified);
|
||||
}, function() {
|
||||
expect(pubKey).to.exist;
|
||||
expect(pubKey.users[0].selfCertifications[0].keyNeverExpires).to.be.false;
|
||||
expect(pubKey.users[0].selfCertifications[0].keyExpirationTime).to.equal(5*365*24*60*60);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Verify V3 certification signature', function(done) {
|
||||
var pubKey = openpgp.key.readArmored(pub_v3).keys[0];
|
||||
|
||||
var verified = pubKey.users[0].selfCertifications[0].verify(pubKey.primaryKey, {key: pubKey.primaryKey, userid: pubKey.users[0].userId});
|
||||
|
||||
return new unit.result("Verify V3 certification signature", verified);
|
||||
}];
|
||||
|
||||
var results = [];
|
||||
|
||||
for(var i in tests) {
|
||||
results.push(tests[i]());
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
expect(verified).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user