From 10406eb5c2c50bb6df2e38fa41b783f520823965 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 27 May 2017 15:08:51 +0300 Subject: [PATCH] Updated tweetnacl-js to 1.0.0 --- CHANGELOG | 44 ++++++++++++++++++ chromeKeePassXC/background/keepass.js | 15 +++--- chromeKeePassXC/background/nacl-util.js | 51 --------------------- chromeKeePassXC/background/nacl-util.min.js | 1 + chromeKeePassXC/chromekeepassxc.js | 20 +++++--- chromeKeePassXC/manifest.json | 2 +- 6 files changed, 69 insertions(+), 64 deletions(-) create mode 100644 CHANGELOG delete mode 100644 chromeKeePassXC/background/nacl-util.js create mode 100755 chromeKeePassXC/background/nacl-util.min.js diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..5a82e86 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,44 @@ +0.1.6 (2017-05-27) +========================= +- Upgraded tweetnacl-js to 1.0.0 +- Upgraded tweetnacl-utils-js to 0.15.0 +- Some code fixes concerning encryption and decryption +- Redesigned password generator dialog + +0.1.5 (2017-05-22) +========================= +- Fixed a few deprecated functions +- Added some more Firefox compatible code (Firefox now works 90%!) +- Removed an unncecessary .map file + +0.1.4 (2017-05-21) +========================= +- Upgraded manifest options to V2 +- Added some more Firefox compatible code + +0.1.3 (2017-05-19) +========================= +- Fixed a bug showing correct status in the popup +- Added a license for a quick method to determine which browser is used in API calls + +0.1.2 (2017-05-18) +========================= +- Upgraded jquery from 3.2.0 to 3.2.1 +- Removed unnecessary images +- Upgraded deprecated API calls (extension -> runtime, so from synchronous to asynchronous) +- Partial Firefox support (the extension can be loaded but functionality is still limited) + +0.1.1 (2017-04-28) +========================= + +- This version works with the KeePassXC fork +- Upgraded JavaScripts to work asynchronously + +0.1.0 (2017-04-12) +========================= + +- Replaced crypto libraries with tweetnacl-js +- New application and popup icons +- Upgraded bootstrap to version 3.3.7 +- Upgraded jquery from 1.11 to 3.2.0 +- Upgraded jquery-ui from 1.10.2 to 1.12.1 \ No newline at end of file diff --git a/chromeKeePassXC/background/keepass.js b/chromeKeePassXC/background/keepass.js index 3100f97..8ea4d4c 100644 --- a/chromeKeePassXC/background/keepass.js +++ b/chromeKeePassXC/background/keepass.js @@ -76,7 +76,7 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password, keepass.callbackOnId(keepass.nativePort.onMessage, "set-login", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -146,7 +146,7 @@ keepass.retrieveCredentials = function (callback, tab, url, submiturl, forceCall keepass.callbackOnId(keepass.nativePort.onMessage, "get-logins", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -227,7 +227,7 @@ keepass.generatePassword = function (callback, tab, forceCallback) { keepass.callbackOnId(keepass.nativePort.onMessage, "generate-password", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -309,7 +309,7 @@ keepass.associate = function(callback, tab) { keepass.callbackOnId(keepass.nativePort.onMessage, "associate", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -390,7 +390,7 @@ keepass.testAssociation = function (callback, tab, triggerUnlock) { id: id, key: idkey }; - console.log(messageData); + var request = { action: "test-associate", message: keepass.encrypt(messageData, nonce), @@ -400,7 +400,7 @@ keepass.testAssociation = function (callback, tab, triggerUnlock) { keepass.callbackOnId(keepass.nativePort.onMessage, "test-associate", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) { + if (!res) { console.log("Failed to decrypt message"); } else @@ -766,6 +766,9 @@ keepass.setCryptoKey = function(id, key) { keepass.encrypt = function(input, nonce) { var messageData = nacl.util.decodeUTF8(JSON.stringify(input)); var message = nacl.box(messageData, nonce, keepass.serverPublicKey, keepass.keyPair.secretKey); + if (!message) { + return ""; + } return keepass.b64e(message); } diff --git a/chromeKeePassXC/background/nacl-util.js b/chromeKeePassXC/background/nacl-util.js deleted file mode 100644 index 804068b..0000000 --- a/chromeKeePassXC/background/nacl-util.js +++ /dev/null @@ -1,51 +0,0 @@ -// Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri. -// Public domain. -(function(root, f) { - 'use strict'; - if (typeof module !== 'undefined' && module.exports) module.exports = f(); - else if (root.nacl) root.nacl.util = f(); - else { - root.nacl = {}; - root.nacl.util = f(); - } -}(this, function() { - 'use strict'; - - var util = {}; - - util.decodeUTF8 = function(s) { - if (typeof s !== 'string') throw new TypeError('expected string'); - var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - }; - - util.encodeUTF8 = function(arr) { - var i, s = []; - for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i])); - return decodeURIComponent(escape(s.join(''))); - }; - - util.encodeBase64 = function(arr) { - if (typeof btoa === 'undefined') { - return (new Buffer(arr)).toString('base64'); - } else { - var i, s = [], len = arr.length; - for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i])); - return btoa(s.join('')); - } - }; - - util.decodeBase64 = function(s) { - if (typeof atob === 'undefined') { - return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0)); - } else { - var i, d = atob(s), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - } - }; - - return util; - -})); diff --git a/chromeKeePassXC/background/nacl-util.min.js b/chromeKeePassXC/background/nacl-util.min.js new file mode 100755 index 0000000..0867ece --- /dev/null +++ b/chromeKeePassXC/background/nacl-util.min.js @@ -0,0 +1 @@ +!function(e,n){"use strict";"undefined"!=typeof module&&module.exports?module.exports=n():e.nacl?e.nacl.util=n():(e.nacl={},e.nacl.util=n())}(this,function(){"use strict";function e(e){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}var n={};return n.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var n,r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length);for(n=0;n