lowercase user/device for decryption key

also spaces in device name are converted to dashes, so
"Will-iPhone 6s" should now be key "will-iphone-6s"
addresses #108
This commit is contained in:
Jan-Piet Mens
2016-03-25 14:54:50 +01:00
parent 15937f91e7
commit 093851eb1d
2 changed files with 7 additions and 1 deletions

View File

@@ -977,7 +977,7 @@ This named lmdb database is keyed on topic name (`owntracks/jane/phone`). If the
#### `keys`
If the _recorder_ was built with encryption support (see below), this named database contains the secret decryption keys for users/device pairs. The LMDB key is the username followed by a dash followed by the device name, all lower case. For example, if user Jjolie with device iPhone needs a secret entered, the database key will be `jjolie-iphone`. This can be entered into the database as follows:
If the _recorder_ was built with encryption support (see below), this named database contains the secret decryption keys for users/device pairs. The LMDB key is the username followed by a dash followed by the device name, all lower case, with spaces translated to a single dash. For example, if user Jjolie with device iPhone needs a secret entered, the database key will be `jjolie-iphone`. This can be entered into the database as follows:
```bash
echo "jjolie-iphone s3cr1t" | ocat --load=keys

View File

@@ -481,6 +481,12 @@ unsigned char *decrypt(struct udata *ud, char *topic, char *p64, char *username,
utstring_renew(userdev);
utstring_printf(userdev, "%s-%s", username, device);
lowercase(UB(userdev));
for (n = 0; n < strlen(UB(userdev)); n++) {
if (UB(userdev)[n] == ' ')
UB(userdev)[n] = '-';
}
memset(key, 0, sizeof(key));
klen = gcache_get(ud->keydb, (char *)UB(userdev), (char *)key, sizeof(key));
if (klen < 1) {