diff --git a/src/js/crypto/pbkdf2-worker.js b/src/js/crypto/pbkdf2-worker.js index a70c6f4..3a97274 100644 --- a/src/js/crypto/pbkdf2-worker.js +++ b/src/js/crypto/pbkdf2-worker.js @@ -2,11 +2,7 @@ 'use strict'; // import web worker dependencies - importScripts('../../lib/crypto-js/core.js'); - importScripts('../../lib/crypto-js/enc-base64.js'); - importScripts('../../lib/crypto-js/sha1.js'); - importScripts('../../lib/crypto-js/hmac.js'); - importScripts('../../lib/crypto-js/pbkdf2.js'); + importScripts('../../lib/forge/forge.rsa.bundle.js'); importScripts('../app-config.js'); importScripts('./pbkdf2.js'); diff --git a/src/js/crypto/pbkdf2.js b/src/js/crypto/pbkdf2.js index 90764c6..f21635b 100644 --- a/src/js/crypto/pbkdf2.js +++ b/src/js/crypto/pbkdf2.js @@ -1,5 +1,5 @@ /** - * A Wrapper for Crypto.js's PBKDF2 function + * A Wrapper for Forge's PBKDF2 function */ app.crypto.PBKDF2 = function() { 'use strict'; @@ -11,12 +11,9 @@ app.crypto.PBKDF2 = function() { * @return [String] The base64 encoded key */ this.getKey = function(password, keySize) { - var salt = CryptoJS.enc.Base64.parse("vbhmLjC+Ub6MSbhS6/CkOwxB25wvwRkSLP2DzDtYb+4="); // from random 256 bit value - var key = CryptoJS.PBKDF2(password, salt, { - keySize: keySize / 32, - iterations: 1000 - }); - var keyBase64 = CryptoJS.enc.Base64.stringify(key); + var salt = forge.util.decode64("vbhmLjC+Ub6MSbhS6/CkOwxB25wvwRkSLP2DzDtYb+4="); + var key = forge.pkcs5.pbkdf2(password, salt, 1000, keySize / 8); + var keyBase64 = forge.util.encode64(key); return keyBase64; }; diff --git a/src/lib/forge/forge.rsa.bundle.js b/src/lib/forge/forge.rsa.bundle.js index 0f39dca..3c21f6e 100644 --- a/src/lib/forge/forge.rsa.bundle.js +++ b/src/lib/forge/forge.rsa.bundle.js @@ -11659,4 +11659,4 @@ if(nodeDefine || typeof define === 'function') { } })(); -})((typeof window !== 'undefined') ? window : null); \ No newline at end of file +})((typeof window !== 'undefined') ? window : 'undefined'); \ No newline at end of file