From 7f19b686cc7b47346ba8bab89bb34188f366db10 Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Wed, 16 May 2018 09:47:31 +0200 Subject: Store node encryption key with user data, fix encryption bug when using additional data --- src/Encryption.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Encryption.cpp') 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"); } -- cgit v1.2.3