Changed database saving from hash to a current public key which acts as an id key.

This commit is contained in:
varjolintu 2017-04-04 17:56:56 +03:00
parent 708b0ad692
commit 93b083d345
4 changed files with 20 additions and 15 deletions

View file

@ -28,7 +28,7 @@ Now the requests are encrypted by [TweetNaCl.js](https://github.com/dchest/tweet
3. All messages (excluding get-databasehash) are now encrypted.
4. When chromeKeePassXC sends a message it is encrypted with KeePassXC's public key, a random generated nonce and chromeKeePassXC's secret key.
5. When KeePassXC sends a message it is encrypted with chromeKeePassXC's public key etc.
6. Databases are stored based on the database hash instead of the key because a new key pair is generated each time chromeKeePassXC is launched.
6. Databases are stored based on the current public key used with `associate`. A new key pair for data transfer is generated each time chromeKeePassXC is launched.
Encrypted messages are built with these JSON parameters:
- action - `test-associate`, `associate`, `get-logins`, `get-logins-count`, `set-login`...
@ -56,7 +56,8 @@ Response (success):
Unencrypted message:
```javascript
{
"action": "associate"
"action": "associate",
"key": "<current public key>"
}
```
@ -84,7 +85,8 @@ Response message data (success, decrypted):
Unencrypted message:
```javascript
{
"action": "test-associate"
"action": "test-associate",
"key": "<saved database public key>"
}
```

View file

@ -299,7 +299,8 @@ keepass.associate = function(callback, tab) {
var nonce = nacl.randomBytes(keepass.keySize);
var messageData = {
action: "associate"
action: "associate",
key: key
};
var request = {
@ -333,7 +334,7 @@ keepass.associate = function(callback, tab) {
page.tabs[tab.id].errorMessage = "KeePassXC association failed, try again.";
}
else {
keepass.setCryptoKey(id, key);
keepass.setCryptoKey(id, key); // Save the current public key as id key for the database
keepass.associated.value = true;
keepass.associated.hash = parsed.hash || 0;
}
@ -342,7 +343,6 @@ keepass.associate = function(callback, tab) {
}
}
});
keepass.nativePort.postMessage(request);
}
@ -364,9 +364,11 @@ keepass.testAssociation = function (tab, triggerUnlock) {
var key = keepass.b64e(keepass.keyPair.publicKey);
var nonce = nacl.randomBytes(keepass.keySize);
var idkey = keepass.getCryptoKey();
var messageData = {
"action": "test-associate",
action: "test-associate",
key: idkey
};
var request = {
@ -417,6 +419,7 @@ keepass.testAssociation = function (tab, triggerUnlock) {
}
}
}
return keepass.isAssociated();
}
});
keepass.nativePort.postMessage(request);
@ -571,7 +574,7 @@ keepass.saveKey = function(hash, id, key) {
if (!(hash in keepass.keyRing)) {
keepass.keyRing[hash] = {
"id": id,
//"key": key,
"key": key,
"hash": hash,
"icon": "blue",
"created": new Date(),
@ -580,7 +583,7 @@ keepass.saveKey = function(hash, id, key) {
}
else {
keepass.keyRing[hash].id = id;
//keepass.keyRing[hash].key = key;
keepass.keyRing[hash].key = key;
keepass.keyRing[hash].hash = hash;
}
localStorage.keyRing = JSON.stringify(keepass.keyRing);
@ -732,7 +735,7 @@ keepass.verifyKeyResponse = function(response, key, nonce) {
keepass.verifyResponse = function(response, nonce, id) {
keepass.associated.value = response.success;
if (!response.success) {
if (response.success != "true") {
keepass.associated.hash = null;
return false;
}
@ -771,11 +774,11 @@ keepass.getCryptoKey = function() {
var key = null;
if (id) {
//key = keepass.keyRing[keepass.databaseHash].key;
key = keepass.b64e(keepass.keyPair.publicKey);
key = keepass.keyRing[keepass.databaseHash].key;
}
return key ? [id, key] : null;
//return key ? [id, key] : null;
return key ? key : null;
}
keepass.setCryptoKey = function(id, key) {

View file

@ -169,7 +169,7 @@
<thead>
<tr>
<th>Identifier</th>
<th>Hash</th>
<th>Key</th>
<th>Last used</th>
<th>Created</th>
<th>Delete</th>

View file

@ -181,7 +181,7 @@ options.initConnectedDatabases = function() {
$("a.dropdown-toggle:first img:first", $tr).attr("src", "/icons/19x19/icon_normal_" + $icon + "_19x19.png");
$tr.children("td:first").text(options.keyRing[hash].id);
$tr.children("td:eq(1)").text(hash);
$tr.children("td:eq(1)").text(options.keyRing[hash].key);
var lastUsed = (options.keyRing[hash].lastUsed) ? new Date(options.keyRing[hash].lastUsed).toLocaleString() : "unknown";
$tr.children("td:eq(2)").text(lastUsed);
var date = (options.keyRing[hash].created) ? new Date(options.keyRing[hash].created).toLocaleDateString() : "unknown";