From 8b94c3bf3a06caa7b003fe61e8242bdb00004eb5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 14 May 2018 00:20:11 +0200 Subject: Replace files with sqlite Using sqlite because sqlite has transactions, storing/loading from files automatically, unloading data that is not accessed often. Removed cosmetic data (node name, username). They can be added using addData by the application that uses odhtdb instead. Database callback functions can now be called with stored data using database.loadNode function. TODO: Add local user storage (with password) back, it has been temorary disabled --- src/Encryption.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Encryption.cpp') diff --git a/src/Encryption.cpp b/src/Encryption.cpp index 9000519..ff37270 100644 --- a/src/Encryption.cpp +++ b/src/Encryption.cpp @@ -19,7 +19,7 @@ namespace odhtdb memcpy(key, _key.data, _key.size); } else - crypto_aead_xchacha20poly1305_ietf_keygen(key); + generateKey(key); randombytes_buf(nonce, ENCRYPTION_NONCE_BYTE_SIZE); if(crypto_aead_xchacha20poly1305_ietf_encrypt(cipherText, &cipherTextLength, (const unsigned char*)data.data, data.size, (const unsigned char*)additionalData.data, additionalData.size, nullptr, nonce, key) < 0) @@ -46,6 +46,11 @@ namespace odhtdb return DataView((void*)cipherText, cipherTextLength); } + void Encryption::generateKey(unsigned char *output) + { + crypto_aead_xchacha20poly1305_ietf_keygen(output); + } + Decryption::Decryption(const DataView &data, const DataView &nonce, const DataView &key) { decryptedTextLength = data.size; -- cgit v1.2.3