Make packet tests run. Rename test files, move signature tests to general folder.
Split keyring tests in own file. Add tests for V3 signatures and fix verification.
This commit is contained in:
parent
66c428da7e
commit
b0ea97ec28
File diff suppressed because one or more lines are too long
|
@ -33,6 +33,7 @@ var util = require('../util'),
|
|||
*/
|
||||
module.exports = function packet_signature() {
|
||||
|
||||
this.version = null;
|
||||
this.signatureType = null;
|
||||
this.hashAlgorithm = null;
|
||||
this.publicKeyAlgorithm = null;
|
||||
|
@ -85,9 +86,9 @@ module.exports = function packet_signature() {
|
|||
this.read = function(bytes) {
|
||||
var i = 0;
|
||||
|
||||
var version = bytes[i++].charCodeAt();
|
||||
this.version = bytes[i++].charCodeAt();
|
||||
// switch on version (3 and 4)
|
||||
switch (version) {
|
||||
switch (this.version) {
|
||||
case 3:
|
||||
// One-octet length of following hashed material. MUST be 5.
|
||||
if (bytes[i++].charCodeAt() != 5)
|
||||
|
@ -104,7 +105,7 @@ module.exports = function packet_signature() {
|
|||
i += 4;
|
||||
|
||||
// storing data appended to data which gets verified
|
||||
this.signatureData = bytes.substring(position, i);
|
||||
this.signatureData = bytes.substring(sigpos, i);
|
||||
|
||||
// Eight-octet Key ID of signer.
|
||||
this.issuerKeyId.read(bytes.substring(i, i + 8));
|
||||
|
@ -570,6 +571,8 @@ module.exports = function packet_signature() {
|
|||
this.calculateTrailer = function() {
|
||||
// calculating the trailer
|
||||
var trailer = '';
|
||||
// V3 signatures don't have a trailer
|
||||
if (this.version == 3) return trailer;
|
||||
trailer += String.fromCharCode(4); // Version
|
||||
trailer += String.fromCharCode(0xFF);
|
||||
trailer += util.writeNumber(this.signatureData.length, 4);
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
var unit = require('../unit.js');
|
||||
|
||||
unit.register("Testing of binary signature checking", function() {
|
||||
var openpgp = require('../../');
|
||||
var keyring = require('../../src/keyring.js');
|
||||
var result = [];
|
||||
var priv_key = openpgp.key.readArmored([
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: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fNZtxdA26jv8//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")).packets;
|
||||
var pub_key = openpgp.key.readArmored(
|
||||
[ '-----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")).packets;
|
||||
var msg = openpgp.message.readArmored([
|
||||
'-----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")).packets;
|
||||
//TODO need both?
|
||||
priv_key[0].decrypt("abcd");
|
||||
priv_key[3].decrypt("abcd");
|
||||
msg[0].decrypt(priv_key[3]);
|
||||
msg[1].decrypt(msg[0].sessionKeyAlgorithm, msg[0].sessionKey);
|
||||
msg[1].packets[2].verify(pub_key[0], msg[1].packets[1]);
|
||||
result[0] = new unit.result("Testing signature checking on CAST5-enciphered message",
|
||||
msg[1].packets[2].verified === true);
|
||||
|
||||
// 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/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")).packets;
|
||||
priv_key_gnupg_ext[3].decrypt("abcd");
|
||||
msg[0].decrypt(priv_key_gnupg_ext[3]);
|
||||
msg[1].decrypt(msg[0].sessionKeyAlgorithm, msg[0].sessionKey);
|
||||
msg[1].packets[2].verify(pub_key[0], msg[1].packets[1]);
|
||||
result[1] = new unit.result("Testing GnuPG stripped-key extensions",
|
||||
msg[1].packets[2].verified === true);
|
||||
|
||||
// Exercises the ability of openpgp_keyring.getPublicKeysForKeyId to return subkeys
|
||||
keyring.init();
|
||||
keyring.importPacketlist([
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'mQGiBFERvI4RBAD0M/HGglCtVNXPF72ehT8riAXrl0rSec4RJC61Bh+UAOhxn5+U',
|
||||
'fDgos5p1SpIzYmn+M87JoSSVLAjfakFk0gHgR9I3bu7SIwq3Bikk1Vw3gO+yDSO6',
|
||||
'TKpLUFGYDiBSSE1MGdxBadWLE1hlRf5B2x62gnGmjSpSVbly33PFkoDmrwCg9rAp',
|
||||
'RmncnF9GhWjOLFkEoQw9Yx8EAOsxvq8Ig5Z1gk+ZKfDZeftpHRe3FdrRtbnhxvYY',
|
||||
'7z+w9uz1EpoZUwDR5G4X3hTwJQ7lXmIOskg/+eRMLEAqEY7b/7tW6RaUJ2d6Ehsi',
|
||||
'dOS89fIxElwjAOnVOM5S24f0FDQTTto7QBOoxcNTfkEJCHXSlpoOUmGAP85fXh3l',
|
||||
'yPTGBACJfKc76Un3UWC1sWIRDxYiyh3ZpZyNEskoV6ESW8jEI1RnMnv5TrfGJH5K',
|
||||
'E8jWX7TTnoFyPJtBTjlucAtkQaS4Bb7dg1LLja17zAqKNGOJK2b9fb2Z+lnTjPiY',
|
||||
'i7DPH1XHnfaEexjlh/U7mYa5RrwIphRxNi8gCuxv874ZMmhEn7QWVGVzdDMgPHRl',
|
||||
'c3QzQHRlc3QuY29tPohiBBMRA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));
|
||||
|
||||
var msg2 = openpgp.message.readArmored([
|
||||
'-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'kA0DAAIRDIjHkdvemNkBrB1iB2Zvby50eHRREbz3VEVTVCBEQVRBIDEyMzQ1NohG',
|
||||
'BAARAgAGBQJREbz3AAoJEAyIx5Hb3pjZ2TcAn32LpDEuHe9QrSRlyvSuREKNOFwz',
|
||||
'AJ9zh4zsK4GIPuEu81YPNmHsju7DYg==',
|
||||
'=WaSx',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join("\n")).packets;
|
||||
var packetlists = keyring.getPacketlistsForKeyId(msg2[0].signingKeyId.write());
|
||||
var pubKey = packetlists[0];
|
||||
msg2[2].verify(pubKey[3], msg2[1]);
|
||||
result[2] = new unit.result("Testing keyring public subkey support",
|
||||
packetlists !== null &&
|
||||
packetlists.length == 1 &&
|
||||
msg2[2].verified);
|
||||
return result;
|
||||
});
|
||||
|
62
test/general/keyring.js
Normal file
62
test/general/keyring.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
var unit = require('../unit.js');
|
||||
|
||||
unit.register("Keyring testing", function() {
|
||||
var openpgp = require('../../');
|
||||
var keyring = require('../../src/keyring.js');
|
||||
var result = [];
|
||||
|
||||
// Exercises the ability of openpgp_keyring.getPublicKeysForKeyId to return subkeys
|
||||
keyring.init();
|
||||
keyring.importPacketlist([
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'mQGiBFERvI4RBAD0M/HGglCtVNXPF72ehT8riAXrl0rSec4RJC61Bh+UAOhxn5+U',
|
||||
'fDgos5p1SpIzYmn+M87JoSSVLAjfakFk0gHgR9I3bu7SIwq3Bikk1Vw3gO+yDSO6',
|
||||
'TKpLUFGYDiBSSE1MGdxBadWLE1hlRf5B2x62gnGmjSpSVbly33PFkoDmrwCg9rAp',
|
||||
'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bNpfqBV7j1K+Kn0n9HYTyQl9ghy',
|
||||
'026+/4c8ag2HV+bg3BD7c2VTVu9xBODHsfu0q8Ql/QB9W8tmYugU6DeXMHaeWPUH',
|
||||
'ph98guM9kF2yHIiRBvAd5i7wOjwn+I/Ir6nBR2yxJ3p31CDUnUlbjTPYg7mtQvHW',
|
||||
'EY2Cp4SWiJEEGBECAAkFAlERvJ4CGwIAUgkQtLvDtDKGtiVHIAQZEQIABgUCURG8',
|
||||
'ngAKCRAMiMeR296Y2SjyAJ9V3wRJJ2Szazqal4khWGfLu5R6/wCfQQIRD24yVdz8',
|
||||
'2a+2eCrwyALT2GAihACfS0nWM3a0gtITqngpJsRws+Ep+eIAn15qD2itutxNb8NI',
|
||||
'bR2gBB5QmVJ3',
|
||||
'=pGA6',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||
].join("\n"));
|
||||
|
||||
var msg2 = openpgp.message.readArmored([
|
||||
'-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'kA0DAAIRDIjHkdvemNkBrB1iB2Zvby50eHRREbz3VEVTVCBEQVRBIDEyMzQ1NohG',
|
||||
'BAARAgAGBQJREbz3AAoJEAyIx5Hb3pjZ2TcAn32LpDEuHe9QrSRlyvSuREKNOFwz',
|
||||
'AJ9zh4zsK4GIPuEu81YPNmHsju7DYg==',
|
||||
'=WaSx',
|
||||
'-----END PGP MESSAGE-----'
|
||||
].join("\n")).packets;
|
||||
var packetlists = keyring.getPacketlistsForKeyId(msg2[0].signingKeyId.write());
|
||||
var pubKey = packetlists[0];
|
||||
msg2[2].verify(pubKey[3], msg2[1]);
|
||||
result[2] = new unit.result("Testing keyring public subkey support",
|
||||
packetlists !== null &&
|
||||
packetlists.length == 1 &&
|
||||
msg2[2].verified);
|
||||
return result;
|
||||
});
|
||||
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
var unit = require('../unit.js');
|
||||
|
||||
unittests.register("Packet testing", function() {
|
||||
unit.register("Packet testing", function() {
|
||||
|
||||
var openpgp = require('../../');
|
||||
|
||||
var armored_key =
|
||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +
|
||||
|
@ -61,7 +64,7 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
msg2[0].decrypt(algo, key);
|
||||
|
||||
return new test_result('Symmetrically encrypted packet',
|
||||
return new unit.result('Symmetrically encrypted packet',
|
||||
msg2[0].packets[0].data == literal.data);
|
||||
|
||||
}, function() {
|
||||
|
@ -84,7 +87,7 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
msg2[0].decrypt(algo, key);
|
||||
|
||||
return new test_result('Sym. encrypted integrity protected packet',
|
||||
return new unit.result('Sym. encrypted integrity protected packet',
|
||||
msg2[0].packets[0].data == literal.data);
|
||||
|
||||
}, function() {
|
||||
|
@ -113,12 +116,12 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
var result = compressed.packets[0].data;
|
||||
|
||||
return new test_result('Sym encrypted session key with a compressed packet',
|
||||
return new unit.result('Sym encrypted session key with a compressed packet',
|
||||
result == 'Hello world!\n');
|
||||
|
||||
}, function() {
|
||||
|
||||
var rsa = new openpgp.publicKey.rsa(),
|
||||
var rsa = new openpgp.crypto.publicKey.rsa(),
|
||||
mpi = rsa.generate(512, "10001")
|
||||
|
||||
var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u];
|
||||
|
@ -145,7 +148,7 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
msg2[0].decrypt({ mpi: mpi });
|
||||
|
||||
return new test_result('Public key encrypted symmetric key packet',
|
||||
return new unit.result('Public key encrypted symmetric key packet',
|
||||
msg2[0].sessionKey == enc.sessionKey &&
|
||||
msg2[0].sessionKeyAlgorithm == enc.sessionKeyAlgorithm);
|
||||
}, function() {
|
||||
|
@ -187,7 +190,7 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
enc.decrypt(key);
|
||||
|
||||
return new test_result('Secret key packet (reading, unencrpted)',
|
||||
return new unit.result('Secret key packet (reading, unencrpted)',
|
||||
enc.sessionKey == secret);
|
||||
}, function() {
|
||||
|
||||
|
@ -252,7 +255,7 @@ unittests.register("Packet testing", function() {
|
|||
var text = msg[1].packets[0].packets[0].data;
|
||||
|
||||
|
||||
return new test_result('Public key encrypted packet (reading, GPG)',
|
||||
return new unit.result('Public key encrypted packet (reading, GPG)',
|
||||
text == 'Hello world!');
|
||||
}, function() {
|
||||
|
||||
|
@ -285,7 +288,7 @@ unittests.register("Packet testing", function() {
|
|||
msg2[1].decrypt(msg2[0].sessionKeyAlgorithm, key2);
|
||||
|
||||
|
||||
return new test_result('Sym encrypted session key reading/writing',
|
||||
return new unit.result('Sym encrypted session key reading/writing',
|
||||
msg2[1].packets[0].data == literal.data);
|
||||
|
||||
}, function() {
|
||||
|
@ -316,7 +319,7 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
|
||||
|
||||
return new test_result('Secret key encryption/decryption test',
|
||||
return new unit.result('Secret key encryption/decryption test',
|
||||
text == 'Hello world!');
|
||||
}, function() {
|
||||
|
||||
|
@ -338,7 +341,7 @@ unittests.register("Packet testing", function() {
|
|||
})
|
||||
|
||||
|
||||
return new test_result('Secret key reading with signature verification.',
|
||||
return new unit.result('Secret key reading with signature verification.',
|
||||
verified == true);
|
||||
}, function() {
|
||||
|
||||
|
@ -373,20 +376,17 @@ unittests.register("Packet testing", function() {
|
|||
|
||||
|
||||
|
||||
var verified = payload[2].verify(key[0],
|
||||
{
|
||||
literal: payload[1]
|
||||
});
|
||||
var verified = payload[2].verify(key[0], payload[1]);
|
||||
|
||||
|
||||
|
||||
return new test_result('Reading a signed, encrypted message.',
|
||||
return new unit.result('Reading a signed, encrypted message.',
|
||||
verified == true);
|
||||
}, function() {
|
||||
var key = new openpgp.packet.list();
|
||||
key.push(new openpgp.packet.secret_key);
|
||||
|
||||
var rsa = new openpgp.publicKey.rsa(),
|
||||
var rsa = new openpgp.crypto.publicKey.rsa(),
|
||||
mpi = rsa.generate(512, "10001")
|
||||
|
||||
|
||||
|
@ -409,14 +409,13 @@ unittests.register("Packet testing", function() {
|
|||
key2[0].decrypt('hello');
|
||||
|
||||
|
||||
return new test_result('Writing and encryptio of a secret key packet.',
|
||||
return new unit.result('Writing and encryptio of a secret key packet.',
|
||||
key[0].mpi.toString() == key2[0].mpi.toString());
|
||||
}, function() {
|
||||
var openpgp = require('openpgp');
|
||||
|
||||
var key = new openpgp.packet.secret_key();
|
||||
|
||||
var rsa = new openpgp.publicKey.rsa,
|
||||
var rsa = new openpgp.crypto.publicKey.rsa,
|
||||
mpi = rsa.generate(512, "10001")
|
||||
|
||||
var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u];
|
||||
|
@ -439,7 +438,7 @@ unittests.register("Packet testing", function() {
|
|||
signature.publicKeyAlgorithm = 'rsa_sign';
|
||||
signature.signatureType = 'binary';
|
||||
|
||||
signature.sign(key, { literal: literal });
|
||||
signature.sign(key, literal);
|
||||
|
||||
signed.push(literal);
|
||||
signed.push(signature);
|
||||
|
@ -449,10 +448,10 @@ unittests.register("Packet testing", function() {
|
|||
var signed2 = new openpgp.packet.list();
|
||||
signed2.read(raw);
|
||||
|
||||
var verified = signed2[1].verify(key, { literal: signed2[0] });
|
||||
var verified = signed2[1].verify(key, signed2[0]);
|
||||
|
||||
|
||||
return new test_result('Writing and verification of a signature packet.',
|
||||
return new unit.result('Writing and verification of a signature packet.',
|
||||
verified == true);
|
||||
}];
|
||||
|
||||
|
|
242
test/general/signature.js
Normal file
242
test/general/signature.js
Normal file
|
@ -0,0 +1,242 @@
|
|||
var unit = require('../unit.js');
|
||||
|
||||
unit.register("Signature testing", function() {
|
||||
var openpgp = require('../../');
|
||||
|
||||
var priv_key_arm1 =
|
||||
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v1.4.11 (GNU/Linux)',
|
||||
'',
|
||||
'lQHhBFERnrMRBADmM0hIfkI3yosjgbWo9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1QyjwEG0APtz41EfAAMFBAC5/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 priv_key_arm2 =
|
||||
['-----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+AX2b9ZuZXAxI3Tc/7++vEyL',
|
||||
'3p18N/MB2kt1Wb1azmXWL2EKlT1BZ5yDaJuBQ8BhphM3tCRUZXN0IE1jVGVzdG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go8128r1zQ',
|
||||
'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 pub_key_arm2 =
|
||||
['-----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 tests = [function() {
|
||||
var priv_key = openpgp.key.readArmored(priv_key_arm1).packets;
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm1).packets;
|
||||
var msg = openpgp.message.readArmored(msg_arm1).packets;
|
||||
//TODO need both?
|
||||
priv_key[0].decrypt("abcd");
|
||||
priv_key[3].decrypt("abcd");
|
||||
msg[0].decrypt(priv_key[3]);
|
||||
msg[1].decrypt(msg[0].sessionKeyAlgorithm, msg[0].sessionKey);
|
||||
msg[1].packets[2].verify(pub_key[0], msg[1].packets[1]);
|
||||
return new unit.result("Testing signature checking on CAST5-enciphered message",
|
||||
msg[1].packets[2].verified === true);
|
||||
|
||||
}, function() {
|
||||
|
||||
// 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/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")).packets;
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm1).packets;
|
||||
var msg = openpgp.message.readArmored(msg_arm1).packets;
|
||||
|
||||
priv_key_gnupg_ext[3].decrypt("abcd");
|
||||
msg[0].decrypt(priv_key_gnupg_ext[3]);
|
||||
msg[1].decrypt(msg[0].sessionKeyAlgorithm, msg[0].sessionKey);
|
||||
msg[1].packets[2].verify(pub_key[0], msg[1].packets[1]);
|
||||
return new unit.result("Testing GnuPG stripped-key extensions",
|
||||
msg[1].packets[2].verified === true);
|
||||
|
||||
}, function() {
|
||||
|
||||
var signedArmor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMwMT4oOW7S46CznTGNeZJLCWpFSVBU3ZGF2fkF5Uo5KYWFyemp3LlAUUV',
|
||||
'cjLzUrneTp3zauvaN9O26L9ZuOFNy4LXyydwcXXMYWFgZGJgY2UCaWXg4hSAmblK',
|
||||
'nPmfsXYxd58Ka9eVrEnSpzilr520fXBrJsf2P/oTqzTj3hzyLG0o3TTzxFfrtOXf',
|
||||
'cw6U57n3/Z4X0pEZ68C5/o/6NpPICD7fuEOz3936raZ6wXGzueY8pfPnVjY0ajAc',
|
||||
'PtJzvvqj+ubYaT1sK9wWhd9lL3/V+9Zuua9QjOWC22buchsCroh8fLoZAA==',
|
||||
'=VH8F',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
|
||||
var sMsg = openpgp.message.readArmored(signedArmor).packets;
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm2).packets;
|
||||
sMsg[0].packets[2].verify(pub_key[3], sMsg[0].packets[1]);
|
||||
return new unit.result("Verify V4 signature. Hash: SHA1. PK: RSA. Signature Type: 0x00 (binary document)", sMsg[0].packets[2].verified);
|
||||
}, function() {
|
||||
|
||||
var signedArmor =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'owGbwMvMyMj4oOW7S46CznTG09YlLCWpFSVBU47xFGfkF5Uo5KYWFyemp/Jy5QGF',
|
||||
'FXIy84DMt1PnvNq69s20LfpvFm5407Lg9fIJvFy8XJ0MU5lZGUFa4eYxxiQz/6+/',
|
||||
'aFt4/6+e76O6s1afLi65emmK9xsdh7Mr60UnT2UN0LwocWnT7t/nOMJubnypvzTu',
|
||||
'aPJyvm9TTpobW/O+P1n2THLS4UCvWt12Oa2lJ04GLwk/bDF1u+8ZpfPCpsxLVzcs',
|
||||
'ZGtbq/f23XxV/jkL47hr3s3Ic4yoZTW4oZO27GYf37TPp9L3VboCAA==',
|
||||
'=pa6B',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
|
||||
var sMsg = openpgp.message.readArmored(signedArmor).packets;
|
||||
var pub_key = openpgp.key.readArmored(pub_key_arm2).packets;
|
||||
sMsg[0].packets[2].verify(pub_key[3], sMsg[0].packets[1]);
|
||||
return new unit.result("Verify V3 signature. Hash: MD5. PK: RSA. Signature Type: 0x01 (text document)", sMsg[0].packets[2].verified);
|
||||
}];
|
||||
|
||||
var results = [];
|
||||
|
||||
for(var i in tests) {
|
||||
results.push(tests[i]());
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
});
|
|
@ -11,7 +11,9 @@ require('./crypto/cipher/cast5.js');
|
|||
require('./crypto/cipher/des.js');
|
||||
require('./crypto/cipher/twofish.js');
|
||||
|
||||
require('./crypto/openpgp.crypto.js');
|
||||
require('./crypto/openpgp.sigcheck.js');
|
||||
require('./crypto/crypto.js');
|
||||
|
||||
require('./general/openpgp.basic.js');
|
||||
require('./general/basic.js');
|
||||
require('./general/keyring.js');
|
||||
require('./general/packet.js');
|
||||
require('./general/signature.js');
|
||||
|
|
1136
test/test-bundle.js
1136
test/test-bundle.js
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user