diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-17 01:43:40 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-17 01:43:43 +0200 |
commit | 02a61fd36ffbc45500f8c18582114f38ef2547b2 (patch) | |
tree | b4d1ee310a6f639c99d33e2c0c2bce715ad44d0d | |
parent | 9fca65c2d457dd4bba07a2c4f3b59173436da26a (diff) |
Fix join channel by invite key, wrong encryption key was used
-rw-r--r-- | src/main.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index f8820f3..776db5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -485,11 +485,11 @@ int main(int argc, char **argv) encryptionKey->getView()); if(decryptedMsg.getDecryptedText().size != odhtdb::ENCRYPTION_KEY_BYTE_SIZE + odhtdb::PUBLIC_KEY_NUM_BYTES) { - fprintf(stderr, "Invite response was of unexpected size, maybe it wasn't mean for us?\n"); + fprintf(stderr, "Invite response was of unexpected size, maybe it wasn't meant for us?\n"); return true; } - odhtdb::DataView channelEncryptionKey(decryptedMsg.getDecryptedText().data, odhtdb::ENCRYPTION_KEY_BYTE_SIZE); + odhtdb::DataView channelEncryptionKeyRaw(decryptedMsg.getDecryptedText().data, odhtdb::ENCRYPTION_KEY_BYTE_SIZE); odhtdb::DataView invitedUserPublicKey((u8*)decryptedMsg.getDecryptedText().data + odhtdb::ENCRYPTION_KEY_BYTE_SIZE, odhtdb::PUBLIC_KEY_NUM_BYTES); if(memcmp(keyPair->getPublicKey().getData(), invitedUserPublicKey.data, odhtdb::PUBLIC_KEY_NUM_BYTES) != 0) { @@ -497,7 +497,9 @@ int main(int argc, char **argv) return true; } - odhtdb::DatabaseNode databaseNode(encryptionKey, nodeHash); + shared_ptr<odhtdb::OwnedByteArray> channelEncryptionKey = make_shared<odhtdb::OwnedByteArray>(new u8[channelEncryptionKeyRaw.size], channelEncryptionKeyRaw.size); + memcpy(channelEncryptionKey->data, channelEncryptionKeyRaw.data, channelEncryptionKeyRaw.size); + odhtdb::DatabaseNode databaseNode(channelEncryptionKey, nodeHash); database->storeNodeInfoForUserEncrypted(databaseNode, currentUsername, currentPassword, *keyPair); printf("Got a response from a person in the channel, we might get added...\n"); waitingToJoinChannels.push_back(databaseNode); |