Add files missed in last commit

This commit is contained in:
Robert Nelson 2014-01-09 02:47:57 -08:00
parent 3680695a69
commit 9f4e6e7ebb
37 changed files with 166 additions and 116 deletions

View File

@ -6,42 +6,23 @@ module.exports = function(grunt) {
browserify: { browserify: {
openpgp_nodebug: { openpgp_nodebug: {
files: { files: {
'resources/openpgp_nodebug.js': [] 'dist/openpgp_nodebug.js': []
}, },
options: { options: {
alias: './src/:openpgp', alias: [ './src/:openpgp' ],
external: [ 'crypto', 'node-localstorage' ] external: [ 'crypto', 'node-localstorage' ]
} }
}, },
openpgp: { openpgp: {
files: { files: {
'resources/openpgp.js': [] 'dist/openpgp.js': []
}, },
options: { options: {
debug: true, debug: true,
alias: './src/:openpgp', alias: [ './src/:openpgp' ],
external: [ 'crypto', 'node-localstorage' ] external: [ 'crypto', 'node-localstorage' ]
} }
}, },
keyring_nodebug: {
files: {
'resources/keyring_nodebug.js': []
},
options: {
alias: './src/keyring/:keyring',
external: [ 'openpgp', 'node-localstorage' ]
}
},
keyring: {
files: {
'resources/keyring.js': []
},
options: {
debug: true,
alias: './src/keyring/:keyring',
external: [ 'openpgp', 'node-localstorage' ]
}
},
unittests: { unittests: {
files: { files: {
'test/lib/unittests-bundle.js': [] 'test/lib/unittests-bundle.js': []
@ -49,22 +30,22 @@ module.exports = function(grunt) {
options: { options: {
debug: true, debug: true,
alias: './test/unittests.js:unittests', alias: './test/unittests.js:unittests',
external: [ 'openpgp', 'keyring', 'node-localstorage' ] external: [ 'openpgp' ]
} }
} }
}, },
replace : { replace: {
openpgpjs: { openpgpjs: {
src: ['resources/openpgp.js'], src: ['dist/openpgp.js'],
dest: ['resources/openpgp.js'], dest: ['dist/openpgp.js'],
replacements: [{ replacements: [{
from: /OpenPGP.js VERSION/g, from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>' to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
}] }]
}, },
openpgpjs_nodebug: { openpgpjs_nodebug: {
src: ['resources/openpgp_nodebug.js'], src: ['dist/openpgp_nodebug.js'],
dest: ['resources/openpgp_nodebug.js'], dest: ['dist/openpgp_nodebug.js'],
replacements: [{ replacements: [{
from: /OpenPGP.js VERSION/g, from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>' to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>'
@ -74,8 +55,7 @@ module.exports = function(grunt) {
uglify: { uglify: {
openpgpjs: { openpgpjs: {
files: { files: {
"resources/openpgp.min.js" : [ "resources/openpgp_nodebug.js" ], 'dist/openpgp.min.js' : [ 'dist/openpgp_nodebug.js' ]
"resources/keyring.min.js" : [ "resources/keyring_nodebug.js" ]
} }
}, },
options: { options: {
@ -83,11 +63,9 @@ module.exports = function(grunt) {
'<%= grunt.template.today("yyyy-mm-dd") %> */' '<%= grunt.template.today("yyyy-mm-dd") %> */'
} }
}, },
prepare_install: { jsbeautifier: {
}, files: ['src/**/*.js'],
jsbeautifier : { options: {
files : ["src/**/*.js"],
options : {
indent_size: 2, indent_size: 2,
preserve_newlines: true, preserve_newlines: true,
keep_array_indentation: false, keep_array_indentation: false,
@ -95,20 +73,27 @@ module.exports = function(grunt) {
wrap_line_length: 120 wrap_line_length: 120
} }
}, },
jshint : { jshint: {
all : ["src/**/*.js"] all: ['src/**/*.js']
}, },
jsdoc : { jsdoc: {
dist : { dist: {
src: ["README.md", "src"], src: ['README.md', 'src'],
options: { options: {
destination: "doc", destination: 'doc',
recurse: true, recurse: true,
template: "jsdoc.template" template: 'jsdoc.template'
} }
} }
}, },
mochaTest: {
unittests: {
options: {
reporter: 'spec'
},
src: [ 'test/unittests.js' ]
}
},
copy: { copy: {
npm: { npm: {
expand: true, expand: true,
@ -120,24 +105,23 @@ module.exports = function(grunt) {
} }
}); });
// Load the plugin that provides the "uglify" task. // Load the plugin(s)
grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-text-replace'); grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-prepare-install');
grunt.loadNpmTasks('grunt-jsbeautifier'); grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdoc'); grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('default', 'Build OpenPGP.js', function() { grunt.registerTask('default', 'Build OpenPGP.js', function() {
grunt.task.run(['browserify', 'replace', 'uglify']); grunt.task.run(['browserify', 'replace', 'uglify', 'npm_pack']);
//TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun //TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun
grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.'); grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.');
}); });
grunt.registerTask('documentation', ['jsdoc']);
// Load the plugin(s) grunt.registerTask('documentation', ['jsdoc']);
grunt.loadNpmTasks('grunt-contrib-copy');
// Alias the `mocha_phantomjs` task to run `mocha-phantomjs` // Alias the `mocha_phantomjs` task to run `mocha-phantomjs`
grunt.registerTask('mocha_phantomjs', 'mocha-phantomjs', function () { grunt.registerTask('mocha_phantomjs', 'mocha-phantomjs', function () {
@ -149,6 +133,25 @@ module.exports = function(grunt) {
mocha.stderr.pipe(process.stderr); mocha.stderr.pipe(process.stderr);
}); });
// Test/Dev tasks // Alias the `npm_pack` task to run `npm pack`
grunt.registerTask('test', ['copy', 'mocha_phantomjs']); grunt.registerTask('npm_pack', 'npm pack', function () {
var done = this.async();
var npm = require('child_process').exec('npm pack ../', { cwd: 'dist'}, function (err, stdout) {
var package = stdout;
if (err === null) {
var install = require('child_process').exec('npm install dist/' + package, function (err) {
done(err);
});
install.stdout.pipe(process.stdout);
install.stderr.pipe(process.stderr);
} else {
done(err);
}
});
npm.stdout.pipe(process.stdout);
npm.stderr.pipe(process.stderr);
});
// Test/Dev tasks
grunt.registerTask('test', ['copy', 'mocha_phantomjs', 'mochaTest']);
}; };

View File

@ -4,11 +4,14 @@
"engines": { "engines": {
"node": ">=0.8" "node": ">=0.8"
}, },
"main": "src/index.js",
"directories": { "directories": {
"lib": "src" "lib": "src"
}, },
"main": "src/index.js", "files": [
"files": [ "src" ], "src",
"test"
],
"scripts": { "scripts": {
"pretest": "grunt", "pretest": "grunt",
"test": "grunt test" "test": "grunt test"
@ -26,6 +29,14 @@
"grunt-text-replace": "*", "grunt-text-replace": "*",
"grunt-jsbeautifier": "*", "grunt-jsbeautifier": "*",
"grunt-contrib-jshint": "*", "grunt-contrib-jshint": "*",
"grunt-jsdoc": "*" "grunt-jsdoc": "*",
"grunt-mocha-test": "~0.8.1"
},
"dependencies": {
"node-localstorage": "~0.3.4"
},
"repository": {
"type": "git",
"url": "http://github.com/openpgpjs/openpgpjs"
} }
} }

View File

@ -43,5 +43,7 @@ module.exports = {
versionstring: "OpenPGP.js VERSION", versionstring: "OpenPGP.js VERSION",
commentstring: "http://openpgpjs.org", commentstring: "http://openpgpjs.org",
node_store: './openpgp.store',
debug: false debug: false
}; };

View File

@ -1 +1,5 @@
/**
* @see module:config/config
* @module config
*/
module.exports = require('./config.js'); module.exports = require('./config.js');

View File

@ -21,7 +21,7 @@
* @module crypto/cfb * @module crypto/cfb
*/ */
var util = require('../util'), var util = require('../util.js'),
cipher = require('./cipher'); cipher = require('./cipher');
module.exports = { module.exports = {

View File

@ -16,7 +16,7 @@
* @module crypto/cipher/aes * @module crypto/cipher/aes
*/ */
var util = require('../../util'); var util = require('../../util.js');
// The round constants used in subkey expansion // The round constants used in subkey expansion
var Rcon = [ var Rcon = [

View File

@ -391,7 +391,7 @@ Blowfish.prototype.init = function(key) {
} }
}; };
var util = require('../../util'); var util = require('../../util.js');
// added by Recurity Labs // added by Recurity Labs

View File

@ -591,7 +591,7 @@ function openpgp_symenc_cast5() {
0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e); 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e);
} }
var util = require('../../util'); var util = require('../../util.js');
function cast5(key) { function cast5(key) {
this.cast5 = new openpgp_symenc_cast5(); this.cast5 = new openpgp_symenc_cast5();

View File

@ -361,7 +361,7 @@ function des_removePadding(message, padding) {
} }
var util = require('../../util'); var util = require('../../util.js');
// added by Recurity Labs // added by Recurity Labs

View File

@ -354,7 +354,7 @@ function createTwofish() {
}; };
} }
var util = require('../../util'); var util = require('../../util.js');
// added by Recurity Labs // added by Recurity Labs

