-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto.h
35 lines (28 loc) · 982 Bytes
/
crypto.h
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
#ifndef __CRYPTO_H__
#define __CRYPTO_H__
#include <string>
#include <vector>
#include "status.h"
namespace ette {
enum class CryptoAlgorithm { kDefaultNone, kAES256CBC };
struct CryptoState {
std::string raw_key;
std::string hashed_key;
std::string plaintext;
std::string ciphertext;
std::vector<unsigned char> iv;
unsigned long ciphertext_size;
uint64_t plaintext_size;
CryptoAlgorithm algorithm;
ette::Status<void> status;
};
CryptoState Encrypt(const std::string& plaintext, const std::string& key,
const std::vector<unsigned char>& iv,
CryptoAlgorithm algorithm);
CryptoState Decrypt(std::string ciphertext, std::string raw_key,
CryptoAlgorithm algorithm);
std::vector<unsigned char> GenerateRandomAsciiByteVector();
bool IsKeyCorrect(const std::string& key, const std::string& path,
CryptoAlgorithm algorithm);
} // namespace ette
#endif // __CRYPTO_H__