diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-10-21 03:07:53 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-10-21 03:07:53 +0800 |
commit | 0deed1775237bc8d48eb41e83b5a661b55e4b6be (patch) | |
tree | d2453cb6ef09a0c76fc413d93d1a6cd7c008f117 /app | |
parent | 383f8ea7dc4a264613cfe92b257878eb78438ce7 (diff) | |
download | tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar.gz tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar.bz2 tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar.lz tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar.xz tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.tar.zst tangerine-wallet-browser-0deed1775237bc8d48eb41e83b5a661b55e4b6be.zip |
Fix tests
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/keyring-controller.js | 2 | ||||
-rw-r--r-- | app/scripts/lib/encryptor.js | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index f6b1e9358..d25dddba1 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -35,7 +35,7 @@ module.exports = class KeyringController extends EventEmitter { } createNewVault(password, entropy, cb) { - const salt = generateNewSalt() + const salt = generateSalt() this.configManager.setSalt(salt) this.loadKey(password) .then((key) => { diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js index 8a3b0b023..3d069ab33 100644 --- a/app/scripts/lib/encryptor.js +++ b/app/scripts/lib/encryptor.js @@ -42,8 +42,9 @@ function encryptWithKey (key, dataObj) { iv: vector, }, key, dataBuffer).then(function(buf){ var buffer = new Uint8Array(buf) - var vectorStr = serializeBufferForStorage(vector) - return serializeBufferForStorage(buffer) + vectorStr + var vectorStr = encodeBufferToBase64(vector) + var vaultStr = encodeBufferToBase64(buffer) + return `${vaultStr}\\${vectorStr}` }) } @@ -56,9 +57,9 @@ function decrypt (password, text) { } function decryptWithKey (key, text) { - const parts = text.split('0x') - const encryptedData = serializeBufferFromStorage(parts[1]) - const vector = serializeBufferFromStorage(parts[2]) + const parts = text.split('\\') + const encryptedData = decodeBase64ToBuffer(parts[0]) + const vector = decodeBase64ToBuffer(parts[1]) return crypto.subtle.decrypt({name: 'AES-GCM', iv: vector}, key, encryptedData) .then(function(result){ const decryptedData = new Uint8Array(result) @@ -128,8 +129,9 @@ function encodeBufferToBase64 (buf) { } function decodeBase64ToBuffer (base64) { - var u8_2 = new Uint8Array(atob(b64encoded).split("") + var buf = new Uint8Array(atob(base64).split('') .map(function(c) { return c.charCodeAt(0) })) + return buf } |