Merge pull request #139 from Robert-Nelson/keyring

Reworked keyring and added new keyring bundle
This commit is contained in:
Thomas Oberndörfer 2013-12-09 03:38:57 -08:00
commit 4979550729
30 changed files with 605 additions and 15814 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ build/
node_modules/
npm*
test/lib/
test/test-bundle.js
resources/keyring_nodebug.js
resources/openpgp_nodebug.js

View File

@ -4,30 +4,50 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
openpgp_nodebug: {
files: {
'resources/openpgp_nodebug.js': []
},
options: {
alias: './src/:openpgp'
}
},
openpgp: {
files: {
'resources/openpgp.js': []
},
options: {
debug: true,
alias: './src/:openpgp'
}
},
openpgp_debug: {
keyring_nodebug: {
files: {
'resources/openpgp.debug.js': []
'resources/keyring_nodebug.js': []
},
options: {
alias: './src/keyring/:keyring',
external: [ 'openpgp' ]
}
},
keyring: {
files: {
'resources/keyring.js': []
},
options: {
debug: true,
alias: './src/:openpgp'
alias: './src/keyring/:keyring',
external: [ 'openpgp' ]
}
},
unittests: {
files: {
'test/test-bundle.js': []
'test/lib/test-bundle.js': []
},
options: {
debug: true,
alias: './test/test-all.js:test-bundle.js'
alias: './test/test-all.js:unittests',
external: [ 'openpgp', 'keyring' ]
}
},
ci_tests: {
@ -37,7 +57,7 @@ module.exports = function(grunt) {
options: {
debug: true,
alias: './test/ci-tests-all.js:ci-tests',
external: [ 'openpgp' ]
external: [ 'openpgp', 'keyring' ]
}
}
},
@ -49,12 +69,21 @@ module.exports = function(grunt) {
from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
}]
},
openpgpjs_nodebug: {
src: ['resources/openpgp_nodebug.js'],
dest: ['resources/openpgp_nodebug.js'],
replacements: [{
from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
}]
}
},
uglify: {
openpgpjs: {
files: {
"resources/openpgp.min.js" : [ "resources/openpgp.js" ]
"resources/openpgp.min.js" : [ "resources/openpgp_nodebug.js" ],
"resources/keyring.min.js" : [ "resources/keyring_nodebug.js" ]
}
},
options: {
@ -95,7 +124,7 @@ module.exports = function(grunt) {
openpgp: {
expand: true,
cwd: 'resources/',
src: ['openpgp.debug.js', 'jquery.min.js'],
src: ['openpgp.js', 'keyring.js', 'jquery.min.js'],
dest: 'test/lib/'
}
}

View File

@ -31,11 +31,13 @@ lint:
@./scripts/lint.sh
bundle:
@browserify -r ./src/:openpgp > ./resources/openpgp.js
@browserify -d -r ./src/:openpgp > ./resources/openpgp.debug.js
@browserify -d -r ./src/:openpgp > ./resources/openpgp.js
@browserify -r ./src/:openpgp > ./resources/openpgp_nodebug.js
@browserify -d -x openpgp -r ./src/keyring/:keyring > ./resources/keyring.js
@browserify -x openpgp -r ./src/keyring/:keyring > ./resources/keyring_nodebug.js
bundle-test:
@browserify -d -r ./test/test-all.js:test-bundle.js > ./test/test-bundle.js
@browserify -d -r ./test/test-all.js:unittests > ./test/lib/test-bundle.js
bundle-ci-test:
@browserify -d -x openpgp -r ./test/ci-tests-all.js:ci-tests > ./test/lib/ci-tests-bundle.js

234
resources/keyring.js Normal file

File diff suppressed because one or more lines are too long

1
resources/keyring.min.js vendored Normal file
View File

@ -0,0 +1 @@
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v0.0.1 - 2013-12-09 */require=function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({RRTcVk:[function(a,b){b.exports=a("./keyring.js"),b.exports.localstore=a("./localstore.js")},{"./keyring.js":3,"./localstore.js":4}],keyring:[function(a,b){b.exports=a("RRTcVk")},{}],3:[function(a,b){var c=a("openpgp"),d=function(){function b(b){this.storeHandler=b?b:a("./localstore"),this.keys=[],this.storeHandler.init(this.keys)}function d(a,b){a=a.toLowerCase();for(var c,d=b.getUserIds();c<d.length;c++)if(keyEmail=d[c].split("<")[1].split(">")[0].trim().toLowerCase(),keyEmail==a)return!0;return!1}function e(a,b){for(var d=b.getKeyIds(),e=0;e<d.length;e++)return c.util.hexstrdump(d[e].write())==a?!0:!1}function f(a,b,d,e){for(var f=[],g=0;g<a.length;g++){var h=a[g];switch(e){case c.enums.packet.public_key:h.isPublic()&&b(d,h)&&f.push(h);break;case c.enums.packet.private_key:h.isPrivate()&&b(d,h)&&f.push(h)}}return f}function g(a){return f(this.keys,d,a,c.enums.packet.public_key)}function h(a){return f(this.keys,d,a,c.enums.packet.secret_key)}function i(a){return this.checkForIdentityAndKeyTypeMatch(this.keys,e,a,c.enums.packet.public_key)}function j(a){return this.keys.push(c.key.readArmored(a)),!0}function k(a){return this.keys[a].armor()}function l(a){var b=this.keys.splice(a,1);return b}function m(a){return this.keys[a].toPublic().armor()}this.keys=[],this.init=b,this.store=function(){this.storeHandler.store(this.keys)},this.checkForIdentityAndKeyTypeMatch=f,this.getPublicKeyForAddress=g,this.getPrivateKeyForAddress=h,this.getKeysForKeyId=i,this.importKey=j,this.exportKey=k,this.removeKey=l,this.exportPublicKey=m};b.exports=new d},{"./localstore":4}],4:[function(a,b){var c=a("openpgp"),d=function(){function a(a){var b=JSON.parse(window.localStorage.getItem("armoredKeys"));if(null!==b&&0===b.length)for(var d,e=0;e<b.length;e++)d=c.key.readArmored(b[e]),a.push(d);else this.keys=[]}function b(a){for(var b=[],c=0;c<a.length;c++)b.push(a[c].armor());window.localStorage.setItem("armoredKeys",JSON.stringify(b))}this.init=a,this.store=b};b.exports=new d},{}]},{},[]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -119,6 +119,19 @@ Key.prototype.getPrivateKeyPacket = function(keyIds) {
return findKey(keys, keyIds);
};
/**
* Returns userids
* @return {string} userid[]
*/
Key.prototype.getUserIds = function() {
var userids = [];
var useridPackets = this.packets.filterByTag(enums.packet.userid);
for (var i = 0; i < useridPackets.length; i++) {
userids.push(useridPackets[i].write());
}
return userids;
};
/**
* Returns true if this is a public key
* @return {Boolean}

View File

@ -1,189 +0,0 @@
// GPG4Browsers - An OpenPGP implementation in javascript
// Copyright (C) 2011 Recurity Labs GmbH
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
var packet = require('./packet');
var enums = require('./enums.js');
var armor = require('./encoding/armor.js');
/**
* @class
* @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
*/
var keyring = function() {
this.armoredPacketlists = [];
this.parsedPacketlists = [];
/**
* Initialization routine for the keyring. This method reads the
* keyring from HTML5 local storage and initializes this instance.
* This method is called by openpgp.init().
*/
function init() {
var armoredPacketlists = JSON.parse(window.localStorage.getItem("armoredPacketlists"));
if (armoredPacketlists === null || armoredPacketlists.length === 0) {
armoredPacketlists = [];
}
this.armoredPacketlists = armoredPacketlists;
var packetlist;
for (var i = 0; i < armoredPacketlists.length; i++) {
packetlist = new packet.list();
packetlist.read(armoredPacketlists[i]);
this.parsedPacketlists.push(packetlist);
}
}
this.init = init;
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
*/
function store() {
window.localStorage.setItem("armoredPacketlists", JSON.stringify(this.armoredPacketlists));
}
this.store = store;
function emailPacketCheck(packet, email) {
var emailMatch = false;
var packetEmail;
email = email.toLowerCase();
if (packet.tag == enums.packet.userid) {
packetEmail = packet.userid;
//we need to get just the email from the userid packet
packetEmail = packetEmail.split('<')[1].split('<')[0].trim.toLowerCase();
if (packetEmail == email) {
emailMatch = true;
}
}
return emailMatch;
}
function idPacketCheck(packet, id) {
if (packet.getKeyId && packet.getKeyId().write() == id) {
return true;
}
return false;
}
function helperCheckIdentityAndPacketMatch(identityFunction, identityInput, packetType, packetlist) {
var packet;
for (var l = 0; l < packetlist.length; l++) {
packet = packetlist[l];
identityMatch = identityFunction(packet, identityInput);
if (!packetType) {
packetMatch = true;
} else if (packet.tag == packetType) {
packetMatch = true;
}
if (packetMatch && identityMatch) {
return true;
}
}
return false;
}
function checkForIdentityAndPacketMatch(identityFunction, identityInput, packetType) {
var results = [];
var packetlist;
var identityMatch;
var packetMatch;
for (var p = 0; p < this.parsedPacketlists.length; p++) {
identityMatch = false;
packetMatch = false;
packetlist = this.parsedPacketlists[p];
if (helperCheckIdentityAndPacketMatch(identityFunction, identityInput, packetType, packetlist)) {
results.push(packetlist);
}
}
return results;
}
this.checkForIdentityAndPacketMatch = checkForIdentityAndPacketMatch;
/**
* searches all public keys in the keyring matching the address or address part of the user ids
* @param {String} email_address
* @return {openpgp_msg_publickey[]} The public keys associated with provided email address.
*/
function getPublicKeyForAddress(email) {
return checkForIdentityAndPacketMatch(emailPacketCheck, email, enums.packet.public_key);
}
this.getPublicKeyForAddress = getPublicKeyForAddress;
/**
* Searches the keyring for a private key containing the specified email address
* @param {String} email_address email address to search for
* @return {openpgp_msg_privatekey[]} private keys found
*/
function getPrivateKeyForAddress(email_address) {
return checkForIdentityAndPacketMatch(emailPacketCheck, email, enums.packet.secret_key);
}
this.getPrivateKeyForAddress = getPrivateKeyForAddress;
/**
* Searches the keyring for public keys having the specified key id
* @param {String} keyId provided as string of hex number (lowercase)
* @return {openpgp_msg_privatekey[]} public keys found
*/
function getPacketlistsForKeyId(keyId) {
return this.checkForIdentityAndPacketMatch(idPacketCheck, keyId);
}
this.getPacketlistsForKeyId = getPacketlistsForKeyId;
/**
* Imports a packet list (public or private key block) from an ascii armored message
* @param {String} armored message to read the packets/key from
*/
function importPacketlist(armored) {
this.armoredPacketlists.push(armored);
var dearmored = armor.decode(armored.replace(/\r/g, '')).data;
packetlist = new packet.list();
packetlist.read(dearmored);
this.parsedPacketlists.push(packetlist);
return true;
}
this.importPacketlist = importPacketlist;
/**
* TODO
* returns the openpgp_msg_privatekey representation of the public key at public key ring index
* @param {Integer} index the index of the public key within the publicKeys array
* @return {openpgp_msg_privatekey} the public key object
*/
function exportPublicKey(index) {
return this.publicKey[index];
}
this.exportPublicKey = exportPublicKey;
/**
* TODO
* Removes a public key from the public key keyring at the specified index
* @param {Integer} index the index of the public key within the publicKeys array
* @return {openpgp_msg_privatekey} The public key object which has been removed
*/
function removePublicKey(index) {
var removed = this.publicKeys.splice(index, 1);
this.store();
return removed;
}
this.removePublicKey = removePublicKey;
};
module.exports = new keyring();

3
src/keyring/index.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = require('./keyring.js');
module.exports.localstore = require('./localstore.js');

162
src/keyring/keyring.js Normal file
View File

@ -0,0 +1,162 @@
// GPG4Browsers - An OpenPGP implementation in javascript
// Copyright (C) 2011 Recurity Labs GmbH
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
var openpgp = require('openpgp');
/**
* @class
* @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
*/
var keyring = function() {
this.keys = [];
/**
* Initialization routine for the keyring. This method reads the
* keyring from HTML5 local storage and initializes this instance.
* This method is called by openpgp.init().
*/
function init(storeHandler) {
this.storeHandler = storeHandler ? storeHandler : require('./localstore');
this.keys = [];
this.storeHandler.init(this.keys);
}
this.init = init;
this.store = function () {
this.storeHandler.store(this.keys);
}
function emailCheck(email, key) {
email = email.toLowerCase();
var keyEmails = key.getUserIds();
for (var i; i < keyEmails.length; i++) {
//we need to get just the email from the userid key
keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase();
if (keyEmail == email) {
return true;
}
}
return false;
}
function idCheck(id, key) {
var keyids = key.getKeyIds();
for (var i = 0; i < keyids.length; i++) {
if (openpgp.util.hexstrdump(keyids[i].write()) == id) {
return true;
}
return false;
}
}
function checkForIdentityAndKeyTypeMatch(keys, identityFunction, identityInput, keyType) {
var results = [];
for (var p = 0; p < keys.length; p++) {
var key = keys[p];
switch (keyType) {
case openpgp.enums.packet.public_key:
if (key.isPublic() && identityFunction(identityInput, key)) {
results.push(key);
}
break;
case openpgp.enums.packet.private_key:
if (key.isPrivate() && identityFunction(identityInput, key)) {
results.push(key);
}
break;
}
}
return results;
}
this.checkForIdentityAndKeyTypeMatch = checkForIdentityAndKeyTypeMatch;
/**
* searches all public keys in the keyring matching the address or address part of the user ids
* @param {String} email email address to search for
* @return {openpgp.key.Key[]} The public keys associated with provided email address.
*/
function getPublicKeyForAddress(email) {
return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.public_key);
}
this.getPublicKeyForAddress = getPublicKeyForAddress;
/**
* Searches the keyring for a private key containing the specified email address
* @param {String} email email address to search for
* @return {openpgp.key.Key[]} private keys found
*/
function getPrivateKeyForAddress(email) {
return checkForIdentityAndKeyTypeMatch(this.keys, emailCheck, email, openpgp.enums.packet.secret_key);
}
this.getPrivateKeyForAddress = getPrivateKeyForAddress;
/**
* Searches the keyring for public keys having the specified key id
* @param {String} keyId provided as string of hex number (lowercase)
* @return {openpgp.key.Key[]} public keys found
*/
function getKeysForKeyId(keyId) {
return this.checkForIdentityAndKeyTypeMatch(this.keys, idCheck, keyId, openpgp.enums.packet.public_key);
}
this.getKeysForKeyId = getKeysForKeyId;
/**
* Imports a key from an ascii armored message
* @param {String} armored message to read the keys/key from
*/
function importKey(armored) {
this.keys.push(openpgp.key.readArmored(armored));
return true;
}
this.importKey = importKey;
/**
* returns the armored message representation of the key at key ring index
* @param {Integer} index the index of the key within the array
* @return {String} armored message representing the key object
*/
function exportKey(index) {
return this.keys[index].armor();
}
this.exportKey = exportKey;
/**
* Removes a public key from the public key keyring at the specified index
* @param {Integer} index the index of the public key within the publicKeys array
* @return {openpgp.key.Key} The public key object which has been removed
*/
function removeKey(index) {
var removed = this.keys.splice(index, 1);
return removed;
}
this.removeKey = removeKey;
/**
* returns the armored message representation of the public key portion of the key at key ring index
* @param {Integer} index the index of the key within the array
* @return {String} armored message representing the public key object
*/
function exportPublicKey(index) {
return this.keys[index].toPublic().armor();
}
this.exportPublicKey = exportPublicKey;
};
module.exports = new keyring();

58
src/keyring/localstore.js Normal file
View File

@ -0,0 +1,58 @@
// GPG4Browsers - An OpenPGP implementation in javascript
// Copyright (C) 2011 Recurity Labs GmbH
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
var openpgp = require('openpgp');
/**
* @class
* @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
*/
var localstore = function() {
/**
* Initialization routine for the keyring. This method reads the
* keyring from HTML5 local storage and initializes this instance.
* This method is called by openpgp.init().
*/
function init(keys) {
var armoredKeys = JSON.parse(window.localStorage.getItem("armoredKeys"));
if (armoredKeys !== null && armoredKeys.length === 0) {
var key;
for (var i = 0; i < armoredKeys.length; i++) {
key = openpgp.key.readArmored(armoredKeys[i]);
keys.push(key);
}
} else {
this.keys = [];
}
}
this.init = init;
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
*/
function store(keys) {
var armoredKeys = [];
for (var i = 0; i < keys.length; i++) {
armoredKeys.push(keys[i].armor());
}
window.localStorage.setItem("armoredKeys", JSON.stringify(armoredKeys));
}
this.store = store;
};
module.exports = new localstore();

View File

@ -1,5 +1,5 @@
var openpgp = require('openpgp');
//keyring = require('../../src/keyring.js');
var openpgp = require('openpgp'),
keyring = require('keyring');
'use strict';
@ -61,17 +61,49 @@ describe('Openpgp integration tests', function() {
});
});
// describe('Import key pair', function() {
// it('should work', function(done) {
// // clear any keypair already in the keychain
// keyring.init();
// // import private key
// keyring.importPacketlist(privkey);
// // import public key
// keyring.importPacketlist(pubkey);
// done();
// });
// });
describe('Keyring', function() {
describe('Import key pair', function() {
it('should work', function(done) {
// clear any keypair already in the keychain
keyring.init();
keyring.importKey(privkey);
keyring.importKey(pubkey);
done();
});
});
describe('Retrieve keys', function() {
it('getPublicKeyForAddress() - unknown address', function(done) {
var key = keyring.getPublicKeyForAddress('nobody@example.com');
expect(key).to.be.empty;
done();
});
it('getPublicKeyForAddress() - valid address', function(done) {
var key = keyring.getPublicKeyForAddress(user);
expect(key).to.exist;
done();
});
it('getPrivateKeyForAddress() - unknown address', function(done) {
var key = keyring.getPrivateKeyForAddress('nobody@example.com');
expect(key).to.be.empty;
done();
});
it('getPrivateKeyForAddress() - valid address', function(done) {
var key = keyring.getPrivateKeyForAddress(user);
expect(key).to.exist;
done();
});
it('getKeysForKeyId() - unknown id', function(done) {
var keys = keyring.getKeysForKeyId('000102030405060708');
expect(keys).to.be.empty;
done();
});
it('getKeysForKeyId() - valid id', function(done) {
var keys = keyring.getKeysForKeyId(keyId.toLowerCase());
expect(keys).to.exist.and.have.length(1);
done();
});
});
});
describe('Encryption', function() {
var message = 'asdfs\n\nThursday, Nov 21, 2013 7:38 PM asdf@example.com wrote:\n' +

View File

@ -10,7 +10,8 @@
<div id="mocha"></div>
<!--<script src="lib/jquery.min.js"></script>-->
<script src="lib/openpgp.debug.js"></script>
<script src="lib/openpgp.js"></script>
<script src="lib/keyring.js"></script>
<script src="lib/chai.js"></script>
<script src="lib/sinon.js"></script>
<script src="lib/mocha.js"></script>

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("AES Rijndael cipher test with test vectors from ecb_tbl.txt", function() {
var openpgp = require('../../../');
var openpgp = require('openpgp');
var util = openpgp.util;
var result = new Array();

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("Blowfish cipher test with test vectors from http://www.schneier.com/code/vectors.txt", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util,
BFencrypt = openpgp.crypto.cipher.blowfish;

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("CAST-128 cipher test with test vectors from RFC2144", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util;
var result = [];

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("TripleDES (EDE) cipher test with test vectors from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util;
var result = [];
@ -99,7 +99,7 @@ unit.register("TripleDES (EDE) cipher test with test vectors from http://csrc.ni
unit.register("DES encrypt/decrypt padding tests", function () {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util;
var result = [];

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("Twofish test with test vectors from http://www.schneier.com/code/ecb_ival.txt", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util;
function TFencrypt(block, key) {

View File

@ -1,7 +1,7 @@
var unit = require('../unit.js');
unit.register("Functional testing of openpgp.crypto.* methods", function() {
var openpgp = require('../../');
var openpgp = require('openpgp');
var util = openpgp.util;
var result = [];
var RSApubMPIstrs = [

Binary file not shown.

View File

@ -1,7 +1,7 @@
var unit = require('../../unit.js');
unit.register("MD5 test with test vectors from RFC 1321", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util,
MD5 = openpgp.crypto.hash.md5;

View File

@ -2,7 +2,7 @@ var unit = require('../../unit.js');
unit.register("RIPE-MD 160 bits test with test vectors from http://homes.esat.kuleuven.be/~bosselae/ripemd160.html", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util,
RMDstring = openpgp.crypto.hash.ripemd;

View File

@ -2,7 +2,7 @@ var unit = require('../../unit.js');
unit.register("SHA* test with test vectors from NIST FIPS 180-2", function() {
var openpgp = require('../../../'),
var openpgp = require('openpgp'),
util = openpgp.util,
hash = openpgp.crypto.hash;

View File

@ -1,7 +1,7 @@
var unit = require('../unit.js');
unit.register("Key generation/encryption/decryption", function() {
var openpgp = require('../../');
var openpgp = require('openpgp');
var result = [];
var testHelper = function(passphrase, userid, message) {
var key = openpgp.generateKeyPair(openpgp.enums.publicKey.rsa_encrypt_sign, 512,
@ -37,7 +37,7 @@ unit.register("Key generation/encryption/decryption", function() {
});
unit.register("Message encryption/decryption", function() {
var openpgp = require('../../');
var openpgp = require('openpgp');
var result = [];

View File

@ -1,8 +1,8 @@
var unit = require('../unit.js');
unit.register("Keyring testing", function() {
var openpgp = require('../../');
var keyring = require('../../src/keyring.js');
var openpgp = require('openpgp');
var keyring = require('keyring');
var result = [];
// Exercises the ability of openpgp_keyring.getPublicKeysForKeyId to return subkeys

View File

@ -2,7 +2,7 @@ var unit = require('../unit.js');
unit.register("Packet testing", function() {
var openpgp = require('../../');
var openpgp = require('openpgp');
var armored_key =
'-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +

View File

@ -1,7 +1,7 @@
var unit = require('../unit.js');
unit.register("Signature testing", function() {
var openpgp = require('../../');
var openpgp = require('openpgp');
var priv_key_arm1 =
[ '-----BEGIN PGP PRIVATE KEY BLOCK-----',
@ -459,4 +459,4 @@ var pub_key_arm3 =
return results;
});
});

View File

@ -56,10 +56,12 @@
</style>
<script src="lib/openpgp.js"></script>
<script src="lib/keyring.js"></script>
<script src="lib/test-bundle.js"></script>
<script type="text/javascript">
var test = require('test-bundle.js');
var test = require('unittests');
function unit_tests() {
var table = document.getElementById('unittests');

File diff suppressed because one or more lines are too long