View File

@ -17,7 +17,7 @@
* @module crypto/hash/md5 * @module crypto/hash/md5
*/ */
var util = require('../../util'); var util = require('../../util.js');
/** /**
* MD5 hash * MD5 hash

View File

@ -49,7 +49,7 @@ hash_headers[11] = [0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
var crypto = require('./crypto.js'), var crypto = require('./crypto.js'),
random = require('./random.js'), random = require('./random.js'),
util = require('../util'), util = require('../util.js'),
BigInteger = require('./public_key/jsbn.js'), BigInteger = require('./public_key/jsbn.js'),
hash = require('./hash'); hash = require('./hash');

View File

@ -28,7 +28,7 @@
var BigInteger = require('./jsbn.js'), var BigInteger = require('./jsbn.js'),
random = require('../random.js'), random = require('../random.js'),
hashModule = require('../hash'), hashModule = require('../hash'),
util = require('../../util'), util = require('../../util.js'),
config = require('../../config'); config = require('../../config');
function DSA() { function DSA() {

View File

@ -26,7 +26,7 @@
var BigInteger = require('./jsbn.js'), var BigInteger = require('./jsbn.js'),
random = require('../random.js'), random = require('../random.js'),
util = require('../../util'); util = require('../../util.js');
function Elgamal() { function Elgamal() {

View File

@ -37,7 +37,7 @@
* @module crypto/public_key/jsbn * @module crypto/public_key/jsbn
*/ */
var util = require('../../util'); var util = require('../../util.js');
// Basic JavaScript BN library - subset useful for RSA encryption. // Basic JavaScript BN library - subset useful for RSA encryption.

