aboutsummaryrefslogtreecommitdiff
path: root/src/Encryption.cpp
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-05-16 09:47:31 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-05-16 09:47:34 +0200
commit7f19b686cc7b47346ba8bab89bb34188f366db10 (patch)
treed36db4f2cecdd572dfc49ae378be393d0c1744ca /src/Encryption.cpp
parent6d0eace64b37098e31c20758b066d4fe23c58a5c (diff)
Store node encryption key with user data, fix encryption bug when using additional data
Diffstat (limited to 'src/Encryption.cpp')
-rw-r--r--src/Encryption.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Encryption.cpp b/src/Encryption.cpp
index ff37270..d4763b8 100644
--- a/src/Encryption.cpp
+++ b/src/Encryption.cpp
@@ -7,7 +7,7 @@ namespace odhtdb
{
static_assert(ENCRYPTION_CHECKSUM_BYTE_SIZE == crypto_aead_xchacha20poly1305_ietf_ABYTES, "Encryption checksum key size has changed for some reason, oops...");
- Encryption::Encryption(const DataView &data, const DataView &additionalData, const DataView &_key)
+ Encryption::Encryption(const DataView &data, const DataView &_key)
{
cipherTextLength = crypto_aead_xchacha20poly1305_ietf_ABYTES + data.size;
cipherText = new unsigned char[cipherTextLength];
@@ -22,7 +22,7 @@ namespace odhtdb
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)
+ if(crypto_aead_xchacha20poly1305_ietf_encrypt(cipherText, &cipherTextLength, (const unsigned char*)data.data, data.size, nullptr, 0, nullptr, nonce, key) < 0)
throw EncryptionException("Failed to encrypt data");
}