From 02a61fd36ffbc45500f8c18582114f38ef2547b2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 17 May 2018 01:43:40 +0200 Subject: Fix join channel by invite key, wrong encryption key was used --- src/main.cpp | 8 +++++--- 1 file 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 channelEncryptionKey = make_shared(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); -- cgit v1.2.3