18 memset(&
ctx, 0,
sizeof(
ctx));
22 const uint8_t plaintext[16])
const {
31 memset(&
ctx, 0,
sizeof(
ctx));
35 const uint8_t ciphertext[16])
const {
44 memset(&
ctx, 0,
sizeof(
ctx));
48 const uint8_t plaintext[16])
const {
57 memset(&
ctx, 0,
sizeof(
ctx));
61 const uint8_t ciphertext[16])
const {
67 const uint8_t *data,
int size,
bool pad, uint8_t *out) {
72 if (!data || !size || !out) {
76 if (!pad && padsize != 0) {
87 enc.Encrypt(out + written, mixed);
94 for (
int i = 0; i != padsize; i++) {
100 enc.Encrypt(out + written, mixed);
108 const uint8_t *data,
int size,
bool pad, uint8_t *out) {
111 const uint8_t *prev = iv;
113 if (!data || !size || !out) {
122 while (written != size) {
123 dec.Decrypt(out, data + written);
127 prev = data + written;
135 uint8_t padsize = *--out;
143 fail |= ((i >
AES_BLOCKSIZE - padsize) & (*out-- != padsize));
148 return written * !fail;
154 : enc(key), pad(padIn) {
159 uint8_t *out)
const {
164 memset(
iv, 0,
sizeof(
iv));
170 : dec(key), pad(padIn) {
175 uint8_t *out)
const {
180 memset(
iv, 0,
sizeof(
iv));
186 : enc(key), pad(padIn) {
195 uint8_t *out)
const {
202 : dec(key), pad(padIn) {
211 uint8_t *out)
const {
static int CBCDecrypt(const T &dec, const uint8_t iv[AES_BLOCKSIZE], const uint8_t *data, int size, bool pad, uint8_t *out)
static int CBCEncrypt(const T &enc, const uint8_t iv[AES_BLOCKSIZE], const uint8_t *data, int size, bool pad, uint8_t *out)
static const int AES128_KEYSIZE
static const int AES256_KEYSIZE
static const int AES_BLOCKSIZE
uint8_t iv[AES_BLOCKSIZE]
int Decrypt(const uint8_t *data, int size, uint8_t *out) const
AES128CBCDecrypt(const uint8_t key[AES128_KEYSIZE], const uint8_t ivIn[AES_BLOCKSIZE], bool padIn)
int Encrypt(const uint8_t *data, int size, uint8_t *out) const
AES128CBCEncrypt(const uint8_t key[AES128_KEYSIZE], const uint8_t ivIn[AES_BLOCKSIZE], bool padIn)
uint8_t iv[AES_BLOCKSIZE]
AES128Decrypt(const uint8_t key[16])
void Decrypt(uint8_t plaintext[16], const uint8_t ciphertext[16]) const
AES128Encrypt(const uint8_t key[16])
void Encrypt(uint8_t ciphertext[16], const uint8_t plaintext[16]) const
AES256CBCDecrypt(const uint8_t key[AES256_KEYSIZE], const uint8_t ivIn[AES_BLOCKSIZE], bool padIn)
uint8_t iv[AES_BLOCKSIZE]
int Decrypt(const uint8_t *data, int size, uint8_t *out) const
uint8_t iv[AES_BLOCKSIZE]
AES256CBCEncrypt(const uint8_t key[AES256_KEYSIZE], const uint8_t ivIn[AES_BLOCKSIZE], bool padIn)
int Encrypt(const uint8_t *data, int size, uint8_t *out) const
AES256Decrypt(const uint8_t key[32])
void Decrypt(uint8_t plaintext[16], const uint8_t ciphertext[16]) const
void Encrypt(uint8_t ciphertext[16], const uint8_t plaintext[16]) const
AES256Encrypt(const uint8_t key[32])
void AES128_decrypt(const AES128_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
void AES256_decrypt(const AES256_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
void AES128_init(AES128_ctx *ctx, const uint8_t *key16)
void AES256_encrypt(const AES256_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
void AES256_init(AES256_ctx *ctx, const uint8_t *key32)
void AES128_encrypt(const AES128_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)