diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js index 01348834..a7252a86 100644 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -160,7 +160,7 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password, const request = { action: kpAction, message: keepass.encrypt(messageData, nonce), - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -221,7 +221,7 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb const request = { action: kpAction, message: keepass.encrypt(messageData, nonce), - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -285,7 +285,7 @@ keepass.generatePassword = function(callback, tab, forceCallback) { const request = { action: kpAction, - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -334,7 +334,7 @@ keepass.associate = function(callback, tab) { page.tabs[tab.id].errorMessage = null; const kpAction = kpActions.ASSOCIATE; - const key = keepass.b64e(keepass.keyPair.publicKey); + const key = nacl.util.encodeBase64(keepass.keyPair.publicKey); const nonce = nacl.randomBytes(keepass.keySize); const messageData = { @@ -345,7 +345,7 @@ keepass.associate = function(callback, tab) { const request = { action: kpAction, message: keepass.encrypt(messageData, nonce), - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -427,7 +427,7 @@ keepass.testAssociation = function(callback, tab, enableTimeout = false) { const request = { action: kpAction, message: keepass.encrypt(messageData, nonce), - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -494,7 +494,7 @@ keepass.getDatabaseHash = function(callback, tab, enableTimeout = false) { const request = { action: kpAction, message: encrypted, - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -549,15 +549,14 @@ keepass.changePublicKeys = function(tab, enableTimeout = false) { } const kpAction = kpActions.CHANGE_PUBLIC_KEYS; - const key = keepass.b64e(keepass.keyPair.publicKey); + const key = nacl.util.encodeBase64(keepass.keyPair.publicKey); let nonce = nacl.randomBytes(keepass.keySize); - nonce = keepass.b64e(nonce); - keepass.clientID = keepass.b64e(nacl.randomBytes(keepass.keySize)); + nonce = nacl.util.encodeBase64(nonce); + keepass.clientID = nacl.util.encodeBase64(nacl.randomBytes(keepass.keySize)); const request = { action: kpAction, publicKey: key, - proxyPort: (page.settings.port ? page.settings.port : 19700), nonce: nonce, clientID: keepass.clientID }; @@ -573,7 +572,7 @@ keepass.changePublicKeys = function(tab, enableTimeout = false) { } else { keepass.isKeePassXCAvailable = true; - console.log('Server public key: ' + keepass.b64e(keepass.serverPublicKey)); + console.log('Server public key: ' + nacl.util.encodeBase64(keepass.serverPublicKey)); } resolve(true); }); @@ -597,7 +596,7 @@ keepass.lockDatabase = function(tab) { const request = { action: kpAction, message: keepass.encrypt(messageData, nonce), - nonce: keepass.b64e(nonce), + nonce: nacl.util.encodeBase64(nonce), clientID: keepass.clientID }; @@ -627,7 +626,7 @@ keepass.lockDatabase = function(tab) { keepass.generateNewKeyPair = function() { keepass.keyPair = nacl.box.keyPair(); - //console.log(keepass.b64e(keepass.keyPair.publicKey) + ' ' + keepass.b64e(keepass.keyPair.secretKey)); + //console.log(nacl.util.encodeBase64(keepass.keyPair.publicKey) + ' ' + nacl.util.encodeBase64(keepass.keyPair.secretKey)); }; keepass.isConfigured = function() { @@ -810,13 +809,14 @@ keepass.verifyKeyResponse = function(response, key, nonce) { } let reply = false; - if (keepass.b64d(nonce).length !== nacl.secretbox.nonceLength) + if (nacl.util.decodeBase64(nonce).length !== nacl.secretbox.nonceLength) { return false; + } reply = (response.nonce === nonce); if (response.publicKey) { - keepass.serverPublicKey = keepass.b64d(response.publicKey); + keepass.serverPublicKey = nacl.util.decodeBase64(response.publicKey); reply = true; } @@ -832,8 +832,9 @@ keepass.verifyResponse = function(response, nonce, id) { keepass.associated.hash = keepass.databaseHash; - if (keepass.b64d(response.nonce).length !== nacl.secretbox.nonceLength) + if (nacl.util.decodeBase64(response.nonce).length !== nacl.secretbox.nonceLength) { return false; + } keepass.associated.value = (response.nonce === nonce); @@ -856,14 +857,6 @@ keepass.handleError = function(tab, errorCode, errorMessage = '') { } }; -keepass.b64e = function(d) { - return nacl.util.encodeBase64(d); -}; - -keepass.b64d = function(d) { - return nacl.util.decodeBase64(d); -}; - keepass.getCryptoKey = function() { let dbkey = null; let dbid = null; @@ -890,15 +883,15 @@ keepass.encrypt = function(input, nonce) { if (keepass.serverPublicKey) { const message = nacl.box(messageData, nonce, keepass.serverPublicKey, keepass.keyPair.secretKey); if (message) { - return keepass.b64e(message); + return nacl.util.encodeBase64(message); } } return ''; }; keepass.decrypt = function(input, nonce, toStr) { - const m = keepass.b64d(input); - const n = keepass.b64d(nonce); + const m = nacl.util.decodeBase64(input); + const n = nacl.util.decodeBase64(nonce); const res = nacl.box.open(m, n, keepass.serverPublicKey, keepass.keyPair.secretKey); return res; }; diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js index 7aba064b..5b9c5255 100644 --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -4,8 +4,7 @@ const defaultSettings = { autoFillAndSend: true, usePasswordGenerator: true, autoFillSingleEntry: false, - autoRetrieveCredentials: true, - proxyPort: '19700' + autoRetrieveCredentials: true }; var page = {}; @@ -35,9 +34,6 @@ page.initSettings = function() { if (!('autoRetrieveCredentials' in page.settings)) { page.settings.autoRetrieveCredentials = defaultSettings.autoRetrieveCredentials; } - if (!('port' in page.settings)) { - page.settings.port = defaultSettings.proxyPort; - } browser.storage.local.set({'settings': page.settings}); resolve(); }); diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html index 9da60520..1a243361 100644 --- a/keepassxc-browser/options/options.html +++ b/keepassxc-browser/options/options.html @@ -84,24 +84,6 @@
-