diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-01 15:24:07 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-01 15:24:10 +0200 |
commit | 418940b10605e1a6c9b87146b9aac3c26c431788 (patch) | |
tree | 928e49d2ec7c03cffc212b7482c6d38448da3401 /src | |
parent | 8b1d23b390b8184c028de10138a3ffeb27421e7f (diff) |
Fix channel joining (converting join key to node info)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 17 |
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); } |