From 418940b10605e1a6c9b87146b9aac3c26c431788 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 1 May 2018 15:24:07 +0200 Subject: Fix channel joining (converting join key to node info) --- src/main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1e63d70..4986e6c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,19 +34,24 @@ string createChannelJoinKey(const unique_ptr &da string createJoinKeyFromDatabaseNode(const odhtdb::DatabaseNode &databaseNode) { - return databaseNode.getRequestHash()->toString() + "&" + odhtdb::bin2hex((const char*)databaseNode.getNodeEncryptionKey()->data, databaseNode.getNodeEncryptionKey()->size); + string result; + result += databaseNode.getRequestHash()->toString(); + result += "&"; + result += odhtdb::bin2hex((const char*)databaseNode.getNodeEncryptionKey()->data, databaseNode.getNodeEncryptionKey()->size); + return result; } odhtdb::DatabaseNode createDatabaseNodeFromJoinKey(const string &joinKey) { - string nodeHashStr = odhtdb::hex2bin(joinKey.c_str(), 64); + string nodeHashRaw = odhtdb::hex2bin(joinKey.c_str(), 64); shared_ptr nodeHash = make_shared(); - memcpy(nodeHash->getData(), nodeHashStr.data(), nodeHashStr.size()); + memcpy(nodeHash->getData(), nodeHashRaw.data(), nodeHashRaw.size()); - string nodeEncryptionKeyStr = odhtdb::hex2bin(joinKey.c_str() + 65, 64); + string nodeEncryptionKeyRaw = odhtdb::hex2bin(joinKey.c_str() + 65, 64); shared_ptr encryptionKey = make_shared(); - encryptionKey->data = new char[nodeEncryptionKeyStr.size()]; - encryptionKey->size = nodeEncryptionKeyStr.size(); + encryptionKey->data = new char[nodeEncryptionKeyRaw.size()]; + memcpy(encryptionKey->data, nodeEncryptionKeyRaw.data(), nodeEncryptionKeyRaw.size()); + encryptionKey->size = nodeEncryptionKeyRaw.size(); return odhtdb::DatabaseNode(encryptionKey, nodeHash); } -- cgit v1.2.3