31 for (i = 0; i < 8; i++) {
32 s->
slice[i] |= (
byte & 1) << (r * 4 +
c);
40 for (
c = 0;
c < 4;
c++) {
42 for (r = 0; r < 4; r++) {
51 for (
c = 0;
c < 4;
c++) {
53 for (r = 0; r < 4; r++) {
56 for (
b = 0;
b < 8;
b++) {
57 v |= ((s->
slice[
b] >> (r * 4 +
c)) & 1) <<
b;
75 uint16_t T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
77 uint16_t T17,
T18,
T19,
T20,
T21,
T22,
T23,
T24,
T25,
T26,
T27,
D;
78 uint16_t M1,
M6,
M11,
M13,
M15,
M20,
M21,
M22,
M23,
M25,
M37,
M38,
M39,
M40;
79 uint16_t M41,
M42,
M43,
M44,
M45,
M46,
M47,
M48,
M49,
M50,
M51,
M52,
M53,
267#define BIT_RANGE(from, to) (((1 << ((to) - (from))) - 1) << (from))
269#define BIT_RANGE_LEFT(x, from, to, shift) \
270 (((x)&BIT_RANGE((from), (to))) << (shift))
271#define BIT_RANGE_RIGHT(x, from, to, shift) \
272 (((x)&BIT_RANGE((from), (to))) >> (shift))
276 for (i = 0; i < 8; i++) {
288 for (i = 0; i < 8; i++) {
298#define ROT(x, b) (((x) >> ((b)*4)) | ((x) << ((4 - (b)) * 4)))
369 for (
b = 0;
b < 8;
b++) {
377 for (
b = 0;
b < 8;
b++) {
378 s->
slice[
b] = (
a->slice[
b] >>
c) & 0x1111;
386 for (
b = 0;
b < 8;
b++) {
388 ((s->
slice[
b] ^= ((
a->slice[
b] >>
c2) & 0x1111)) & 0x1111) <<
c1;
395 for (
b = 0;
b < 8;
b++) {
434 for (i = 0; i <
nrounds + 1; i++) {
436 for (
b = 0;
b < 8;
b++) {
445 for (r = 0; r < 4; r++) {
476 for (round = 1; round <
nrounds; round++) {
504 for (round = 1; round <
nrounds; round++) {
void AES192_decrypt(const AES192_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
void AES128_decrypt(const AES128_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
static void SaveBytes(uint8_t *data16, const AES_state *s)
Convert 8 sliced integers into 16 bytes of data.
static void LoadByte(AES_state *s, uint8_t byte, int r, int c)
Convert a byte to sliced form, storing it corresponding to given row and column in s.
void AES256_decrypt(const AES256_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
static void KeySetupColumnMix(AES_state *s, AES_state *r, const AES_state *a, int c1, int c2)
column_c1(r) |= (column_0(s) ^= column_c2(a))
void AES128_init(AES128_ctx *ctx, const uint8_t *key16)
static void LoadBytes(AES_state *s, const uint8_t *data16)
Load 16 bytes of data into 8 sliced integers.
static void InvShiftRows(AES_state *s)
static void SubBytes(AES_state *s, int inv)
static void AES_setup(AES_state *rounds, const uint8_t *key, int nkeywords, int nrounds)
Expand the cipher key into the key schedule.
#define BIT_RANGE_RIGHT(x, from, to, shift)
void AES256_encrypt(const AES256_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
void AES192_encrypt(const AES192_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
static void AES_encrypt(const AES_state *rounds, int nrounds, uint8_t *cipher16, const uint8_t *plain16)
static void KeySetupTransform(AES_state *s, const AES_state *r)
Rotate the rows in s one position upwards, and xor in r.
void AES256_init(AES256_ctx *ctx, const uint8_t *key32)
static void AddRoundKey(AES_state *s, const AES_state *round)
void AES128_encrypt(const AES128_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
static void AES_decrypt(const AES_state *rounds, int nrounds, uint8_t *plain16, const uint8_t *cipher16)
static void ShiftRows(AES_state *s)
static void MixColumns(AES_state *s, int inv)
void AES192_init(AES192_ctx *ctx, const uint8_t *key24)
static void GetOneColumn(AES_state *s, const AES_state *a, int c)
column_0(s) = column_c(a)
static void MultX(AES_state *s)
#define BIT_RANGE(from, to)
#define BIT_RANGE_LEFT(x, from, to, shift)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...