aboutsummaryrefslogtreecommitdiff
path: root/src/Encryption.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Encryption.cpp')
-rw-r--r--src/Encryption.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Encryption.cpp b/src/Encryption.cpp
index 7f8700b..e67c719 100644
--- a/src/Encryption.cpp
+++ b/src/Encryption.cpp
@@ -12,14 +12,14 @@ namespace odhtdb
if(_key.data)
{
- if(_key.size != KEY_BYTE_SIZE)
+ if(_key.size != ENCRYPTION_KEY_BYTE_SIZE)
throw EncryptionException("Encryption key is wrong size");
memcpy(key, _key.data, _key.size);
}
else
crypto_aead_xchacha20poly1305_ietf_keygen(key);
- randombytes_buf(nonce, NONCE_BYTE_SIZE);
+ 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)
throw EncryptionException("Failed to encrypt data");
}
@@ -31,12 +31,12 @@ namespace odhtdb
DataView Encryption::getKey() const
{
- return DataView((void*)key, KEY_BYTE_SIZE);
+ return DataView((void*)key, ENCRYPTION_KEY_BYTE_SIZE);
}
DataView Encryption::getNonce() const
{
- return DataView((void*)nonce, NONCE_BYTE_SIZE);
+ return DataView((void*)nonce, ENCRYPTION_NONCE_BYTE_SIZE);
}
DataView Encryption::getCipherText() const
@@ -49,10 +49,10 @@ namespace odhtdb
decryptedText = new unsigned char[data.size];
decryptedTextLength = data.size;
- if(nonce.size < NONCE_BYTE_SIZE)
+ if(nonce.size < ENCRYPTION_NONCE_BYTE_SIZE)
throw DecryptionException("Nonce is not big enough");
- if(key.size < KEY_BYTE_SIZE)
+ if(key.size < ENCRYPTION_KEY_BYTE_SIZE)
throw DecryptionException("Key is not big enough");
if(crypto_aead_xchacha20poly1305_ietf_decrypt(decryptedText, &decryptedTextLength, nullptr, (const unsigned char*)data.data, data.size, nullptr, 0, (const unsigned char*)nonce.data, (const unsigned char*)key.data) < 0)