View File

@ -25,7 +25,7 @@
*/ */
var BigInteger = require('./jsbn.js'), var BigInteger = require('./jsbn.js'),
util = require('../../util'), util = require('../../util.js'),
random = require('../random.js'); random = require('../random.js');
function SecureRandom() { function SecureRandom() {

View File

@ -27,7 +27,7 @@ var nodeCrypto = null;
if (typeof window === undefined) {} if (typeof window === undefined) {}
try { try {
crypto = require('crypto'); nodeCrypto = require('crypto');
} catch (e) { } catch (e) {
} }
@ -66,7 +66,7 @@ module.exports = {
this.getRandomValues(buf); this.getRandomValues(buf);
var bits = ((to - from)).toString(2).length; var bits = ((to - from)).toString(2).length;
while ((buf[0] & (Math.pow(2, bits) - 1)) > (to - from)) while ((buf[0] & (Math.pow(2, bits) - 1)) > (to - from))
window.crypto.getRandomValues(buf); this.getRandomValues(buf);
return from + (Math.abs(buf[0] & (Math.pow(2, bits) - 1))); return from + (Math.abs(buf[0] & (Math.pow(2, bits) - 1)));
}, },
@ -84,7 +84,7 @@ module.exports = {
try { try {
window.crypto.getRandomValues(buf); window.crypto.getRandomValues(buf);
} catch (e) { } catch (e) {
var bytes = crypto.randomBytes(4); var bytes = nodeCrypto.randomBytes(4);
buf[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; buf[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
} }
}, },

View File

@ -1,39 +1,67 @@
module.exports = require('./openpgp.js'); module.exports = require('./openpgp.js');
/**
* @see module:key
* @name module:openpgp.key
*/
module.exports.key = require('./key.js'); module.exports.key = require('./key.js');
/**
* @see module:message
* @name module:openpgp.message
*/
module.exports.message = require('./message.js'); module.exports.message = require('./message.js');
/**
* @see module:cleartext
* @name module:openpgp.cleartext
*/
module.exports.cleartext = require('./cleartext.js'); module.exports.cleartext = require('./cleartext.js');
/** /**
* @see module:util/util * @see module:util
* @module util * @name module:openpgp.util
*/
module.exports.util = require('./util.js');
/**
* @see module:packet
* @name module:openpgp.packet
*/ */
module.exports.util = require('./util/util.js');
module.exports.packet = require('./packet'); module.exports.packet = require('./packet');
/** /**
* @see module:type/mpi * @see module:type/mpi
* @module mpi * @name module:openpgp.MPI
*/ */
module.exports.mpi = require('./type/mpi.js'); module.exports.MPI = require('./type/mpi.js');
/** /**
* @see module:type/s2k * @see module:type/s2k
* @module s2k * @name module:openpgp.S2K
*/ */
module.exports.s2k = require('./type/s2k.js'); module.exports.S2K = require('./type/s2k.js');
/** /**
* @see module:type/keyid * @see module:type/keyid
* @module keyid * @name module:openpgp.Keyid
*/ */
module.exports.keyid = require('./type/keyid.js'); module.exports.Keyid = require('./type/keyid.js');
/** /**
* @see module:encoding/armor * @see module:encoding/armor
* @module armor * @name module:openpgp.armor
*/ */
module.exports.armor = require('./encoding/armor.js'); module.exports.armor = require('./encoding/armor.js');
/**
* @see module:enums
* @name module:openpgp.enums
*/
module.exports.enums = require('./enums.js'); module.exports.enums = require('./enums.js');
/** /**
* @see module:config/config * @see module:config/config
* @module config * @name module:openpgp.config
*/ */
module.exports.config = require('./config/config.js'); module.exports.config = require('./config/config.js');
/**
* @see module:crypto
* @name module:openpgp.crypto
*/
module.exports.crypto = require('./crypto'); module.exports.crypto = require('./crypto');
/**
* @see module:keyring
* @name module:openpgp.Keyring
*/
module.exports.Keyring = require('./keyring');

View File

@ -1,3 +1,6 @@
/**
* @see module:keyring/keyring
* @module keyring
*/
module.exports = require('./keyring.js'); module.exports = require('./keyring.js');
module.exports.localstore = require('./localstore.js'); module.exports.localstore = require('./localstore.js');

View File

@ -39,7 +39,7 @@ LocalStore.prototype.load = function () {
} }
if (storage === null) { if (storage === null) {
storage = new (require('node-localstorage').LocalStorage)('./keyring.store'); storage = new (require('node-localstorage').LocalStorage)(openpgp.config.node_store);
} }
var armoredKeys = JSON.parse(storage.getItem("armoredKeys")); var armoredKeys = JSON.parse(storage.getItem("armoredKeys"));
var keys = []; var keys = [];

View File

@ -27,7 +27,7 @@
module.exports = Literal; module.exports = Literal;
var util = require('../util'), var util = require('../util.js'),
enums = require('../enums.js'); enums = require('../enums.js');
/** /**

View File

@ -22,7 +22,7 @@
*/ */
var enums = require('../enums.js'), var enums = require('../enums.js'),
util = require('../util'); util = require('../util.js');
module.exports = { module.exports = {
readSimpleLength: function(bytes) { readSimpleLength: function(bytes) {

View File

@ -32,7 +32,7 @@
module.exports = PublicKey; module.exports = PublicKey;
var util = require('../util'), var util = require('../util.js'),
type_mpi = require('../type/mpi.js'), type_mpi = require('../type/mpi.js'),
type_keyid = require('../type/keyid.js'), type_keyid = require('../type/keyid.js'),
enums = require('../enums.js'), enums = require('../enums.js'),

View File

@ -40,7 +40,7 @@
module.exports = PublicKeyEncryptedSessionKey; module.exports = PublicKeyEncryptedSessionKey;
var type_keyid = require('../type/keyid.js'), var type_keyid = require('../type/keyid.js'),
util = require('../util'), util = require('../util.js'),
type_mpi = require('../type/mpi.js'), type_mpi = require('../type/mpi.js'),
enums = require('../enums.js'), enums = require('../enums.js'),
crypto = require('../crypto'); crypto = require('../crypto');

View File

@ -35,7 +35,7 @@ module.exports = SecretKey;
var publicKey = require('./public_key.js'), var publicKey = require('./public_key.js'),
enums = require('../enums.js'), enums = require('../enums.js'),
util = require('../util'), util = require('../util.js'),
crypto = require('../crypto'), crypto = require('../crypto'),
type_mpi = require('../type/mpi.js'), type_mpi = require('../type/mpi.js'),
type_s2k = require('../type/s2k.js'); type_s2k = require('../type/s2k.js');

View File

@ -33,7 +33,7 @@
module.exports = Signature; module.exports = Signature;
var util = require('../util'), var util = require('../util.js'),
packet = require('./packet.js'), packet = require('./packet.js'),
enums = require('../enums.js'), enums = require('../enums.js'),
crypto = require('../crypto'), crypto = require('../crypto'),

View File

@ -32,7 +32,7 @@
module.exports = SymEncryptedIntegrityProtected; module.exports = SymEncryptedIntegrityProtected;
var util = require('../util'), var util = require('../util.js'),
crypto = require('../crypto'); crypto = require('../crypto');
/** /**

View File

@ -35,7 +35,7 @@
* @module packet/user_attribute * @module packet/user_attribute
*/ */
var util = require('../util'), var util = require('../util.js'),
packet = require('./packet.js'); packet = require('./packet.js');
module.exports = UserAttribute; module.exports = UserAttribute;

View File

@ -29,7 +29,7 @@
module.exports = Userid; module.exports = Userid;
var util = require('../util'); var util = require('../util.js');
/** /**
* @constructor * @constructor

View File

@ -28,7 +28,7 @@
module.exports = Keyid; module.exports = Keyid;
var util = require('../util'); var util = require('../util.js');
/** /**
* @constructor * @constructor

View File

@ -37,7 +37,7 @@
module.exports = MPI; module.exports = MPI;
var BigInteger = require('../crypto/public_key/jsbn.js'), var BigInteger = require('../crypto/public_key/jsbn.js'),
util = require('../util'); util = require('../util.js');
/** /**
* @constructor * @constructor

View File

@ -32,7 +32,7 @@
module.exports = S2K; module.exports = S2K;
var enums = require('../enums.js'), var enums = require('../enums.js'),
util = require('../util'), util = require('../util.js'),
crypto = require('../crypto'); crypto = require('../crypto');
/** /**

View File

@ -18,10 +18,10 @@
/** /**
* This object contains utility functions * This object contains utility functions
* @requires config * @requires config
* @module util/util * @module util
*/ */
var config = require('../config'); var config = require('./config');
module.exports = { module.exports = {
readNumber: function (bytes) { readNumber: function (bytes) {
@ -194,7 +194,7 @@ module.exports = {
/** /**
* Convert a Uint8Array to a string. This currently functions * Convert a Uint8Array to a string. This currently functions
* the same as bin2str. * the same as bin2str.
* @function module:util/util.Uint8Array2str * @function module:util.Uint8Array2str
* @param {Uint8Array} bin An array of (binary) integers to convert * @param {Uint8Array} bin An array of (binary) integers to convert
* @return {String} String representation of the array * @return {String} String representation of the array
*/ */

View File

@ -190,36 +190,36 @@ describe('API functional testing', function() {
var RSApubMPIs = []; var RSApubMPIs = [];
var i; var i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
RSApubMPIs[i] = new openpgp.mpi(); RSApubMPIs[i] = new openpgp.MPI();
RSApubMPIs[i].read(RSApubMPIstrs[i]); RSApubMPIs[i].read(RSApubMPIstrs[i]);
} }
var RSAsecMPIs = []; var RSAsecMPIs = [];
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
RSAsecMPIs[i] = new openpgp.mpi(); RSAsecMPIs[i] = new openpgp.MPI();
RSAsecMPIs[i].read(RSAsecMPIstrs[i]); RSAsecMPIs[i].read(RSAsecMPIstrs[i]);
} }
var DSAsecMPIs = []; var DSAsecMPIs = [];
for (i = 0; i < 1; i++) { for (i = 0; i < 1; i++) {
DSAsecMPIs[i] = new openpgp.mpi(); DSAsecMPIs[i] = new openpgp.MPI();
DSAsecMPIs[i].read(DSAsecMPIstrs[i]); DSAsecMPIs[i].read(DSAsecMPIstrs[i]);
} }
var DSApubMPIs = []; var DSApubMPIs = [];
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
DSApubMPIs[i] = new openpgp.mpi(); DSApubMPIs[i] = new openpgp.MPI();
DSApubMPIs[i].read(DSApubMPIstrs[i]); DSApubMPIs[i].read(DSApubMPIstrs[i]);
} }
var ElgamalsecMPIs = []; var ElgamalsecMPIs = [];
for (i = 0; i < 1; i++) { for (i = 0; i < 1; i++) {
ElgamalsecMPIs[i] = new openpgp.mpi(); ElgamalsecMPIs[i] = new openpgp.MPI();
ElgamalsecMPIs[i].read(ElgamalsecMPIstrs[i]); ElgamalsecMPIs[i].read(ElgamalsecMPIstrs[i]);
} }
var ElgamalpubMPIs = []; var ElgamalpubMPIs = [];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
ElgamalpubMPIs[i] = new openpgp.mpi(); ElgamalpubMPIs[i] = new openpgp.MPI();
ElgamalpubMPIs[i].read(ElgamalpubMPIstrs[i]); ElgamalpubMPIs[i].read(ElgamalpubMPIstrs[i]);
} }
@ -228,7 +228,7 @@ describe('API functional testing', function() {
//Originally we passed public and secret MPI separately, now they are joined. Is this what we want to do long term? //Originally we passed public and secret MPI separately, now they are joined. Is this what we want to do long term?
// RSA // RSA
var RSAsignedData = openpgp.crypto.signature.sign(2, 1, RSApubMPIs.concat(RSAsecMPIs), "foobar"); var RSAsignedData = openpgp.crypto.signature.sign(2, 1, RSApubMPIs.concat(RSAsecMPIs), "foobar");
var RSAsignedDataMPI = new openpgp.mpi(); var RSAsignedDataMPI = new openpgp.MPI();
RSAsignedDataMPI.read(RSAsignedData); RSAsignedDataMPI.read(RSAsignedData);
var success = openpgp.crypto.signature.verify(1, 2, [RSAsignedDataMPI], RSApubMPIs, "foobar"); var success = openpgp.crypto.signature.verify(1, 2, [RSAsignedDataMPI], RSApubMPIs, "foobar");
expect(success).to.be.true; expect(success).to.be.true;
@ -240,8 +240,8 @@ describe('API functional testing', function() {
var DSAsignedData = openpgp.crypto.signature.sign(2, 17, DSApubMPIs.concat(DSAsecMPIs), "foobar"); var DSAsignedData = openpgp.crypto.signature.sign(2, 17, DSApubMPIs.concat(DSAsecMPIs), "foobar");
var DSAmsgMPIs = []; var DSAmsgMPIs = [];
DSAmsgMPIs[0] = new openpgp.mpi(); DSAmsgMPIs[0] = new openpgp.MPI();
DSAmsgMPIs[1] = new openpgp.mpi(); DSAmsgMPIs[1] = new openpgp.MPI();
DSAmsgMPIs[0].read(DSAsignedData.substring(0,34)); DSAmsgMPIs[0].read(DSAsignedData.substring(0,34));
DSAmsgMPIs[1].read(DSAsignedData.substring(34,68)); DSAmsgMPIs[1].read(DSAsignedData.substring(34,68));
var success = openpgp.crypto.signature.verify(17, 2, DSAmsgMPIs, DSApubMPIs, "foobar"); var success = openpgp.crypto.signature.verify(17, 2, DSAmsgMPIs, DSApubMPIs, "foobar");
@ -271,7 +271,7 @@ describe('API functional testing', function() {
}); });
it('Asymmetric using RSA with eme_pkcs1 padding', function (done) { it('Asymmetric using RSA with eme_pkcs1 padding', function (done) {
var RSAUnencryptedData = new openpgp.mpi(); var RSAUnencryptedData = new openpgp.MPI();
RSAUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, RSApubMPIs[0].byteLength())); RSAUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, RSApubMPIs[0].byteLength()));
var RSAEncryptedData = openpgp.crypto.publicKeyEncrypt("rsa_encrypt_sign", RSApubMPIs, RSAUnencryptedData); var RSAEncryptedData = openpgp.crypto.publicKeyEncrypt("rsa_encrypt_sign", RSApubMPIs, RSAUnencryptedData);
@ -281,7 +281,7 @@ describe('API functional testing', function() {
}); });
it('Asymmetric using Elgamal with eme_pkcs1 padding', function (done) { it('Asymmetric using Elgamal with eme_pkcs1 padding', function (done) {
var ElgamalUnencryptedData = new openpgp.mpi(); var ElgamalUnencryptedData = new openpgp.MPI();
ElgamalUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, ElgamalpubMPIs[0].byteLength())); ElgamalUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, ElgamalpubMPIs[0].byteLength()));
var ElgamalEncryptedData = openpgp.crypto.publicKeyEncrypt("elgamal", ElgamalpubMPIs, ElgamalUnencryptedData); var ElgamalEncryptedData = openpgp.crypto.publicKeyEncrypt("elgamal", ElgamalpubMPIs, ElgamalUnencryptedData);

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var openpgp = require('openpgp'), var openpgp = require('openpgp'),
keyring = new (require('keyring'))(), keyring = new openpgp.Keyring(),
chai = require('chai'), chai = require('chai'),
expect = chai.expect; expect = chai.expect;

View File

@ -122,7 +122,7 @@ describe("Packet", function() {
var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u];
mpi = mpi.map(function(k) { mpi = mpi.map(function(k) {
var mpi = new openpgp.mpi(); var mpi = new openpgp.MPI();
mpi.fromBigInteger(k); mpi.fromBigInteger(k);
return mpi; return mpi;
}); });
@ -386,7 +386,7 @@ describe("Packet", function() {
var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u];
mpi = mpi.map(function(k) { mpi = mpi.map(function(k) {
var mpi = new openpgp.mpi(); var mpi = new openpgp.MPI();
mpi.fromBigInteger(k); mpi.fromBigInteger(k);
return mpi; return mpi;
}); });
@ -414,7 +414,7 @@ describe("Packet", function() {
var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u];
mpi = mpi.map(function(k) { mpi = mpi.map(function(k) {
var mpi = new openpgp.mpi(); var mpi = new openpgp.MPI();
mpi.fromBigInteger(k); mpi.fromBigInteger(k);
return mpi; return mpi;
}); });

View File

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