27 lines
558 B
C++
27 lines
558 B
C++
#ifndef CRYPTOGRAPHY_HPP
|
|
#define CRYPTOGRAPHY_HPP
|
|
|
|
#include <cstdint>
|
|
|
|
struct evp_cipher_ctx_st;
|
|
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
|
|
|
class Buffer;
|
|
|
|
class Cryptography
|
|
{
|
|
public:
|
|
Cryptography(const char *password, size_t size);
|
|
~Cryptography();
|
|
bool encrypt(Buffer *plain, Buffer *encrypted);
|
|
bool decrypt(Buffer *encrypted, Buffer *decrypted);
|
|
bool generate_key_and_iv_from_password(const char *password, size_t size);
|
|
|
|
private:
|
|
uint8_t key[32] = {0};
|
|
uint8_t iv[16] = {0};
|
|
EVP_CIPHER_CTX *ctx = nullptr;
|
|
bool handleErrors();
|
|
};
|
|
|
|
#endif |