blob: 8e9c66c0621801aa9d428186793d957122522ecd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|