diff options
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 } |