diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-13 06:26:06 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 5a8727e34b938b70623ca865273fd81c7604b461 (patch) | |
tree | a2921e90aa454072dc58fced36b508f67f5d1226 /include/Encryption.hpp | |
parent | 9ffc25c9d99fe86d4789108d1d8615ecb0388cc6 (diff) |
Expose include dir
Diffstat (limited to 'include/Encryption.hpp')
-rw-r--r-- | include/Encryption.hpp | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/include/Encryption.hpp b/include/Encryption.hpp deleted file mode 100644 index 4697b35..0000000 --- a/include/Encryption.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -/* - * Encrypts/decrypts data using xchacha20-poly1305 ietf - */ - -#include "DataView.hpp" -#include "utils.hpp" -#include <string> -#include <stdexcept> - -namespace odhtdb -{ - const int NONCE_BYTE_SIZE = 24; - const int KEY_BYTE_SIZE = 32; - - class EncryptionException : public std::runtime_error - { - public: - EncryptionException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - - class DecryptionException : public std::runtime_error - { - public: - DecryptionException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - - class Encryption - { - DISABLE_COPY(Encryption) - public: - // Throws EncryptionException on failure (or std::bad_alloc on failed memory allocation) - Encryption(const DataView &data, const DataView &additionalData = DataView(), const DataView &key = DataView()); - ~Encryption(); - - DataView getKey() const; - DataView getNonce() const; - DataView getCipherText() const; - private: - unsigned char key[KEY_BYTE_SIZE]; - unsigned char nonce[NONCE_BYTE_SIZE]; - unsigned char *cipherText; - unsigned long long cipherTextLength; - }; - - class Decryption - { - DISABLE_COPY(Decryption) - public: - Decryption() : decryptedText(nullptr), decryptedTextLength(0) {} - - // Throws DecryptionException on failure - Decryption(const DataView &data, const DataView &nonce, const DataView &key); - Decryption(Decryption &&other); - Decryption& operator=(Decryption &&other); - ~Decryption(); - - DataView getDecryptedText() const; - private: - unsigned char *decryptedText; - unsigned long long decryptedTextLength; - }; -} |