aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-03-13 08:20:57 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commit89d9a70f8bc284970138d0fb824b5fcbf13d0b3c (patch)
tree97a133ebe573b806caab17c85a4a99e29a35aa93
parent5a8727e34b938b70623ca865273fd81c7604b461 (diff)
Fix PrivateKey/PublicKey ::toString
-rw-r--r--include/odhtdb/Database.hpp1
-rw-r--r--src/Signature.cpp12
2 files changed, 4 insertions, 9 deletions
diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp
index 6bc7bc5..5114d28 100644
--- a/include/odhtdb/Database.hpp
+++ b/include/odhtdb/Database.hpp
@@ -112,6 +112,7 @@ namespace odhtdb
DatabaseCreateResponse(LocalUser *nodeAdminUser, const std::shared_ptr<char*> &key, const std::shared_ptr<Hash> &hash);
const LocalUser* getNodeAdminUser() const;
+ // Size of encryption key is odhtdb::KEY_BYTE_SIZE (found in Encryption.hpp)
const std::shared_ptr<char*> getNodeEncryptionKey() const;
const std::shared_ptr<Hash> getRequestHash() const;
private:
diff --git a/src/Signature.cpp b/src/Signature.cpp
index cba5954..b6fb12a 100644
--- a/src/Signature.cpp
+++ b/src/Signature.cpp
@@ -1,7 +1,7 @@
#include "../include/odhtdb/Signature.hpp"
#include "../include/odhtdb/Hash.hpp"
+#include "../include/odhtdb/bin2hex.hpp"
#include <sodium/crypto_sign_ed25519.h>
-#include <sodium/utils.h>
#include <cstring>
using namespace std;
@@ -61,10 +61,7 @@ namespace odhtdb
string PublicKey::toString() const
{
- string result;
- result.resize(PUBLIC_KEY_NUM_BYTES * 2 + 1);
- sodium_bin2hex(&result[0], PUBLIC_KEY_NUM_BYTES * 2 + 1, (const unsigned char*)data, PUBLIC_KEY_NUM_BYTES);
- return result;
+ return bin2hex(data, PUBLIC_KEY_NUM_BYTES);
}
PrivateKey::PrivateKey(const char *_data, size_t size)
@@ -108,10 +105,7 @@ namespace odhtdb
string PrivateKey::toString() const
{
- string result;
- result.resize(PRIVATE_KEY_NUM_BYTES * 2);
- sodium_bin2hex(&result[0], PRIVATE_KEY_NUM_BYTES * 2 + 1, (const unsigned char*)data, PRIVATE_KEY_NUM_BYTES);
- return result;
+ return bin2hex(data, PRIVATE_KEY_NUM_BYTES);
}
KeyPair::KeyPair()