diff options
Diffstat (limited to 'src/crypt/cryptclassevp.h')
| -rw-r--r-- | src/crypt/cryptclassevp.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/crypt/cryptclassevp.h b/src/crypt/cryptclassevp.h new file mode 100644 index 0000000..8e9c66c --- /dev/null +++ b/src/crypt/cryptclassevp.h @@ -0,0 +1,48 @@ +#ifndef CRYPTCLASSEVP_H +#define CRYPTCLASSEVP_H + +#include "cryptclassbase.h" + +#include <openssl/evp.h> +#include <openssl/err.h> +#include <stdexcept> + +/** +* @author Walter Roth, 2015 +* @brief The CryptClassEvp is a class for symmetric cryptography using OpenSSL's EVP API. +* Subclasses must overwrite the algorithm function to specify the algorithm to be used. +* The implementation of algorithm in this class returns a NULL-Cipher object (no encryption). +* This is quite useful for debugging. +* +*/ +class CryptClassEvp : public CryptClassBase +{ +public: + CryptClassEvp(); + virtual ~CryptClassEvp(); + + /** + * @brief setAlgorithm Overwrite this function to specify the algorithm to be used. + * @param cipher The cipher object e.g. EVP_bf_cbc() for Blowfish in CBC mode. + */ + virtual const EVP_CIPHER *algorithm() = 0; + + /** + * @brief encrypt Setup context and key and encrypt m_clearText into m_cryptText. + */ + void encrypt(); + + /** + * @brief encrypt Setup context and key and decrypt m_cryptText into m_clearText. + */ + void decrypt(); + + /** + * @brief handleOpenSslError Calls ERR_get_error and sends debug output to stderr. + * @param file The __FILE__ makro + * @param line The __LINE__ makro + * @return + */ + void handleOpenSslError(); +}; +#endif // CRYPTCLASSEVP_H |
