diff --git a/Gruntfile.js b/Gruntfile.js index 658264e4..8968d7ce 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,42 +6,23 @@ module.exports = function(grunt) { browserify: { openpgp_nodebug: { files: { - 'resources/openpgp_nodebug.js': [] + 'dist/openpgp_nodebug.js': [] }, options: { - alias: './src/:openpgp', + alias: [ './src/:openpgp' ], external: [ 'crypto', 'node-localstorage' ] } }, openpgp: { files: { - 'resources/openpgp.js': [] + 'dist/openpgp.js': [] }, options: { debug: true, - alias: './src/:openpgp', + alias: [ './src/:openpgp' ], 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: { files: { 'test/lib/unittests-bundle.js': [] @@ -49,22 +30,22 @@ module.exports = function(grunt) { options: { debug: true, alias: './test/unittests.js:unittests', - external: [ 'openpgp', 'keyring', 'node-localstorage' ] + external: [ 'openpgp' ] } } }, - replace : { + replace: { openpgpjs: { - src: ['resources/openpgp.js'], - dest: ['resources/openpgp.js'], + src: ['dist/openpgp.js'], + dest: ['dist/openpgp.js'], replacements: [{ 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'], + src: ['dist/openpgp_nodebug.js'], + dest: ['dist/openpgp_nodebug.js'], replacements: [{ from: /OpenPGP.js VERSION/g, to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>' @@ -74,8 +55,7 @@ module.exports = function(grunt) { uglify: { openpgpjs: { files: { - "resources/openpgp.min.js" : [ "resources/openpgp_nodebug.js" ], - "resources/keyring.min.js" : [ "resources/keyring_nodebug.js" ] + 'dist/openpgp.min.js' : [ 'dist/openpgp_nodebug.js' ] } }, options: { @@ -83,11 +63,9 @@ module.exports = function(grunt) { '<%= grunt.template.today("yyyy-mm-dd") %> */' } }, - prepare_install: { - }, - jsbeautifier : { - files : ["src/**/*.js"], - options : { + jsbeautifier: { + files: ['src/**/*.js'], + options: { indent_size: 2, preserve_newlines: true, keep_array_indentation: false, @@ -95,20 +73,27 @@ module.exports = function(grunt) { wrap_line_length: 120 } }, - jshint : { - all : ["src/**/*.js"] + jshint: { + all: ['src/**/*.js'] }, - jsdoc : { - dist : { - src: ["README.md", "src"], + jsdoc: { + dist: { + src: ['README.md', 'src'], options: { - destination: "doc", + destination: 'doc', recurse: true, - template: "jsdoc.template" + template: 'jsdoc.template' } } }, - + mochaTest: { + unittests: { + options: { + reporter: 'spec' + }, + src: [ 'test/unittests.js' ] + } + }, copy: { npm: { 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-contrib-uglify'); grunt.loadNpmTasks('grunt-text-replace'); - grunt.loadNpmTasks('grunt-prepare-install'); grunt.loadNpmTasks('grunt-jsbeautifier'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-jsdoc'); + grunt.loadNpmTasks('grunt-mocha-test'); + grunt.loadNpmTasks('grunt-contrib-copy'); 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 grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.'); }); - grunt.registerTask('documentation', ['jsdoc']); - // Load the plugin(s) - grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.registerTask('documentation', ['jsdoc']); // Alias the `mocha_phantomjs` task to run `mocha-phantomjs` grunt.registerTask('mocha_phantomjs', 'mocha-phantomjs', function () { @@ -149,6 +133,25 @@ module.exports = function(grunt) { mocha.stderr.pipe(process.stderr); }); - // Test/Dev tasks - grunt.registerTask('test', ['copy', 'mocha_phantomjs']); + // Alias the `npm_pack` task to run `npm pack` + 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']); }; diff --git a/package.json b/package.json index 8a8588cb..e4355bcd 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,14 @@ "engines": { "node": ">=0.8" }, + "main": "src/index.js", "directories": { "lib": "src" }, - "main": "src/index.js", - "files": [ "src" ], + "files": [ + "src", + "test" + ], "scripts": { "pretest": "grunt", "test": "grunt test" @@ -26,6 +29,14 @@ "grunt-text-replace": "*", "grunt-jsbeautifier": "*", "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" } } diff --git a/src/config/config.js b/src/config/config.js index 8f38163e..de202569 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -43,5 +43,7 @@ module.exports = { versionstring: "OpenPGP.js VERSION", commentstring: "http://openpgpjs.org", + node_store: './openpgp.store', + debug: false }; diff --git a/src/config/index.js b/src/config/index.js index 0a31abf0..4e9f84a5 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1 +1,5 @@ +/** + * @see module:config/config + * @module config + */ module.exports = require('./config.js'); diff --git a/src/crypto/cfb.js b/src/crypto/cfb.js index f28218bf..4387cd60 100644 --- a/src/crypto/cfb.js +++ b/src/crypto/cfb.js @@ -21,7 +21,7 @@ * @module crypto/cfb */ -var util = require('../util'), +var util = require('../util.js'), cipher = require('./cipher'); module.exports = { diff --git a/src/crypto/cipher/aes.js b/src/crypto/cipher/aes.js index 5d99d78e..2a13e946 100644 --- a/src/crypto/cipher/aes.js +++ b/src/crypto/cipher/aes.js @@ -16,7 +16,7 @@ * @module crypto/cipher/aes */ -var util = require('../../util'); +var util = require('../../util.js'); // The round constants used in subkey expansion var Rcon = [ diff --git a/src/crypto/cipher/blowfish.js b/src/crypto/cipher/blowfish.js index a496c90e..2c481022 100644 --- a/src/crypto/cipher/blowfish.js +++ b/src/crypto/cipher/blowfish.js @@ -391,7 +391,7 @@ Blowfish.prototype.init = function(key) { } }; -var util = require('../../util'); +var util = require('../../util.js'); // added by Recurity Labs diff --git a/src/crypto/cipher/cast5.js b/src/crypto/cipher/cast5.js index f875490f..bc64dce5 100644 --- a/src/crypto/cipher/cast5.js +++ b/src/crypto/cipher/cast5.js @@ -591,7 +591,7 @@ function openpgp_symenc_cast5() { 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e); } -var util = require('../../util'); +var util = require('../../util.js'); function cast5(key) { this.cast5 = new openpgp_symenc_cast5(); diff --git a/src/crypto/cipher/des.js b/src/crypto/cipher/des.js index fdb67b32..6ce3ba47 100644 --- a/src/crypto/cipher/des.js +++ b/src/crypto/cipher/des.js @@ -361,7 +361,7 @@ function des_removePadding(message, padding) { } -var util = require('../../util'); +var util = require('../../util.js'); // added by Recurity Labs diff --git a/src/crypto/cipher/twofish.js b/src/crypto/cipher/twofish.js index fc27b17a..9ab4aab6 100644 --- a/src/crypto/cipher/twofish.js +++ b/src/crypto/cipher/twofish.js @@ -354,7 +354,7 @@ function createTwofish() { }; } -var util = require('../../util'); +var util = require('../../util.js'); // added by Recurity Labs diff --git a/src/crypto/hash/md5.js b/src/crypto/hash/md5.js index 1829aa75..b0261d49 100644 --- a/src/crypto/hash/md5.js +++ b/src/crypto/hash/md5.js @@ -17,7 +17,7 @@ * @module crypto/hash/md5 */ -var util = require('../../util'); +var util = require('../../util.js'); /** * MD5 hash diff --git a/src/crypto/pkcs1.js b/src/crypto/pkcs1.js index 3d70ebe7..a311c627 100644 --- a/src/crypto/pkcs1.js +++ b/src/crypto/pkcs1.js @@ -49,7 +49,7 @@ hash_headers[11] = [0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, var crypto = require('./crypto.js'), random = require('./random.js'), - util = require('../util'), + util = require('../util.js'), BigInteger = require('./public_key/jsbn.js'), hash = require('./hash'); diff --git a/src/crypto/public_key/dsa.js b/src/crypto/public_key/dsa.js index d9791096..29190daa 100644 --- a/src/crypto/public_key/dsa.js +++ b/src/crypto/public_key/dsa.js @@ -28,7 +28,7 @@ var BigInteger = require('./jsbn.js'), random = require('../random.js'), hashModule = require('../hash'), - util = require('../../util'), + util = require('../../util.js'), config = require('../../config'); function DSA() { diff --git a/src/crypto/public_key/elgamal.js b/src/crypto/public_key/elgamal.js index 4cc3a686..7638bd2e 100644 --- a/src/crypto/public_key/elgamal.js +++ b/src/crypto/public_key/elgamal.js @@ -26,7 +26,7 @@ var BigInteger = require('./jsbn.js'), random = require('../random.js'), - util = require('../../util'); + util = require('../../util.js'); function Elgamal() { diff --git a/src/crypto/public_key/jsbn.js b/src/crypto/public_key/jsbn.js index 845fd44a..eb7712c7 100644 --- a/src/crypto/public_key/jsbn.js +++ b/src/crypto/public_key/jsbn.js @@ -37,7 +37,7 @@ * @module crypto/public_key/jsbn */ -var util = require('../../util'); +var util = require('../../util.js'); // Basic JavaScript BN library - subset useful for RSA encryption. diff --git a/src/crypto/public_key/rsa.js b/src/crypto/public_key/rsa.js index f6d48f3f..4a907f3c 100644 --- a/src/crypto/public_key/rsa.js +++ b/src/crypto/public_key/rsa.js @@ -25,7 +25,7 @@ */ var BigInteger = require('./jsbn.js'), - util = require('../../util'), + util = require('../../util.js'), random = require('../random.js'); function SecureRandom() { diff --git a/src/crypto/random.js b/src/crypto/random.js index 4497d9d0..c454e3a3 100644 --- a/src/crypto/random.js +++ b/src/crypto/random.js @@ -27,7 +27,7 @@ var nodeCrypto = null; if (typeof window === undefined) {} try { - crypto = require('crypto'); + nodeCrypto = require('crypto'); } catch (e) { } @@ -66,7 +66,7 @@ module.exports = { this.getRandomValues(buf); var bits = ((to - from)).toString(2).length; 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))); }, @@ -84,7 +84,7 @@ module.exports = { try { window.crypto.getRandomValues(buf); } 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]; } }, diff --git a/src/index.js b/src/index.js index d6709e6c..711a8a55 100644 --- a/src/index.js +++ b/src/index.js @@ -1,39 +1,67 @@ module.exports = require('./openpgp.js'); - +/** + * @see module:key + * @name module:openpgp.key + */ module.exports.key = require('./key.js'); +/** + * @see module:message + * @name module:openpgp.message + */ module.exports.message = require('./message.js'); +/** + * @see module:cleartext + * @name module:openpgp.cleartext + */ module.exports.cleartext = require('./cleartext.js'); /** - * @see module:util/util - * @module util + * @see 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'); /** * @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 - * @module s2k + * @name module:openpgp.S2K */ -module.exports.s2k = require('./type/s2k.js'); +module.exports.S2K = require('./type/s2k.js'); /** * @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 - * @module armor + * @name module:openpgp.armor */ module.exports.armor = require('./encoding/armor.js'); +/** + * @see module:enums + * @name module:openpgp.enums + */ module.exports.enums = require('./enums.js'); /** * @see module:config/config - * @module config + * @name module:openpgp.config */ module.exports.config = require('./config/config.js'); +/** + * @see module:crypto + * @name module:openpgp.crypto + */ module.exports.crypto = require('./crypto'); +/** + * @see module:keyring + * @name module:openpgp.Keyring + */ +module.exports.Keyring = require('./keyring'); diff --git a/src/keyring/index.js b/src/keyring/index.js index 867b80b7..b1ef2352 100644 --- a/src/keyring/index.js +++ b/src/keyring/index.js @@ -1,3 +1,6 @@ - +/** + * @see module:keyring/keyring + * @module keyring + */ module.exports = require('./keyring.js'); module.exports.localstore = require('./localstore.js'); diff --git a/src/keyring/localstore.js b/src/keyring/localstore.js index 7d60b41d..0b46bbe1 100644 --- a/src/keyring/localstore.js +++ b/src/keyring/localstore.js @@ -39,7 +39,7 @@ LocalStore.prototype.load = function () { } 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 keys = []; diff --git a/src/packet/literal.js b/src/packet/literal.js index 130f2162..40de1257 100644 --- a/src/packet/literal.js +++ b/src/packet/literal.js @@ -27,7 +27,7 @@ module.exports = Literal; -var util = require('../util'), +var util = require('../util.js'), enums = require('../enums.js'); /** diff --git a/src/packet/packet.js b/src/packet/packet.js index 661d5f47..8de54895 100644 --- a/src/packet/packet.js +++ b/src/packet/packet.js @@ -22,7 +22,7 @@ */ var enums = require('../enums.js'), - util = require('../util'); + util = require('../util.js'); module.exports = { readSimpleLength: function(bytes) { diff --git a/src/packet/public_key.js b/src/packet/public_key.js index 5fa835af..30935f52 100644 --- a/src/packet/public_key.js +++ b/src/packet/public_key.js @@ -32,7 +32,7 @@ module.exports = PublicKey; -var util = require('../util'), +var util = require('../util.js'), type_mpi = require('../type/mpi.js'), type_keyid = require('../type/keyid.js'), enums = require('../enums.js'), diff --git a/src/packet/public_key_encrypted_session_key.js b/src/packet/public_key_encrypted_session_key.js index bac2168b..676046bb 100644 --- a/src/packet/public_key_encrypted_session_key.js +++ b/src/packet/public_key_encrypted_session_key.js @@ -40,7 +40,7 @@ module.exports = PublicKeyEncryptedSessionKey; var type_keyid = require('../type/keyid.js'), - util = require('../util'), + util = require('../util.js'), type_mpi = require('../type/mpi.js'), enums = require('../enums.js'), crypto = require('../crypto'); diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js index 15574245..6324ec7b 100644 --- a/src/packet/secret_key.js +++ b/src/packet/secret_key.js @@ -35,7 +35,7 @@ module.exports = SecretKey; var publicKey = require('./public_key.js'), enums = require('../enums.js'), - util = require('../util'), + util = require('../util.js'), crypto = require('../crypto'), type_mpi = require('../type/mpi.js'), type_s2k = require('../type/s2k.js'); diff --git a/src/packet/signature.js b/src/packet/signature.js index 4c6abfc2..657f1ed2 100644 --- a/src/packet/signature.js +++ b/src/packet/signature.js @@ -33,7 +33,7 @@ module.exports = Signature; -var util = require('../util'), +var util = require('../util.js'), packet = require('./packet.js'), enums = require('../enums.js'), crypto = require('../crypto'), diff --git a/src/packet/sym_encrypted_integrity_protected.js b/src/packet/sym_encrypted_integrity_protected.js index 6a6d8c1e..353946d1 100644 --- a/src/packet/sym_encrypted_integrity_protected.js +++ b/src/packet/sym_encrypted_integrity_protected.js @@ -32,7 +32,7 @@ module.exports = SymEncryptedIntegrityProtected; -var util = require('../util'), +var util = require('../util.js'), crypto = require('../crypto'); /** diff --git a/src/packet/user_attribute.js b/src/packet/user_attribute.js index 787739dd..42c41a65 100644 --- a/src/packet/user_attribute.js +++ b/src/packet/user_attribute.js @@ -35,7 +35,7 @@ * @module packet/user_attribute */ -var util = require('../util'), +var util = require('../util.js'), packet = require('./packet.js'); module.exports = UserAttribute; diff --git a/src/packet/userid.js b/src/packet/userid.js index bc0ad6a8..285fdcb5 100644 --- a/src/packet/userid.js +++ b/src/packet/userid.js @@ -29,7 +29,7 @@ module.exports = Userid; -var util = require('../util'); +var util = require('../util.js'); /** * @constructor diff --git a/src/type/keyid.js b/src/type/keyid.js index 84b3bcdc..78aa0c31 100644 --- a/src/type/keyid.js +++ b/src/type/keyid.js @@ -28,7 +28,7 @@ module.exports = Keyid; -var util = require('../util'); +var util = require('../util.js'); /** * @constructor diff --git a/src/type/mpi.js b/src/type/mpi.js index 22afa903..6ea7a2e3 100644 --- a/src/type/mpi.js +++ b/src/type/mpi.js @@ -37,7 +37,7 @@ module.exports = MPI; var BigInteger = require('../crypto/public_key/jsbn.js'), - util = require('../util'); + util = require('../util.js'); /** * @constructor diff --git a/src/type/s2k.js b/src/type/s2k.js index 3de47042..91701ac2 100644 --- a/src/type/s2k.js +++ b/src/type/s2k.js @@ -32,7 +32,7 @@ module.exports = S2K; var enums = require('../enums.js'), - util = require('../util'), + util = require('../util.js'), crypto = require('../crypto'); /** diff --git a/src/util.js b/src/util.js index a1b2d73c..c3f90e36 100644 --- a/src/util.js +++ b/src/util.js @@ -18,10 +18,10 @@ /** * This object contains utility functions * @requires config - * @module util/util + * @module util */ -var config = require('../config'); +var config = require('./config'); module.exports = { readNumber: function (bytes) { @@ -194,7 +194,7 @@ module.exports = { /** * Convert a Uint8Array to a string. This currently functions * the same as bin2str. - * @function module:util/util.Uint8Array2str + * @function module:util.Uint8Array2str * @param {Uint8Array} bin An array of (binary) integers to convert * @return {String} String representation of the array */ diff --git a/test/crypto/crypto.js b/test/crypto/crypto.js index 54911211..45a79df5 100644 --- a/test/crypto/crypto.js +++ b/test/crypto/crypto.js @@ -190,36 +190,36 @@ describe('API functional testing', function() { var RSApubMPIs = []; var i; for (i = 0; i < 2; i++) { - RSApubMPIs[i] = new openpgp.mpi(); + RSApubMPIs[i] = new openpgp.MPI(); RSApubMPIs[i].read(RSApubMPIstrs[i]); } var RSAsecMPIs = []; for (i = 0; i < 4; i++) { - RSAsecMPIs[i] = new openpgp.mpi(); + RSAsecMPIs[i] = new openpgp.MPI(); RSAsecMPIs[i].read(RSAsecMPIstrs[i]); } var DSAsecMPIs = []; for (i = 0; i < 1; i++) { - DSAsecMPIs[i] = new openpgp.mpi(); + DSAsecMPIs[i] = new openpgp.MPI(); DSAsecMPIs[i].read(DSAsecMPIstrs[i]); } var DSApubMPIs = []; for (i = 0; i < 4; i++) { - DSApubMPIs[i] = new openpgp.mpi(); + DSApubMPIs[i] = new openpgp.MPI(); DSApubMPIs[i].read(DSApubMPIstrs[i]); } var ElgamalsecMPIs = []; for (i = 0; i < 1; i++) { - ElgamalsecMPIs[i] = new openpgp.mpi(); + ElgamalsecMPIs[i] = new openpgp.MPI(); ElgamalsecMPIs[i].read(ElgamalsecMPIstrs[i]); } var ElgamalpubMPIs = []; for (i = 0; i < 3; i++) { - ElgamalpubMPIs[i] = new openpgp.mpi(); + ElgamalpubMPIs[i] = new openpgp.MPI(); 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? // RSA 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); var success = openpgp.crypto.signature.verify(1, 2, [RSAsignedDataMPI], RSApubMPIs, "foobar"); 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 DSAmsgMPIs = []; - DSAmsgMPIs[0] = new openpgp.mpi(); - DSAmsgMPIs[1] = new openpgp.mpi(); + DSAmsgMPIs[0] = new openpgp.MPI(); + DSAmsgMPIs[1] = new openpgp.MPI(); DSAmsgMPIs[0].read(DSAsignedData.substring(0,34)); DSAmsgMPIs[1].read(DSAsignedData.substring(34,68)); 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) { - var RSAUnencryptedData = new openpgp.mpi(); + var RSAUnencryptedData = new openpgp.MPI(); RSAUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, RSApubMPIs[0].byteLength())); 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) { - var ElgamalUnencryptedData = new openpgp.mpi(); + var ElgamalUnencryptedData = new openpgp.MPI(); ElgamalUnencryptedData.fromBytes(openpgp.crypto.pkcs1.eme.encode(symmKey, ElgamalpubMPIs[0].byteLength())); var ElgamalEncryptedData = openpgp.crypto.publicKeyEncrypt("elgamal", ElgamalpubMPIs, ElgamalUnencryptedData); diff --git a/test/general/keyring.js b/test/general/keyring.js index 9dd51346..ccae3d36 100644 --- a/test/general/keyring.js +++ b/test/general/keyring.js @@ -1,7 +1,7 @@ 'use strict'; var openpgp = require('openpgp'), - keyring = new (require('keyring'))(), + keyring = new openpgp.Keyring(), chai = require('chai'), expect = chai.expect; diff --git a/test/general/packet.js b/test/general/packet.js index 8a02d1f5..975f2578 100644 --- a/test/general/packet.js +++ b/test/general/packet.js @@ -122,7 +122,7 @@ describe("Packet", function() { var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; mpi = mpi.map(function(k) { - var mpi = new openpgp.mpi(); + var mpi = new openpgp.MPI(); mpi.fromBigInteger(k); return mpi; }); @@ -386,7 +386,7 @@ describe("Packet", function() { var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; mpi = mpi.map(function(k) { - var mpi = new openpgp.mpi(); + var mpi = new openpgp.MPI(); mpi.fromBigInteger(k); return mpi; }); @@ -414,7 +414,7 @@ describe("Packet", function() { var mpi = [mpi.n, mpi.ee, mpi.d, mpi.p, mpi.q, mpi.u]; mpi = mpi.map(function(k) { - var mpi = new openpgp.mpi(); + var mpi = new openpgp.MPI(); mpi.fromBigInteger(k); return mpi; }); diff --git a/test/unittests.html b/test/unittests.html index cd8d94ed..5c1093c8 100644 --- a/test/unittests.html +++ b/test/unittests.html @@ -10,8 +10,7 @@
- - +