aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-01 15:24:07 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-01 15:24:10 +0200
commit418940b10605e1a6c9b87146b9aac3c26c431788 (patch)
tree928e49d2ec7c03cffc212b7482c6d38448da3401
parent8b1d23b390b8184c028de10138a3ffeb27421e7f (diff)
Fix channel joining (converting join key to node info)
-rw-r--r--src/main.cpp17
1 files changed, 11 insertions, 6 deletions
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<odhtdb::DatabaseCreateResponse> &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<odhtdb::Hash> nodeHash = make_shared<odhtdb::Hash>();
- 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<odhtdb::OwnedMemory> encryptionKey = make_shared<odhtdb::OwnedMemory>();
- 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);
}