Cryptography WIP

This commit is contained in:
Nikola Petrov
2023-08-13 01:28:01 +02:00
parent c41127839d
commit fdcdc1054b
9 changed files with 227 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
#pragma once
class Buffer
{
public:
unsigned char* buffer = nullptr;
size_t size = 0;
Buffer(size_t size)
{
this->size = size;
this->buffer = new unsigned char[size];
}
Buffer() {
size = 0;
buffer = nullptr;
}
~Buffer()
{
if (buffer) delete[] buffer;
}
};

View File

@@ -1,3 +0,0 @@
#pragma once
bool put_data_on_clipboard(const char* text);

View File

@@ -0,0 +1,23 @@
#pragma once
#include <cstdint>
struct evp_cipher_ctx_st;
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
class Cryptography
{
public:
Cryptography(const char* password);
~Cryptography();
int encrypt(uint8_t* input_buffer, int32_t input_buffer_size);
int decrypt(uint8_t* input_buffer);
private:
uint8_t key[32] = { 0 };
uint8_t iv[16] = { 0 };
EVP_CIPHER_CTX* ctx = nullptr;
bool generate_key_and_iv_from_password(const char* password);
void handleErrors();
};

View File

@@ -0,0 +1,4 @@
#pragma once
bool put_data_on_clipboard(const char* text);
std::string get_passwd();