diff options
Diffstat (limited to 'src/Encryption.cpp')
-rw-r--r-- | src/Encryption.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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; |