Move most test high lvl api test code to test/openpgp.js, cleanup
This commit is contained in:
parent
d5a2e0fb81
commit
707b3919e1
|
@ -1,5 +1,6 @@
|
|||
describe('Crypto', function () {
|
||||
require('./crypto.js');
|
||||
require('./cipher');
|
||||
require('./hash');
|
||||
require('./random.js');
|
||||
require('./crypto.js');
|
||||
});
|
||||
|
|
80
test/crypto/random.js
Normal file
80
test/crypto/random.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
describe('Random Buffer', function() {
|
||||
var randomBuffer;
|
||||
|
||||
before(function() {
|
||||
randomBuffer = new openpgp.crypto.random.randomBuffer.constructor();
|
||||
expect(randomBuffer).to.exist;
|
||||
});
|
||||
|
||||
it('Throw error if not initialized', function () {
|
||||
expect(randomBuffer.set.bind(randomBuffer)).to.throw('RandomBuffer is not initialized');
|
||||
expect(randomBuffer.get.bind(randomBuffer)).to.throw('RandomBuffer is not initialized');
|
||||
});
|
||||
|
||||
it('Initialization', function () {
|
||||
randomBuffer.init(5);
|
||||
expect(randomBuffer.buffer).to.exist;
|
||||
expect(randomBuffer.buffer).to.have.length(5);
|
||||
expect(randomBuffer.size).to.equal(0);
|
||||
});
|
||||
|
||||
function equal(buf, arr) {
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
if (buf[i] !== arr[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
it('Set Method', function () {
|
||||
randomBuffer.init(5);
|
||||
var buf = new Uint32Array(2);
|
||||
expect(randomBuffer.set.bind(randomBuffer, buf)).to.throw('Invalid type: buf not an Uint8Array');
|
||||
buf = new Uint8Array(2);
|
||||
buf[0] = 1; buf[1] = 2;
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,0,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(2);
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,1,2,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(4);
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,1,2,1])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(5);
|
||||
randomBuffer.init(1);
|
||||
buf = new Uint8Array(2);
|
||||
buf[0] = 1; buf[1] = 2;
|
||||
randomBuffer.set(buf);
|
||||
expect(buf).to.to.have.property('0', 1);
|
||||
expect(randomBuffer.size).to.equal(1);
|
||||
});
|
||||
|
||||
it('Get Method', function () {
|
||||
randomBuffer.init(5);
|
||||
var buf = new Uint8Array(5);
|
||||
buf[0] = 1; buf[1] = 2; buf[2] = 5; buf[3] = 7; buf[4] = 8;
|
||||
randomBuffer.set(buf);
|
||||
buf = new Uint32Array(2);
|
||||
expect(randomBuffer.get.bind(randomBuffer, buf)).to.throw('Invalid type: buf not an Uint8Array');
|
||||
buf = new Uint8Array(2);
|
||||
randomBuffer.get(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,5,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(3);
|
||||
expect(buf).to.to.have.property('0', 8);
|
||||
expect(buf).to.to.have.property('1', 7);
|
||||
randomBuffer.get(buf);
|
||||
expect(buf).to.to.have.property('0', 5);
|
||||
expect(buf).to.to.have.property('1', 2);
|
||||
expect(equal(randomBuffer.buffer, [1,0,0,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(1);
|
||||
expect(function() { randomBuffer.get(buf); }).to.throw('Random number buffer depleted');
|
||||
});
|
||||
});
|
|
@ -1,325 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
describe('Basic', function() {
|
||||
|
||||
describe("Key generation/encryption/decryption", function() {
|
||||
it.skip('Performance test', function (done) {
|
||||
// init test data
|
||||
function randomString(length, chars) {
|
||||
var result = '';
|
||||
for (var i = length; i > 0; --i) {
|
||||
result += chars[Math.round(Math.random() * (chars.length - 1))];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var message = randomString(1024*1024*3, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
|
||||
var userid = 'Test McTestington <test@example.com>';
|
||||
var passphrase = 'password';
|
||||
|
||||
var opt = {numBits: 512, userId: userid, passphrase: passphrase};
|
||||
if (openpgp.util.getWebCrypto()) { opt.numBits = 2048; } // webkit webcrypto accepts minimum 2048 bit keys
|
||||
|
||||
openpgp.generateKeyPair(opt).then(function(key) {
|
||||
|
||||
var privKeys = openpgp.key.readArmored(key.privateKeyArmored);
|
||||
var publicKeys = openpgp.key.readArmored(key.publicKeyArmored);
|
||||
|
||||
var privKey = privKeys.keys[0];
|
||||
var pubKey = publicKeys.keys[0];
|
||||
|
||||
var success = privKey.decrypt(passphrase);
|
||||
expect(success).to.be.true;
|
||||
|
||||
if (console.profile) {
|
||||
console.profile("encrypt/sign/verify/decrypt");
|
||||
}
|
||||
|
||||
// sign and encrypt
|
||||
var msg, encrypted;
|
||||
msg = openpgp.message.fromText(message, "test.txt");
|
||||
msg = msg.sign([privKey]);
|
||||
msg = msg.encrypt([pubKey]);
|
||||
encrypted = openpgp.armor.encode(openpgp.enums.armor.message, msg.packets.write());
|
||||
|
||||
if (console.profileEnd) {
|
||||
console.profileEnd();
|
||||
}
|
||||
|
||||
msg = openpgp.message.readArmored(encrypted);
|
||||
|
||||
var keyids = msg.getEncryptionKeyIds();
|
||||
|
||||
expect(keyids).to.exist;
|
||||
|
||||
return openpgp.decryptAndVerifyMessage(privKey, [pubKey], msg);
|
||||
|
||||
}).then(function(decrypted) {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
expect(decrypted.text).to.equal(message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Message encryption/decryption", function() {
|
||||
var pub_key =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'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)',
|
||||
'',
|
||||
'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+IuSRnrlpZl3kcbHASPAOfE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JgWJiH1fbYlwESByHW+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 password1 = 'I am a password';
|
||||
var password2 = 'I am another password';
|
||||
|
||||
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 params = {
|
||||
packets: true
|
||||
};
|
||||
|
||||
openpgp.encryptMessage([pubKey], plaintext, [password1, password2], params).then(function(encrypted) {
|
||||
|
||||
expect(encrypted).to.exist;
|
||||
encrypted = openpgp.util.concatUint8Array([encrypted.keys,encrypted.data]);
|
||||
encrypted = openpgp.armor.encode(openpgp.enums.armor.message, encrypted);
|
||||
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();
|
||||
});
|
||||
|
||||
it('Calling decryptMessage with not decrypted key packet leads to exception', function (done) {
|
||||
openpgp.decryptMessage(privKey, message).catch(function(error) {
|
||||
expect(error).to.exist;
|
||||
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) {
|
||||
openpgp.decryptMessage(privKey, message).then(function(decrypted) {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Decrypt with password1 leads to the same result', function (done) {
|
||||
openpgp.decryptMessage(password1, message).then(function(decrypted) {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Decrypt with password2 leads to the same result', function (done) {
|
||||
openpgp.decryptMessage(password2, message).then(function(decrypted) {
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Decrypt message 2x', function(done) {
|
||||
var decrypted1;
|
||||
|
||||
openpgp.decryptMessage(privKey, message).then(function(decrypted) {
|
||||
decrypted1 = decrypted;
|
||||
return openpgp.decryptMessage(privKey, message);
|
||||
}).then(function(decrypted2) {
|
||||
expect(decrypted1).to.equal(decrypted2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("Message 3DES decryption", function() {
|
||||
var pgp_msg =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||
'Comment: GPGTools - http://gpgtools.org',
|
||||
'',
|
||||
'hIwDBU4Dycfvp2EBA/9tuhQgOrcATcm2PRmIOcs6q947YhlsBTZZdVJDfVjkKlyM',
|
||||
'M0yE+lnNplWb041Cpfkkl6IvorKQd2iPbAkOL0IXwmVN41l+PvVgMcuFvvzetehG',
|
||||
'Ca0/VEYOaTZRNqyr9FIzcnVy1I/PaWT3iqVAYa+G8TEA5Dh9RLfsx8ZA9UNIaNI+',
|
||||
'ASm9aZ3H6FerNhm8RezDY5vRn6xw3o/wH5YEBvV2BEmmFKZ2BlqFQxqChr8UNwd1',
|
||||
'Ieebnq0HtBPE8YU/L0U=',
|
||||
'=JyIa',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
|
||||
var priv_key =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||
'Comment: GPGTools - http://gpgtools.org',
|
||||
'',
|
||||
'lQH+BFLqLegBBAC/rN3g30Jrcpx5lTb7Kxe+ZfS7ppOIoBjjN+qcOh81cJJVS5dT',
|
||||
'UGcDsm2tCLVS3P2dGaYhfU9fsoSq/wK/tXsdoWXvXdjHbbueyi1kTZqlnyT190UE',
|
||||
'vmDxH0yqquvUaf7+CNXC0T6l9gGS9p0x7xNydWRb7zeK1wIsYI+dRGQmzQARAQAB',
|
||||
'/gMDArgQHMknurQXy0Pho3Nsdu6zCUNXuplvaSXruefKsQn6eexGPnecNTT2iy5N',
|
||||
'70EK371D7GcNhhLsn8roUcj1Hi3kR14wXW7lcQBy9RRbbglIJXIqKJ8ywBEO8BaQ',
|
||||
'b0plL+w5A9EvX0BQc4d53MTqySh6POsEDOxPzH4D/JWbaozfmc4LfGDqH1gl7ebY',
|
||||
'iu81vnBuuskjpz8rxRI81MldJEIObrTE2x46DF7AmS6L6u/Qz3AAmZd89p5INCdx',
|
||||
'DemxzuMKpC3wSgdgSSKHHTKiNOMxiRd5mFH5v1KVcEG/TyXFlmah7RwA4rA4fjeo',
|
||||
'OpnbVWp6ciUniRvgLaCMMbmolAoho9zaLbPzCQVQ8F7gkrjnnPm4MKA+AUXmjt7t',
|
||||
'VrrYkyTp1pxLZyUWX9+aKoxEO9OIDz7p9Mh02BZ/tznQ7U+IV2bcNhwrL6LPk4Mb',
|
||||
'J4YF/cLVxFVVma88GSFikSjPf30AUty5nBQFtbFGqnPctCF0aHJvd2F3YXkgPHRo',
|
||||
'cm93YXdheUBleGFtcGxlLmNvbT6IuAQTAQIAIgUCUuot6AIbAwYLCQgHAwIGFQgC',
|
||||
'CQoLBBYCAwECHgECF4AACgkQkk2hoj5duD/HZQP/ZXJ8PSlA1oj1NW97ccT0LiNH',
|
||||
'WzxPPoH9a/qGQYg61jp+aTa0C5hlYY/GgeFpiZlpwVUtlkZYfslXJqbCcp3os4xt',
|
||||
'kiukDbPnq2Y41wNVxXrDw6KbOjohbhzeRUh8tx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fDWVwKA==',
|
||||
'=IkKW',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
it('Decrypt message', function (done) {
|
||||
var privKey, message;
|
||||
|
||||
privKey = openpgp.key.readArmored(priv_key).keys[0];
|
||||
privKey.decrypt('1234');
|
||||
message = openpgp.message.readArmored(pgp_msg);
|
||||
|
||||
openpgp.decryptMessage(privKey, message).then(function(decrypted) {
|
||||
expect(decrypted).to.equal('hello 3des\n');
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe("Misc.", function() {
|
||||
|
||||
it('util.decode_utf8 throws error if invalid parameter type', function () {
|
||||
var test = openpgp.util.decode_utf8.bind(null, {chameleon: true});
|
||||
expect(test).to.throw(Error, /Parameter "utf8" is not of type string/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -6,7 +6,6 @@ describe('General', function () {
|
|||
require('./signature.js');
|
||||
require('./key.js');
|
||||
require('./openpgp.js');
|
||||
require('./basic.js');
|
||||
require('./hkp.js');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* globals tryWorker: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
||||
|
@ -7,69 +9,154 @@ var sinon = require('sinon'),
|
|||
expect = chai.expect;
|
||||
|
||||
var pub_key =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
||||
'fIF6P29lJFxpblWk02PSID5zX/DYU9/zjM2xPO8Oa4xo0cVTOTLj++Ri5mtr//f5',
|
||||
'GLsIXxFrBJhD/ghFsL3Op0GXOeLJ9A5bsOn8th7x6JucNKuaRB6bQbSPABEBAAG0',
|
||||
'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IC KEY BLOCK-----'].join('\n');
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'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)',
|
||||
'',
|
||||
'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/QFbwNyEh6K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ydPSgRKoaUdRHJY0S4vp9ouKOtl',
|
||||
'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');
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||
'/nyBej9vZSRcaW5VpNNj0iA+c1/w2FPf84zNsTzvDmuMaNHFUzky4/vkYuZra//3',
|
||||
'+Ri7CF8RawSYQ/4IRbC9zqdBlzniyfQOW7Dp/LYe8eibnDSrmkQem0G0jwARAQAB',
|
||||
'/gMDAu7L//czBpE40p1ZqO8K3k7UejemjsQqc7kOqnlDYd1Z6/3NEA/UM30Siipr',
|
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pLzL7GwBbWFhSWgSLy53',
|
||||
'Md99Kxw3cApWCok2E8R9/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 pub_key_de =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||
'',
|
||||
'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||
'EslVgTd8IcUU14ZMOO7y91dw0KP4q61b4OIy7oVxzfFfKCC1s0Dc7GTay+qo5afJ',
|
||||
'wbWcgTyCIahTRmi5UepU7xdRHRMlqAclOwY2no8fw0JRQfFwRFCjbMdmvzC/k+Wo',
|
||||
'A42nn8YaSAG2v7OqF3rkYjkv/7iak48PO/l0Q13USAJLIWdHvRTir78mQUsEY0qR',
|
||||
'VoNqz5sMqakzhTvTav07EVy/1xC6GKoWXA9sdB/4r7+blVuu9M4yD40GkE69oAXO',
|
||||
'mz6tG3lRq41S0OSzNyDWtUQgMVF6wYqVxUGrAQDJM5A1rF1RKzFiHdkyy57E8LC1',
|
||||
'SIJyIXWJ0c5b8/olWQf9G5a17fMjkRTC3FO+ZHwFE1jIM6znYOF2GltDToLuJPq9',
|
||||
'lWrI7zVP9AJPwrUt7FK2MBNAvd1jKyIhdU98PBQ2pr+jmyqIycl9iDGXLDO7D7E/',
|
||||
'TBnxwQzoL/5b7UnPImuXOwv5JhVmyV2t003xjzb1EGggOnpKugUtVLps8JiLl9n+',
|
||||
'Nkj5wpU7NXbuHj2XGkkGmKkCIz4l0dJQR9V6svJV9By0RPgfGPXlN1VR6f2ounNy',
|
||||
'6REnDCQP9S3Li5eNcxlSGDIxIZL22j63sU/68GVlzqhVdGXxofv5jGtajiNSpPot',
|
||||
'ElZU0dusna4PzYmiBCsyN8jENWSzHLJ37N4ScN4b/gf6Axf9FU0PjzPBN1o9W6zj',
|
||||
'kpfhlSWDjE3BK8jJ7KvzecM2QE/iJsbuyKEsklw1v0MsRDsox5QlQJcKOoUHC+OT',
|
||||
'iKm8cnPckLQNPOw/kb+5Auz7TXBQ63dogDuqO8QGGOpjh8SIY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VcQgGXo2ZhVYkoLNhWTIEBuJWIyc4Vj20YpTms',
|
||||
'lgHnjeq5rP6781MwAJQnViyJ2SziGK4/+3CoDiQLO1zId42otXBvsbUuLSL5peX4',
|
||||
'v2XNVMLJMY5iSfzbBWczecyapiQ3fbVtWgucgrqlrqM3546v+GdATBhGOu8ppf5j',
|
||||
'7d1A7ohhBBgRCAAJBQJS1YHUAhsMAAoJELqZP8Ku4Yo6SgoBAIVcZstwz4lyA2et',
|
||||
'y61IhKbJCOlQxyem+kepjNapkhKDAQDIDL38bZWU4Rm0nq82Xb4yaI0BCWDcFkHV',
|
||||
'og2umGfGng==',
|
||||
'=v3+L',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
var priv_key_de =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||
'',
|
||||
'lQN5BFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||
'EslVgTd8IcUU14ZMOO7y91dw0KP4q61b4OIy7oVxzfFfKCC1s0Dc7GTay+qo5afJ',
|
||||
'wbWcgTyCIahTRmi5UepU7xdRHRMlqAclOwY2no8fw0JRQfFwRFCjbMdmvzC/k+Wo',
|
||||
'A42nn8YaSAG2v7OqF3rkYjkv/7iak48PO/l0Q13USAJLIWdHvRTir78mQUsEY0qR',
|
||||
'VoNqz5sMqakzhTvTav07EVy/1xC6GKoWXA9sdB/4r7+blVuu9M4yD40GkE69oAXO',
|
||||
'mz6tG3lRq41S0OSzNyDWtUQgMVF6wYqVxUGrAQDJM5A1rF1RKzFiHdkyy57E8LC1',
|
||||
'SIJyIXWJ0c5b8/olWQf9G5a17fMjkRTC3FO+ZHwFE1jIM6znYOF2GltDToLuJPq9',
|
||||
'lWrI7zVP9AJPwrUt7FK2MBNAvd1jKyIhdU98PBQ2pr+jmyqIycl9iDGXLDO7D7E/',
|
||||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L5M+n',
|
||||
'Xd7sx4s+M4KZ/MZfI6ZX4lhcoUdAbB9FWiV7uNntyeFo8qgGM5at/Q0EsyzMSqbe',
|
||||
'Bxk4bpd5MfYGThn0Ae2xaw3X94KaZ3LjtHo2V27FD+jvmmoAj9b1+zcO/pJ8Suoj',
|
||||
'QmcnS4VDVV+Ba5WPTav0LzDdQXyGMZI9PDxCjAI2f1HjTuxIt8X8rAQSQdoMIcQR',
|
||||
'YEjolsXS6iob1eVigyL86hLJjI3VPn6kBCv3Tb+WXX+9LgSAt9yvv4HMwBLK33k6',
|
||||
'IH7M72SqQulZywADBQgAt2xVTMjdVyMniMLjEd4HbUgwyCPkVkcA4zTXqfKu+dAe',
|
||||
'4dK5tre0clkXZVtR1V8RDAD0zaVyM030e2zbzn4cGKDL2dmwk2ZBeXWZDgGKoKvG',
|
||||
'KYf8PRpTAYweFzol3OUdfXH5SngOylCD4OCLs4RSVkSsllIWqLpnS5IJFgt6PDVc',
|
||||
'QgGXo2ZhVYkoLNhWTIEBuJWIyc4Vj20YpTmslgHnjeq5rP6781MwAJQnViyJ2Szi',
|
||||
'GK4/+3CoDiQLO1zId42otXBvsbUuLSL5peX4v2XNVMLJMY5iSfzbBWczecyapiQ3',
|
||||
'fbVtWgucgrqlrqM3546v+GdATBhGOu8ppf5j7d1A7v4DAwJta87fJ43wicncdV+Y',
|
||||
'7ess/j8Rx6/4Jt7ptmRjJNRNbB0ORLZ5BA9544qzAWNtfPOs2PUEDT1L+ChXfD4w',
|
||||
'ZG3Yk5hE+PsgbSbGQ5iTSTg9XJYqiGEEGBEIAAkFAlLVgdQCGwwACgkQupk/wq7h',
|
||||
'ijpKCgD9HC+RyNOutHhPFbgSvyH3cY6Rbnh1MFAUH3SG4gmiE8kA/A679f/+Izs1',
|
||||
'DHTORVqAOdoOcu5Qh7AQg1GdSmfFAsx2',
|
||||
'=kyeP',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
var passphrase = 'hello world';
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
|
@ -295,8 +382,8 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
openpgp.generateKey(opt).then(function(newKey) {
|
||||
expect(newKey.key.getUserIds()[0]).to.equal('Test User <text@example.com>');
|
||||
expect(newKey.privateKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.match(/^-----BEGIN PGP PUBLIC/);
|
||||
expect(newKey.privateKeyArmored).to.match(/^-----BEGIN PGP PRIVATE/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -311,8 +398,8 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
openpgp.generateKey(opt).then(function(newKey) {
|
||||
expect(newKey.key.getUserIds()[0]).to.equal('Test User <text@example.com>');
|
||||
expect(newKey.privateKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.match(/^-----BEGIN PGP PUBLIC/);
|
||||
expect(newKey.privateKeyArmored).to.match(/^-----BEGIN PGP PRIVATE/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -327,8 +414,8 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
openpgp.generateKey(opt).then(function(newKey) {
|
||||
expect(newKey.key.getUserIds()[0]).to.equal('Test User <text@example.com>');
|
||||
expect(newKey.privateKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.exist;
|
||||
expect(newKey.publicKeyArmored).to.match(/^-----BEGIN PGP PUBLIC/);
|
||||
expect(newKey.privateKeyArmored).to.match(/^-----BEGIN PGP PRIVATE/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -361,23 +448,24 @@ describe('OpenPGP.js public api tests', function() {
|
|||
|
||||
describe('without Worker', tests);
|
||||
|
||||
if (typeof window !== 'undefined' && window.Worker) {
|
||||
describe('with Worker', function() {
|
||||
before(function() {
|
||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
});
|
||||
|
||||
tests();
|
||||
|
||||
after(function() {
|
||||
openpgp.destroyWorker(); // cleanup worker in case of failure
|
||||
});
|
||||
});
|
||||
} else {
|
||||
describe.skip('with Worker (No Web Worker support --> skipping tests)', tests);
|
||||
}
|
||||
tryWorker('with Worker', tests, function() {
|
||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
}, function() {
|
||||
openpgp.destroyWorker(); // cleanup worker in case of failure
|
||||
});
|
||||
|
||||
function tests() {
|
||||
it('Configuration', function(done){
|
||||
openpgp.config.show_version = false;
|
||||
openpgp.config.commentstring = 'different';
|
||||
openpgp.encrypt({ publicKeys:publicKey.keys, data:plaintext }).then(function(encrypted) {
|
||||
expect(encrypted.data).to.exist;
|
||||
expect(encrypted.data).not.to.match(/^Version:/);
|
||||
expect(encrypted.data).to.match(/Comment: different/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Calling decrypt with not decrypted key leads to exception', function (done) {
|
||||
var encOpt = {
|
||||
data: plaintext,
|
||||
|
@ -506,7 +594,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('with pgp key pair', function() {
|
||||
describe('AES / RSA encrypt, decrypt, sign, verify', function() {
|
||||
var wrong_pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n' +
|
||||
'Version: OpenPGP.js v0.9.0\r\n' +
|
||||
'Comment: Hoodiecrow - https://hoodiecrow.com\r\n' +
|
||||
|
@ -532,6 +620,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
privateKey: privateKey.keys[0]
|
||||
};
|
||||
openpgp.encrypt(encOpt).then(function(encrypted) {
|
||||
expect(encrypted.data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
decOpt.message = openpgp.message.readArmored(encrypted.data);
|
||||
return openpgp.decrypt(decOpt);
|
||||
}).then(function(decrypted) {
|
||||
|
@ -557,7 +646,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
}).then(function(decrypted) {
|
||||
expect(decrypted.data).to.equal(plaintext);
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
expect(decrypted.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].primaryKey.getKeyId().toHex());
|
||||
expect(decrypted.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -578,7 +667,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
}).then(function(decrypted) {
|
||||
expect(decrypted.data).to.equal(plaintext);
|
||||
expect(decrypted.signatures[0].valid).to.be.null;
|
||||
expect(decrypted.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].primaryKey.getKeyId().toHex());
|
||||
expect(decrypted.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -592,12 +681,13 @@ describe('OpenPGP.js public api tests', function() {
|
|||
publicKeys: publicKey.keys
|
||||
};
|
||||
openpgp.sign(signOpt).then(function(signed) {
|
||||
expect(signed.data).to.match(/-----BEGIN PGP SIGNED MESSAGE-----/);
|
||||
verifyOpt.message = openpgp.cleartext.readArmored(signed.data);
|
||||
return openpgp.verify(verifyOpt);
|
||||
}).then(function(verified) {
|
||||
expect(verified.data).to.equal(plaintext);
|
||||
expect(verified.signatures[0].valid).to.be.true;
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].primaryKey.getKeyId().toHex());
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -616,7 +706,7 @@ describe('OpenPGP.js public api tests', function() {
|
|||
}).then(function(verified) {
|
||||
expect(verified.data).to.equal(plaintext);
|
||||
expect(verified.signatures[0].valid).to.be.null;
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].primaryKey.getKeyId().toHex());
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -636,13 +726,102 @@ describe('OpenPGP.js public api tests', function() {
|
|||
}).then(function(verified) {
|
||||
expect(verified.data).to.equal(plaintext);
|
||||
expect(verified.signatures[0].valid).to.be.true;
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].primaryKey.getKeyId().toHex());
|
||||
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('with symmetric entryption', function() {
|
||||
describe('ELG / DSA encrypt, decrypt, sign, verify', function() {
|
||||
it('round trip test', function (done) {
|
||||
var pubKeyDE = openpgp.key.readArmored(pub_key_de).keys[0];
|
||||
var privKeyDE = openpgp.key.readArmored(priv_key_de).keys[0];
|
||||
privKeyDE.decrypt(passphrase);
|
||||
openpgp.encrypt({
|
||||
publicKeys: pubKeyDE,
|
||||
privateKeys: privKeyDE,
|
||||
data: plaintext
|
||||
}).then(function(encrypted) {
|
||||
return openpgp.decrypt({
|
||||
privateKey: privKeyDE,
|
||||
publicKeys: pubKeyDE,
|
||||
message: openpgp.message.readArmored(encrypted.data)
|
||||
});
|
||||
}).then(function(encrypted) {
|
||||
expect(encrypted.data).to.exist;
|
||||
expect(encrypted.data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("3DES decrypt", function() {
|
||||
var pgp_msg =
|
||||
['-----BEGIN PGP MESSAGE-----',
|
||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||
'Comment: GPGTools - http://gpgtools.org',
|
||||
'',
|
||||
'hIwDBU4Dycfvp2EBA/9tuhQgOrcATcm2PRmIOcs6q947YhlsBTZZdVJDfVjkKlyM',
|
||||
'M0yE+lnNplWb041Cpfkkl6IvorKQd2iPbAkOL0IXwmVN41l+PvVgMcuFvvzetehG',
|
||||
'Ca0/VEYOaTZRNqyr9FIzcnVy1I/PaWT3iqVAYa+G8TEA5Dh9RLfsx8ZA9UNIaNI+',
|
||||
'ASm9aZ3H6FerNhm8RezDY5vRn6xw3o/wH5YEBvV2BEmmFKZ2BlqFQxqChr8UNwd1',
|
||||
'Ieebnq0HtBPE8YU/L0U=',
|
||||
'=JyIa',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
|
||||
var priv_key =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||
'Comment: GPGTools - http://gpgtools.org',
|
||||
'',
|
||||
'lQH+BFLqLegBBAC/rN3g30Jrcpx5lTb7Kxe+ZfS7ppOIoBjjN+qcOh81cJJVS5dT',
|
||||
'UGcDsm2tCLVS3P2dGaYhfU9fsoSq/wK/tXsdoWXvXdjHbbueyi1kTZqlnyT190UE',
|
||||
'vmDxH0yqquvUaf7+CNXC0T6l9gGS9p0x7xNydWRb7zeK1wIsYI+dRGQmzQARAQAB',
|
||||
'/gMDArgQHMknurQXy0Pho3Nsdu6zCUNXuplvaSXruefKsQn6eexGPnecNTT2iy5N',
|
||||
'70EK371D7GcNhhLsn8roUcj1Hi3kR14wXW7lcQBy9RRbbglIJXIqKJ8ywBEO8BaQ',
|
||||
'b0plL+w5A9EvX0BQc4d53MTqySh6POsEDOxPzH4D/JWbaozfmc4LfGDqH1gl7ebY',
|
||||
'iu81vnBuuskjpz8rxRI81MldJEIObrTE2x46DF7AmS6L6u/Qz3AAmZd89p5INCdx',
|
||||
'DemxzuMKpC3wSgdgSSKHHTKiNOMxiRd5mFH5v1KVcEG/TyXFlmah7RwA4rA4fjeo',
|
||||
'OpnbVWp6ciUniRvgLaCMMbmolAoho9zaLbPzCQVQ8F7gkrjnnPm4MKA+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j4AUNuLuUJeVghtz4Qt6dvjyz',
|
||||
'PlBvSF+ESqALjM8IqnG15FX4LmEDFrFcfNCsnmeyZ2nr1h2mV5jOON0EmBtCyhCt',
|
||||
'D/Ivi4/SZk+tBVhsBI+7ZECZYDJzZQnyPDsUv31MU4OwdWi7FhzHvDj/0bhYY7+I',
|
||||
'nwQYAQIACQUCUuot6AIbDAAKCRCSTaGiPl24PwYAA/sGIHvCKWP5+4ZlBHuOdbP9',
|
||||
'9v3PXFCm61qFEL0DTSq7NgBcuf0ASRElRI3wIKlfkwaiSzVPfNLiMTexdc7XaiTz',
|
||||
'CHaOn1Xl2gmYTq2KiJkgtLuwptYU1iSj7vvSHKy0+nYIckOZB4pRCOjknT08O4ZJ',
|
||||
'22q10ausyQXoOxXfDWVwKA==',
|
||||
'=IkKW',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
it('Decrypt message', function (done) {
|
||||
var privKey, message;
|
||||
|
||||
privKey = openpgp.key.readArmored(priv_key).keys[0];
|
||||
privKey.decrypt('1234');
|
||||
message = openpgp.message.readArmored(pgp_msg);
|
||||
|
||||
openpgp.decrypt({ privateKey:privKey, message:message }).then(function(decrypted) {
|
||||
expect(decrypted.data).to.equal('hello 3des\n');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AES encrypt, decrypt', function() {
|
||||
it('should encrypt and decrypt with one password', function(done) {
|
||||
var encOpt = {
|
||||
data: plaintext,
|
||||
|
|
|
@ -180,4 +180,11 @@ describe('Util unit tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Misc.", function() {
|
||||
it('util.decode_utf8 throws error if invalid parameter type', function () {
|
||||
var test = openpgp.util.decode_utf8.bind(null, {chameleon: true});
|
||||
expect(test).to.throw(Error, /Parameter "utf8" is not of type string/);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,10 +6,22 @@
|
|||
return new Promise(function(res, rej) { rej(val); });
|
||||
};
|
||||
|
||||
(typeof window !== 'undefined' ? window : global).tryWorker = function(name, tests, beforeFn, afterFn) {
|
||||
if (typeof window !== 'undefined' && window.Worker) {
|
||||
describe(name, function() {
|
||||
before(beforeFn);
|
||||
|
||||
tests();
|
||||
|
||||
after(afterFn);
|
||||
});
|
||||
} else {
|
||||
describe.skip(name + ' (No Web Worker support --> skipping tests)', tests);
|
||||
}
|
||||
};
|
||||
|
||||
describe('Unit Tests', function () {
|
||||
require('./crypto');
|
||||
require('./general');
|
||||
if (typeof window !== 'undefined') {
|
||||
require('./worker');
|
||||
}
|
||||
require('./worker');
|
||||
});
|
||||
|
|
|
@ -1,629 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var openpgp = typeof window != 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
|
||||
var pub_key_rsa =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'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_rsa =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||
'/nyBej9vZSRcaW5VpNNj0iA+c1/w2FPf84zNsTzvDmuMaNHFUzky4/vkYuZra//3',
|
||||
'+Ri7CF8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UMwZach28QwK',
|
||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||
'=lw5e',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
var pub_key_de =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||
'',
|
||||
'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||
'EslVgTd8IcUU14ZMOO7y91dw0KP4q61b4OIy7oVxzfFfKCC1s0Dc7GTay+qo5afJ',
|
||||
'wbWcgTyCIahTRmi5UepU7xdRHRMlqAclOwY2no8fw0JRQfFwRFCjbMdmvzC/k+Wo',
|
||||
'A42nn8YaSAG2v7OqF3rkYjkv/7iak48PO/l0Q13USAJLIWdHvRTir78mQUsEY0qR',
|
||||
'VoNqz5sMqakzhTvTav07EVy/1xC6GKoWXA9sdB/4r7+blVuu9M4yD40GkE69oAXO',
|
||||
'mz6tG3lRq41S0OSzNyDWtUQgMVF6wYqVxUGrAQDJM5A1rF1RKzFiHdkyy57E8LC1',
|
||||
'SIJyIXWJ0c5b8/olWQf9G5a17fMjkRTC3FO+ZHwFE1jIM6znYOF2GltDToLuJPq9',
|
||||
'lWrI7zVP9AJPwrUt7FK2MBNAvd1jKyIhdU98PBQ2pr+jmyqIycl9iDGXLDO7D7E/',
|
||||
'TBnxwQzoL/5b7UnPImuXOwv5JhVmyV2t003xjzb1EGggOnpKugUtVLps8JiLl9n+',
|
||||
'Nkj5wpU7NXbuHj2XGkkGmKkCIz4l0dJQR9V6svJV9By0RPgfGPXlN1VR6f2ounNy',
|
||||
'6REnDCQP9S3Li5eNcxlSGDIxIZL22j63sU/68GVlzqhVdGXxofv5jGtajiNSpPot',
|
||||
'ElZU0dusna4PzYmiBCsyN8jENWSzHLJ37N4ScN4b/gf6Axf9FU0PjzPBN1o9W6zj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kXZVtR1V8RDAD0zaVyM030e2zb',
|
||||
'zn4cGKDL2dmwk2ZBeXWZDgGKoKvGKYf8PRpTAYweFzol3OUdfXH5SngOylCD4OCL',
|
||||
's4RSVkSsllIWqLpnS5IJFgt6PDVcQgGXo2ZhVYkoLNhWTIEBuJWIyc4Vj20YpTms',
|
||||
'lgHnjeq5rP6781MwAJQnViyJ2SziGK4/+3CoDiQLO1zId42otXBvsbUuLSL5peX4',
|
||||
'v2XNVMLJMY5iSfzbBWczecyapiQ3fbVtWgucgrqlrqM3546v+GdATBhGOu8ppf5j',
|
||||
'7d1A7ohhBBgRCAAJBQJS1YHUAhsMAAoJELqZP8Ku4Yo6SgoBAIVcZstwz4lyA2et',
|
||||
'y61IhKbJCOlQxyem+kepjNapkhKDAQDIDL38bZWU4Rm0nq82Xb4yaI0BCWDcFkHV',
|
||||
'og2umGfGng==',
|
||||
'=v3+L',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
var priv_key_de =
|
||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||
'',
|
||||
'lQN5BFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||
'EslVgTd8IcUU14ZMOO7y91dw0KP4q61b4OIy7oVxzfFfKCC1s0Dc7GTay+qo5afJ',
|
||||
'wbWcgTyCIahTRmi5UepU7xdRHRMlqAclOwY2no8fw0JRQfFwRFCjbMdmvzC/k+Wo',
|
||||
'A42nn8YaSAG2v7OqF3rkYjkv/7iak48PO/l0Q13USAJLIWdHvRTir78mQUsEY0qR',
|
||||
'VoNqz5sMqakzhTvTav07EVy/1xC6GKoWXA9sdB/4r7+blVuu9M4yD40GkE69oAXO',
|
||||
'mz6tG3lRq41S0OSzNyDWtUQgMVF6wYqVxUGrAQDJM5A1rF1RKzFiHdkyy57E8LC1',
|
||||
'SIJyIXWJ0c5b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kA/A679f/+Izs1',
|
||||
'DHTORVqAOdoOcu5Qh7AQg1GdSmfFAsx2',
|
||||
'=kyeP',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
|
||||
var password1 = 'I am a password';
|
||||
var password2 = 'I am another password';
|
||||
|
||||
var pubKeyRSA, privKeyRSA, pubKeyDE, privKeyDE;
|
||||
|
||||
function initKeys() {
|
||||
pubKeyRSA = openpgp.key.readArmored(pub_key_rsa).keys[0];
|
||||
expect(pubKeyRSA).to.exist;
|
||||
privKeyRSA = openpgp.key.readArmored(priv_key_rsa).keys[0];
|
||||
expect(privKeyRSA).to.exist;
|
||||
pubKeyDE = openpgp.key.readArmored(pub_key_de).keys[0];
|
||||
expect(pubKeyDE).to.exist;
|
||||
privKeyDE = openpgp.key.readArmored(priv_key_de).keys[0];
|
||||
expect(privKeyDE).to.exist;
|
||||
}
|
||||
|
||||
describe('Init Worker', function() {
|
||||
|
||||
this.timeout(0);
|
||||
|
||||
it('openpgp.getWorker method', function (done) {
|
||||
expect(openpgp.getWorker()).to.be.null;
|
||||
var workerAvailable = openpgp.initWorker('../dist/openpgp.worker.js');
|
||||
expect(workerAvailable).to.be.true;
|
||||
expect(openpgp.getWorker()).to.exist;
|
||||
privKeyRSA = openpgp.key.readArmored(priv_key_rsa).keys[0];
|
||||
expect(privKeyRSA.primaryKey.isDecrypted).to.be.false;
|
||||
openpgp.getWorker().decryptKeyPacket(privKeyRSA, [privKeyRSA.primaryKey.getKeyId()], 'hello world').then(function(key) {
|
||||
expect(key.primaryKey.isDecrypted).to.be.true;
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
//}).catch(done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('High level API', function() {
|
||||
|
||||
this.timeout(0);
|
||||
|
||||
before(function() {
|
||||
openpgp.initWorker('../dist/openpgp.worker.js');
|
||||
initKeys();
|
||||
});
|
||||
|
||||
describe('Main', function(){
|
||||
it('Configuration', function(done){
|
||||
openpgp.config.show_version = false;
|
||||
openpgp.config.commentstring = 'different';
|
||||
openpgp.initWorker('../dist/openpgp.worker.js');
|
||||
openpgp.encryptMessage([pubKeyRSA], plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).not.to.match(/^Version:/);
|
||||
expect(data).to.match(/Comment: different/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Encryption', function() {
|
||||
it('AES: encryptMessage one password async', function (done) {
|
||||
openpgp.encryptMessage([], plaintext, password1).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('RSA: encryptMessage one key async', function (done) {
|
||||
openpgp.encryptMessage(pubKeyRSA, plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('RSA: encryptMessage one key one password async', function (done) {
|
||||
openpgp.encryptMessage(pubKeyRSA, plaintext, password1).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('RSA: encryptMessage one key two passwords async', function (done) {
|
||||
openpgp.encryptMessage(pubKeyRSA, plaintext, [password1, password2]).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('ELG: encryptMessage async', function (done) {
|
||||
openpgp.encryptMessage([pubKeyDE], plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Decryption', function() {
|
||||
|
||||
var msgRSA, msgDE, msgAES, keys, data;
|
||||
|
||||
before(function() {
|
||||
privKeyRSA.decrypt('hello world');
|
||||
privKeyDE.decrypt('hello world');
|
||||
msgRSA = openpgp.message.fromText(plaintext).encrypt([pubKeyRSA],[password1, password2]);
|
||||
msgDE = openpgp.message.fromText(plaintext).encrypt([pubKeyDE]);
|
||||
msgAES = openpgp.message.fromText(plaintext).encrypt([],[password1]);
|
||||
var dataIndex = msgAES.packets.indexOfTag(openpgp.enums.packet.symmetricallyEncrypted, openpgp.enums.packet.symEncryptedIntegrityProtected)[0];
|
||||
data = msgAES.packets.slice(dataIndex,msgAES.packets.length).write();
|
||||
});
|
||||
|
||||
it('RSA: decryptMessage async', function (done) {
|
||||
openpgp.decryptMessage(privKeyRSA, msgRSA).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('ELG: decryptMessage async', function (done) {
|
||||
openpgp.decryptMessage(privKeyDE, msgDE).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('AES: decryptMessage password1 async', function (done) {
|
||||
openpgp.decryptMessage(password1, msgRSA).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('AES: decryptMessage password2 async', function (done) {
|
||||
openpgp.decryptMessage(password2, msgRSA).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('RSA: decryptSessionKey/encryptSessionKey/decryptMessage async', function (done) {
|
||||
openpgp.decryptSessionKey(password1, msgAES).then(function(sk) {
|
||||
return openpgp.encryptSessionKey(sk.key, sk.algo, pubKeyRSA);
|
||||
}).then(function(keypacket) {
|
||||
var msg = openpgp.message.read(openpgp.util.concatUint8Array([keypacket, data]));
|
||||
return openpgp.decryptMessage(privKeyRSA, msg);
|
||||
}).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('AES: decryptSessionKey/encryptSessionKey/decryptMessage async', function (done) {
|
||||
openpgp.decryptSessionKey(password1, msgAES).then(function(sk) {
|
||||
return openpgp.encryptSessionKey(sk.key, sk.algo, [], password2);
|
||||
}).then(function(keypacket) {
|
||||
var msg = openpgp.message.read(openpgp.util.concatUint8Array([keypacket, data]));
|
||||
return openpgp.decryptMessage(password2, msg);
|
||||
}).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('AES: decryptSessionKey/decryptMessage with session key async', function (done) {
|
||||
openpgp.decryptSessionKey(password1, msgAES).then(function(sk) {
|
||||
var msg = openpgp.message.read(data);
|
||||
return openpgp.decryptMessage(sk.key, msg, {sessionKeyAlgorithm: sk.algo});
|
||||
}).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function verifySignature(data, privKey) {
|
||||
expect(data.text).to.equal(plaintext);
|
||||
expect(data.signatures).to.have.length(1);
|
||||
expect(data.signatures[0].valid).to.be.true;
|
||||
expect(data.signatures[0].keyid.equals(privKey.getSigningKeyPacket().getKeyId())).to.be.true;
|
||||
}
|
||||
|
||||
describe('Decrypt and Verify', function() {
|
||||
|
||||
var msgRSA, msgDE;
|
||||
|
||||
before(function() {
|
||||
privKeyRSA.decrypt('hello world');
|
||||
privKeyDE.decrypt('hello world');
|
||||
msgRSA = openpgp.message.fromText(plaintext).sign([privKeyRSA]).encrypt([pubKeyRSA]);
|
||||
msgDE = openpgp.message.fromText(plaintext).sign([privKeyDE]).encrypt([pubKeyDE]);
|
||||
});
|
||||
|
||||
it('RSA: decryptAndVerifyMessage async', function (done) {
|
||||
openpgp.decryptAndVerifyMessage(privKeyRSA, [pubKeyRSA], msgRSA).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
verifySignature(data, privKeyRSA);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('ELG: decryptAndVerifyMessage async', function (done) {
|
||||
openpgp.decryptAndVerifyMessage(privKeyDE, [pubKeyDE], msgDE).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
verifySignature(data, privKeyDE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Sign and Encrypt', function() {
|
||||
|
||||
before(function() {
|
||||
privKeyRSA.decrypt('hello world');
|
||||
});
|
||||
|
||||
it('RSA: signAndEncryptMessage async', function (done) {
|
||||
openpgp.signAndEncryptMessage([pubKeyRSA], privKeyRSA, plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/^-----BEGIN PGP MESSAGE/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
return openpgp.decryptAndVerifyMessage(privKeyRSA, [pubKeyRSA], msg);
|
||||
}).then(function(decrypted) {
|
||||
verifySignature(decrypted, privKeyRSA);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Signing', function() {
|
||||
|
||||
before(function() {
|
||||
privKeyRSA.decrypt('hello world');
|
||||
privKeyDE.decrypt('hello world');
|
||||
});
|
||||
|
||||
it('RSA: signClearMessage async', function (done) {
|
||||
openpgp.signClearMessage([privKeyRSA], plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/-----BEGIN PGP SIGNED MESSAGE-----/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('DSA: signClearMessage async', function (done) {
|
||||
openpgp.signClearMessage([privKeyDE], plaintext).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.match(/-----BEGIN PGP SIGNED MESSAGE-----/);
|
||||
var msg = openpgp.message.readArmored(data);
|
||||
expect(msg).to.be.an.instanceof(openpgp.message.Message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('RSA: verifyClearSignedMessage async', function (done) {
|
||||
openpgp.signClearMessage([privKeyRSA], plaintext).then(function(signed) {
|
||||
signed = openpgp.cleartext.readArmored(signed);
|
||||
return openpgp.verifyClearSignedMessage([pubKeyRSA], signed);
|
||||
}).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
verifySignature(data, privKeyRSA);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Error handling', function() {
|
||||
|
||||
before(initKeys);
|
||||
|
||||
it('Signing with not decrypted key gives error', function (done) {
|
||||
openpgp.signClearMessage([privKeyRSA], plaintext).catch(function(err) {
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Depleted random buffer in worker gives error', function (done) {
|
||||
var wProxy = new openpgp.AsyncProxy('../dist/openpgp.worker.js');
|
||||
wProxy.worker = new Worker('../dist/openpgp.worker.js');
|
||||
wProxy.worker.onmessage = wProxy.onMessage.bind(wProxy);
|
||||
wProxy.seedRandom(10);
|
||||
wProxy.encryptMessage([pubKeyRSA], plaintext).catch(function(err) {
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Key generation', function() {
|
||||
|
||||
it('Generate 1024-bit RSA/RSA key async', function (done) {
|
||||
var opt = {numBits: 1024, userId: 'Test McTestington <test@example.com>', passphrase: 'hello world'};
|
||||
openpgp.generateKeyPair(opt).then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data.publicKeyArmored).to.match(/^-----BEGIN PGP PUBLIC/);
|
||||
expect(data.privateKeyArmored).to.match(/^-----BEGIN PGP PRIVATE/);
|
||||
expect(data.key).to.be.an.instanceof(openpgp.key.Key);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Decrypt secret key', function() {
|
||||
|
||||
var msg, proxy;
|
||||
|
||||
beforeEach(function() {
|
||||
proxy = new openpgp.AsyncProxy('../dist/openpgp.worker.js');
|
||||
initKeys();
|
||||
msg = openpgp.message.fromText(plaintext).encrypt([pubKeyRSA]);
|
||||
});
|
||||
|
||||
it('Decrypt key', function (done) {
|
||||
expect(privKeyRSA.primaryKey.isDecrypted).to.be.false;
|
||||
expect(privKeyRSA.subKeys[0].subKey.isDecrypted).to.be.false;
|
||||
proxy.decryptKey(privKeyRSA, 'hello world').then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.be.an.instanceof(openpgp.key.Key);
|
||||
expect(data.primaryKey.isDecrypted).to.be.true;
|
||||
expect(data.subKeys[0].subKey.isDecrypted).to.be.true;
|
||||
return openpgp.decryptMessage(data, msg);
|
||||
}).then(function(text) {
|
||||
expect(text).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Decrypt key packet', function (done) {
|
||||
expect(privKeyRSA.primaryKey.isDecrypted).to.be.false;
|
||||
expect(privKeyRSA.subKeys[0].subKey.isDecrypted).to.be.false;
|
||||
var keyid = privKeyRSA.subKeys[0].subKey.getKeyId();
|
||||
proxy.decryptKeyPacket(privKeyRSA, [keyid], 'hello world').then(function(data) {
|
||||
expect(data).to.exist;
|
||||
expect(data).to.be.an.instanceof(openpgp.key.Key);
|
||||
expect(data.primaryKey.isDecrypted).to.be.false;
|
||||
expect(data.subKeys[0].subKey.isDecrypted).to.be.true;
|
||||
return openpgp.decryptMessage(data, msg);
|
||||
}).then(function(text) {
|
||||
expect(text).to.equal(plaintext);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Error on wrong password decryptKey', function (done) {
|
||||
proxy.decryptKey(privKeyRSA, 'what?').catch(function(err) {
|
||||
expect(err.message).to.eql('Wrong password');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Error on wrong password decryptKeyPacket', function (done) {
|
||||
var keyid = privKeyRSA.subKeys[0].subKey.getKeyId();
|
||||
proxy.decryptKeyPacket(privKeyRSA, [keyid], 'what?').catch(function(err) {
|
||||
expect(err.message).to.eql('Wrong password');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Random Buffer', function() {
|
||||
|
||||
var randomBuffer;
|
||||
|
||||
before(function() {
|
||||
randomBuffer = new openpgp.crypto.random.randomBuffer.constructor();
|
||||
expect(randomBuffer).to.exist;
|
||||
});
|
||||
|
||||
it('Throw error if not initialized', function () {
|
||||
expect(randomBuffer.set.bind(randomBuffer)).to.throw('RandomBuffer is not initialized');
|
||||
expect(randomBuffer.get.bind(randomBuffer)).to.throw('RandomBuffer is not initialized');
|
||||
});
|
||||
|
||||
it('Initialization', function () {
|
||||
randomBuffer.init(5);
|
||||
expect(randomBuffer.buffer).to.exist;
|
||||
expect(randomBuffer.buffer).to.have.length(5);
|
||||
expect(randomBuffer.size).to.equal(0);
|
||||
});
|
||||
|
||||
function equal(buf, arr) {
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
if (buf[i] !== arr[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
it('Set Method', function () {
|
||||
randomBuffer.init(5);
|
||||
var buf = new Uint32Array(2);
|
||||
expect(randomBuffer.set.bind(randomBuffer, buf)).to.throw('Invalid type: buf not an Uint8Array');
|
||||
buf = new Uint8Array(2);
|
||||
buf[0] = 1; buf[1] = 2;
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,0,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(2);
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,1,2,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(4);
|
||||
randomBuffer.set(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,1,2,1])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(5);
|
||||
randomBuffer.init(1);
|
||||
buf = new Uint8Array(2);
|
||||
buf[0] = 1; buf[1] = 2;
|
||||
randomBuffer.set(buf);
|
||||
expect(buf).to.to.have.property('0', 1);
|
||||
expect(randomBuffer.size).to.equal(1);
|
||||
});
|
||||
|
||||
it('Get Method', function () {
|
||||
randomBuffer.init(5);
|
||||
var buf = new Uint8Array(5);
|
||||
buf[0] = 1; buf[1] = 2; buf[2] = 5; buf[3] = 7; buf[4] = 8;
|
||||
randomBuffer.set(buf);
|
||||
buf = new Uint32Array(2);
|
||||
expect(randomBuffer.get.bind(randomBuffer, buf)).to.throw('Invalid type: buf not an Uint8Array');
|
||||
buf = new Uint8Array(2);
|
||||
randomBuffer.get(buf);
|
||||
expect(equal(randomBuffer.buffer, [1,2,5,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(3);
|
||||
expect(buf).to.to.have.property('0', 8);
|
||||
expect(buf).to.to.have.property('1', 7);
|
||||
randomBuffer.get(buf);
|
||||
expect(buf).to.to.have.property('0', 5);
|
||||
expect(buf).to.to.have.property('1', 2);
|
||||
expect(equal(randomBuffer.buffer, [1,0,0,0,0])).to.be.true;
|
||||
expect(randomBuffer.size).to.equal(1);
|
||||
expect(function() { randomBuffer.get(buf) }).to.throw('Random number buffer depleted');
|
||||
});
|
||||
|
||||
});
|
60
test/worker/async_proxy.js
Normal file
60
test/worker/async_proxy.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* globals tryWorker: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var pub_key =
|
||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||
'',
|
||||
'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 plaintext = 'short message\nnext line\n한국어/조선말';
|
||||
var pubKey;
|
||||
|
||||
tryWorker('Async Proxy', tests, function() {
|
||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||
pubKey = openpgp.key.readArmored(pub_key).keys[0];
|
||||
}, function() {
|
||||
openpgp.destroyWorker();
|
||||
});
|
||||
|
||||
function tests() {
|
||||
|
||||
describe('Error handling', function() {
|
||||
it('Depleted random buffer in worker gives error', function (done) {
|
||||
var wProxy = new openpgp.AsyncProxy({ path:'../dist/openpgp.worker.js' });
|
||||
wProxy.worker = new Worker('../dist/openpgp.worker.js');
|
||||
wProxy.worker.onmessage = wProxy.onMessage.bind(wProxy);
|
||||
wProxy.seedRandom(10);
|
||||
wProxy.delegate('encrypt', { publicKeys:[pubKey], data:plaintext }).catch(function(err) {
|
||||
expect(err.message).to.match(/Random number buffer depleted/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
describe('Web Worker', function () {
|
||||
require('./api.js');
|
||||
require('./async_proxy.js');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user