2020-11-12 12:00:50 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
2020-11-24 02:00:22 +01:00
|
|
|
#include <vector>
|
2020-11-12 12:00:50 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
namespace hex::prv {
|
|
|
|
class Provider;
|
|
|
|
}
|
2020-11-12 12:00:50 +01:00
|
|
|
|
2021-02-02 23:11:23 +01:00
|
|
|
namespace hex::crypt {
|
|
|
|
|
|
|
|
void initialize();
|
|
|
|
void exit();
|
2020-11-12 12:00:50 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
u16 crc8(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut);
|
|
|
|
u16 crc16(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut);
|
|
|
|
u32 crc32(prv::Provider *&data, u64 offset, size_t size, u32 polynomial, u32 init, u32 xorout, bool reflectIn, bool reflectOut);
|
2020-11-12 12:00:50 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
std::array<u8, 16> md5(prv::Provider *&data, u64 offset, size_t size);
|
|
|
|
std::array<u8, 20> sha1(prv::Provider *&data, u64 offset, size_t size);
|
|
|
|
std::array<u8, 28> sha224(prv::Provider *&data, u64 offset, size_t size);
|
|
|
|
std::array<u8, 32> sha256(prv::Provider *&data, u64 offset, size_t size);
|
|
|
|
std::array<u8, 48> sha384(prv::Provider *&data, u64 offset, size_t size);
|
|
|
|
std::array<u8, 64> sha512(prv::Provider *&data, u64 offset, size_t size);
|
2020-11-12 12:00:50 +01:00
|
|
|
|
2021-09-03 02:34:40 +02:00
|
|
|
std::array<u8, 16> md5(const std::vector<u8> &data);
|
|
|
|
std::array<u8, 20> sha1(const std::vector<u8> &data);
|
|
|
|
std::array<u8, 28> sha224(const std::vector<u8> &data);
|
|
|
|
std::array<u8, 32> sha256(const std::vector<u8> &data);
|
|
|
|
std::array<u8, 48> sha384(const std::vector<u8> &data);
|
|
|
|
std::array<u8, 64> sha512(const std::vector<u8> &data);
|
|
|
|
|
2020-11-24 02:00:22 +01:00
|
|
|
std::vector<u8> decode64(const std::vector<u8> &input);
|
|
|
|
std::vector<u8> encode64(const std::vector<u8> &input);
|
2021-09-03 02:34:40 +02:00
|
|
|
std::vector<u8> decode16(const std::string &input);
|
|
|
|
std::string encode16(const std::vector<u8> &input);
|
2021-02-03 11:54:41 +01:00
|
|
|
|
2021-02-04 00:21:53 +01:00
|
|
|
enum class AESMode : u8 {
|
2022-02-01 22:09:44 +01:00
|
|
|
ECB = 0,
|
|
|
|
CBC = 1,
|
2022-01-24 20:53:17 +01:00
|
|
|
CFB128 = 2,
|
2022-02-01 22:09:44 +01:00
|
|
|
CTR = 3,
|
|
|
|
GCM = 4,
|
|
|
|
CCM = 5,
|
|
|
|
OFB = 6,
|
|
|
|
XTS = 7
|
2021-02-04 00:21:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class KeyLength : u8 {
|
|
|
|
Key128Bits = 0,
|
|
|
|
Key192Bits = 1,
|
|
|
|
Key256Bits = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<u8> aesDecrypt(AESMode mode, KeyLength keyLength, const std::vector<u8> &key, std::array<u8, 8> nonce, std::array<u8, 8> iv, const std::vector<u8> &input);
|
2021-10-26 17:21:48 +02:00
|
|
|
}
|