diff --git a/package.json b/package.json index 22753224..e80716e9 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "dependencies": { "@mattiasbuelens/web-streams-polyfill": "0.1.0-alpha.4", "address-rfc2822": "^2.0.3", - "asmcrypto.js": "^0.22.0", + "asmcrypto.js": "^2.3.0", "asn1.js": "^5.0.0", "bn.js": "^4.11.8", "buffer": "^5.0.8", diff --git a/src/crypto/cipher/aes.js b/src/crypto/cipher/aes.js index a41c89aa..ff389480 100644 --- a/src/crypto/cipher/aes.js +++ b/src/crypto/cipher/aes.js @@ -2,7 +2,7 @@ * @requires asmcrypto.js */ -import { AES_ECB } from 'asmcrypto.js/src/aes/ecb/ecb'; +import { AES_ECB } from 'asmcrypto.js/dist_es8/aes/ecb'; // TODO use webCrypto or nodeCrypto when possible. function aes(length) { @@ -10,11 +10,11 @@ function aes(length) { const aes_ecb = new AES_ECB(key); this.encrypt = function(block) { - return aes_ecb.encrypt(block).result; + return aes_ecb.encrypt(block); }; this.decrypt = function(block) { - return aes_ecb.decrypt(block).result; + return aes_ecb.decrypt(block); }; }; diff --git a/src/crypto/cmac.js b/src/crypto/cmac.js index de0b9146..d34838a6 100644 --- a/src/crypto/cmac.js +++ b/src/crypto/cmac.js @@ -6,7 +6,7 @@ * @module crypto/cmac */ -import { AES_CBC } from 'asmcrypto.js/src/aes/cbc/exports'; +import { AES_CBC } from 'asmcrypto.js/dist_es8/aes/cbc'; import util from '../util'; const webCrypto = util.getWebCrypto(); diff --git a/src/crypto/eax.js b/src/crypto/eax.js index acad0d67..b40f64ef 100644 --- a/src/crypto/eax.js +++ b/src/crypto/eax.js @@ -24,7 +24,7 @@ * @module crypto/eax */ -import { AES_CTR } from 'asmcrypto.js/src/aes/ctr/exports'; +import { AES_CTR } from 'asmcrypto.js/dist_es8/aes/ctr'; import CMAC from './cmac'; import util from '../util'; diff --git a/src/crypto/gcm.js b/src/crypto/gcm.js index 888decd8..55c25c80 100644 --- a/src/crypto/gcm.js +++ b/src/crypto/gcm.js @@ -23,7 +23,7 @@ * @module crypto/gcm */ -import { AES_GCM } from 'asmcrypto.js/src/aes/gcm/exports'; +import { AES_GCM } from 'asmcrypto.js/dist_es8/aes/gcm'; import util from '../util'; const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9 diff --git a/src/crypto/hash/index.js b/src/crypto/hash/index.js index 92a0987a..65a18bfa 100644 --- a/src/crypto/hash/index.js +++ b/src/crypto/hash/index.js @@ -10,9 +10,9 @@ * @module crypto/hash */ -import { SHA1 } from 'asmcrypto.js/src/hash/sha1/exports'; -import { SHA256 } from 'asmcrypto.js/src/hash/sha256/exports'; -import { SHA512 } from 'asmcrypto.js/src/hash/sha512/exports'; +import { Sha1 } from 'asmcrypto.js/dist_es8/hash/sha1/sha1'; +import { Sha256 } from 'asmcrypto.js/dist_es8/hash/sha256/sha256'; +import { Sha512 } from 'asmcrypto.js/dist_es8/hash/sha512/sha512'; import sha224 from 'hash.js/lib/hash/sha/224'; import sha384 from 'hash.js/lib/hash/sha/384'; import { ripemd160 } from 'hash.js/lib/hash/ripemd'; @@ -68,11 +68,11 @@ if (nodeCrypto) { // Use Node native crypto for all hash functions } else { // Use JS fallbacks hash_fns = { md5: md5, - sha1: asmcrypto_hash(SHA1), + sha1: asmcrypto_hash(Sha1), sha224: hashjs_hash(sha224), - sha256: asmcrypto_hash(SHA256), + sha256: asmcrypto_hash(Sha256), sha384: hashjs_hash(sha384), - sha512: asmcrypto_hash(SHA512), + sha512: asmcrypto_hash(Sha512), ripemd: hashjs_hash(ripemd160) }; } diff --git a/src/packet/sym_encrypted_integrity_protected.js b/src/packet/sym_encrypted_integrity_protected.js index 6b6b2397..d5176dda 100644 --- a/src/packet/sym_encrypted_integrity_protected.js +++ b/src/packet/sym_encrypted_integrity_protected.js @@ -24,7 +24,7 @@ * @requires util */ -import { AES_CFB, AES_CFB_Decrypt, AES_CFB_Encrypt } from 'asmcrypto.js/src/aes/cfb/exports'; +import { AES_CFB } from 'asmcrypto.js/dist_es8/aes/cfb'; import config from '../config'; import crypto from '../crypto'; @@ -169,8 +169,8 @@ function aesEncrypt(algo, pt, key) { if (nodeCrypto) { // Node crypto library. return nodeEncrypt(algo, pt, key); } // asm.js fallback - const cfb = new AES_CFB_Encrypt(key); - return stream.transform(pt, value => cfb.process(value).result, () => cfb.finish().result); + const cfb = new AES_CFB(key); + return stream.transform(pt, value => cfb.AES_Encrypt_process(value), () => cfb.AES_Encrypt_finish()); } function aesDecrypt(algo, ct, key) { @@ -179,8 +179,8 @@ function aesDecrypt(algo, ct, key) { pt = nodeDecrypt(algo, ct, key); } else { // asm.js fallback if (util.isStream(ct)) { - const cfb = new AES_CFB_Decrypt(key); - pt = stream.transform(ct, value => cfb.process(value).result, () => cfb.finish().result); + const cfb = new AES_CFB(key); + pt = stream.transform(ct, value => cfb.AES_Decrypt_process(value), () => cfb.AES_Decrypt_finish()); } else { pt = AES_CFB.decrypt(ct, key); }