diff --git a/Gruntfile.js b/Gruntfile.js index f8f210df..091ef0a6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -263,7 +263,7 @@ module.exports = function(grunt) { // Load the plugin(s) grunt.loadNpmTasks('grunt-browserify'); - grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-uglify-es'); grunt.loadNpmTasks('grunt-text-replace'); grunt.loadNpmTasks('grunt-jsbeautifier'); grunt.loadNpmTasks('grunt-jsdoc'); diff --git a/package.json b/package.json index a1d29484..aca34417 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,10 @@ "grunt-contrib-clean": "~1.1.0", "grunt-contrib-connect": "~1.0.2", "grunt-contrib-copy": "~1.0.0", - "grunt-contrib-uglify": "~3.2.1", + "grunt-contrib-uglify-es": "^3.3.0", "grunt-contrib-watch": "^1.0.0", "grunt-jsbeautifier": "^0.2.13", "grunt-jsdoc": "^2.2.1", - "grunt-keepalive": "^1.0.0", "grunt-mocha-istanbul": "^5.0.2", "grunt-mocha-test": "^0.13.3", "grunt-saucelabs": "9.0.0", @@ -73,12 +72,12 @@ "whatwg-fetch": "^2.0.3" }, "dependencies": { - "asmcrypto-lite": "github:openpgpjs/asmcrypto-lite", + "asmcrypto.js": "github:mahrud/asmcrypto.js", "asn1.js": "^5.0.0", "bn.js": "^4.11.8", "buffer": "^5.0.8", - "compressjs": "github:openpgpjs/compressjs.git", - "elliptic": "github:openpgpjs/elliptic.git", + "compressjs": "github:openpgpjs/compressjs", + "elliptic": "github:openpgpjs/elliptic", "hash.js": "^1.1.3", "jwk-to-pem": "^1.2.6", "node-fetch": "^1.7.3", diff --git a/src/crypto/cipher/aes.js b/src/crypto/cipher/aes.js index f99cabf6..a1f0423b 100644 --- a/src/crypto/cipher/aes.js +++ b/src/crypto/cipher/aes.js @@ -1,8 +1,9 @@ /** + * @requires asmcrypto.js * @module crypto/cipher/aes */ -import asmCrypto from 'asmcrypto-lite'; +import { AES_ECB } from 'asmcrypto.js'; // TODO use webCrypto or nodeCrypto when possible. export default function aes(length) { @@ -11,12 +12,12 @@ export default function aes(length) { this.encrypt = function(block) { block = Uint8Array.from(block); - return Array.from(asmCrypto.AES_ECB.encrypt(block, this.key, false)); + return Array.from(AES_ECB.encrypt(block, this.key, false)); }; this.decrypt = function(block) { block = Uint8Array.from(block); - return Array.from(asmCrypto.AES_ECB.decrypt(block, this.key, false)); + return Array.from(AES_ECB.decrypt(block, this.key, false)); }; }; diff --git a/src/crypto/gcm.js b/src/crypto/gcm.js index 6cb04d2f..ed4b1222 100644 --- a/src/crypto/gcm.js +++ b/src/crypto/gcm.js @@ -18,10 +18,15 @@ /** * @fileoverview This module wraps native AES-GCM en/decryption for both * the WebCrypto api as well as node.js' crypto api. + * @requires asmcrypto.js + * @requires config + * @requires util + * @module crypto/gcm */ -import asmCrypto from 'asmcrypto-lite'; -import util from '../util.js'; +import { AES_GCM } from 'asmcrypto.js'; +import config from '../config'; +import util from '../util'; const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9 const nodeCrypto = util.getNodeCrypto(); @@ -49,7 +54,7 @@ function encrypt(cipher, plaintext, key, iv) { } else if (nodeCrypto) { // Node crypto library return nodeEncrypt(plaintext, key, iv); } // asm.js fallback - return Promise.resolve(asmCrypto.AES_GCM.encrypt(plaintext, key, iv)); + return Promise.resolve(AES_GCM.encrypt(plaintext, key, iv)); } /** @@ -70,7 +75,7 @@ function decrypt(cipher, ciphertext, key, iv) { } else if (nodeCrypto) { // Node crypto library return nodeDecrypt(ciphertext, key, iv); } // asm.js fallback - return Promise.resolve(asmCrypto.AES_GCM.decrypt(ciphertext, key, iv)); + return Promise.resolve(AES_GCM.decrypt(ciphertext, key, iv)); } export default { diff --git a/src/crypto/hash/index.js b/src/crypto/hash/index.js index 7f1455fb..8fca5645 100644 --- a/src/crypto/hash/index.js +++ b/src/crypto/hash/index.js @@ -1,18 +1,20 @@ /** - * @requires crypto/hash/sha + * @requires rusha + * @requires asmcrypto.js + * @requires hash.js * @requires crypto/hash/md5 * @requires util * @module crypto/hash */ import Rusha from 'rusha'; -import asmCrypto from 'asmcrypto-lite'; +import { SHA256 } from 'asmcrypto.js'; import sha224 from 'hash.js/lib/hash/sha/224'; import sha384 from 'hash.js/lib/hash/sha/384'; import sha512 from 'hash.js/lib/hash/sha/512'; import { ripemd160 } from 'hash.js/lib/hash/ripemd'; import md5 from './md5'; -import util from '../../util.js'; +import util from '../../util'; const rusha = new Rusha(); const nodeCrypto = util.getNodeCrypto(); @@ -54,7 +56,7 @@ if (nodeCrypto) { // Use Node native crypto for all hash functions /** @see module:hash.js */ sha224: hashjs_hash(sha224), /** @see module:asmcrypto */ - sha256: asmCrypto.SHA256.bytes, + sha256: SHA256.bytes, /** @see module:hash.js */ sha384: hashjs_hash(sha384), // TODO, benchmark this vs asmCrypto's SHA512 diff --git a/src/packet/sym_encrypted_integrity_protected.js b/src/packet/sym_encrypted_integrity_protected.js index dc43541e..763384c4 100644 --- a/src/packet/sym_encrypted_integrity_protected.js +++ b/src/packet/sym_encrypted_integrity_protected.js @@ -25,16 +25,17 @@ * created for OpenPGP that addresses the problem of detecting a modification to * encrypted data. It is used in combination with a Modification Detection Code * packet. + * @requires asmcrypto.js * @requires crypto - * @requires util * @requires enums + * @requires util * @module packet/sym_encrypted_integrity_protected */ -import asmCrypto from 'asmcrypto-lite'; -import util from '../util.js'; +import { AES_CFB } from 'asmcrypto.js'; import crypto from '../crypto'; -import enums from '../enums.js'; +import enums from '../enums'; +import util from '../util'; const nodeCrypto = util.getNodeCrypto(); const Buffer = util.getNodeBuffer(); @@ -145,7 +146,7 @@ function aesEncrypt(algo, prefix, pt, key) { if (nodeCrypto) { // Node crypto library. return nodeEncrypt(algo, prefix, pt, key); } // asm.js fallback - return asmCrypto.AES_CFB.encrypt(util.concatUint8Array([prefix, pt]), key); + return AES_CFB.encrypt(util.concatUint8Array([prefix, pt]), key); } function aesDecrypt(algo, ct, key) { @@ -153,7 +154,7 @@ function aesDecrypt(algo, ct, key) { if (nodeCrypto) { // Node crypto library. pt = nodeDecrypt(algo, ct, key); } else { // asm.js fallback - pt = asmCrypto.AES_CFB.decrypt(ct, key); + pt = AES_CFB.decrypt(ct, key); } return pt.subarray(crypto.cipher[algo].blockSize + 2, pt.length); // Remove random prefix }