diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-10-15 07:28:08 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-10-15 07:29:24 +0800 |
commit | 036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c (patch) | |
tree | aea7c554834f877092716509831076165c0a2875 | |
parent | 69aed23e9b8af5b620576ad5586d37eea99793ef (diff) | |
download | tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar.gz tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar.bz2 tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar.lz tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar.xz tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.tar.zst tangerine-wallet-browser-036b0e4ccabded3c3dda39f8d81b9fa3fc07dd9c.zip |
Linted
-rw-r--r-- | app/scripts/lib/encryptor.js | 14 | ||||
-rw-r--r-- | test/integration/lib/encryptor-test.js | 1 |
2 files changed, 5 insertions, 10 deletions
diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js index 4b3c7eb8e..91d6ed5ce 100644 --- a/app/scripts/lib/encryptor.js +++ b/app/scripts/lib/encryptor.js @@ -1,5 +1,4 @@ var ethUtil = require('ethereumjs-util') -var vector = global.crypto.getRandomValues(new Uint8Array(16)) module.exports = { @@ -36,7 +35,7 @@ function encryptWithKey (key, dataObj) { return global.crypto.subtle.encrypt({ name: 'AES-GCM', - iv: vector + iv: vector, }, key, dataBuffer).then(function(buf){ var buffer = new Uint8Array(buf) var vectorStr = serializeBufferForStorage(vector) @@ -52,17 +51,14 @@ function decrypt (password, text) { }) } -// AUDIT: See if this still works when generating a fresh vector function decryptWithKey (key, text) { const parts = text.split('0x') const encryptedData = serializeBufferFromStorage(parts[1]) const vector = serializeBufferFromStorage(parts[2]) - debugger - return crypto.subtle.decrypt({name: "AES-GCM", iv: vector}, key, encryptedData) + return crypto.subtle.decrypt({name: 'AES-GCM', iv: vector}, key, encryptedData) .then(function(result){ const decryptedData = new Uint8Array(result) const decryptedStr = convertArrayBufferViewtoString(decryptedData) - const numArr = decryptedStr.split(',') const decryptedObj = JSON.parse(decryptedStr) return decryptedObj }) @@ -96,10 +92,10 @@ function keyFromPassword (password) { function serializeBufferFromStorage (str) { str = ethUtil.stripHexPrefix(str) - var buf = new Uint8Array(str.length/2) - for (var i = 0; i < str.length; i+= 2) { + var buf = new Uint8Array(str.length / 2) + for (var i = 0; i < str.length; i += 2) { var seg = str.substr(i, 2) - buf[i/2] = parseInt(seg, 16) + buf[i / 2] = parseInt(seg, 16) } return buf } diff --git a/test/integration/lib/encryptor-test.js b/test/integration/lib/encryptor-test.js index 3297ad177..88ebed51b 100644 --- a/test/integration/lib/encryptor-test.js +++ b/test/integration/lib/encryptor-test.js @@ -38,7 +38,6 @@ QUnit.test('encryptor:encrypt & decrypt', function(assert) { done() }) .catch(function(reason) { - debugger assert.ifError(reason, 'threw an error') }) |