Update to asmcrypto.js 2

This commit is contained in:
Daniel Huigens 2018-06-29 23:26:33 +02:00
parent e66d44e42d
commit d489f3369f
7 changed files with 18 additions and 18 deletions

View File

@ -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",

View File

@ -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);
};
};

View File

@ -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();

View File

@ -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';

View File

@ -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

View File

@ -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)
};
}

View File

@ -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);
}