Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include "ctaes.h"
Go to the source code of this file.
Macros | |
#define | BIT_RANGE(from, to) (((1 << ((to) - (from))) - 1) << (from)) |
#define | BIT_RANGE_LEFT(x, from, to, shift) (((x) & BIT_RANGE((from), (to))) << (shift)) |
#define | BIT_RANGE_RIGHT(x, from, to, shift) (((x) & BIT_RANGE((from), (to))) >> (shift)) |
#define | ROT(x, b) (((x) >> ((b) * 4)) | ((x) << ((4-(b)) * 4))) |
Functions | |
static void | LoadByte (AES_state *s, unsigned char byte, int r, int c) |
Convert a byte to sliced form, storing it corresponding to given row and column in s. More... | |
static void | LoadBytes (AES_state *s, const unsigned char *data16) |
Load 16 bytes of data into 8 sliced integers. More... | |
static void | SaveBytes (unsigned char *data16, const AES_state *s) |
Convert 8 sliced integers into 16 bytes of data. More... | |
static void | SubBytes (AES_state *s, int inv) |
static void | ShiftRows (AES_state *s) |
static void | InvShiftRows (AES_state *s) |
static void | MixColumns (AES_state *s, int inv) |
static void | AddRoundKey (AES_state *s, const AES_state *round) |
static void | GetOneColumn (AES_state *s, const AES_state *a, int c) |
column_0(s) = column_c(a) More... | |
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)) More... | |
static void | KeySetupTransform (AES_state *s, const AES_state *r) |
Rotate the rows in s one position upwards, and xor in r. More... | |
static void | MultX (AES_state *s) |
static void | AES_setup (AES_state *rounds, const uint8_t *key, int nkeywords, int nrounds) |
Expand the cipher key into the key schedule. More... | |
static void | AES_encrypt (const AES_state *rounds, int nrounds, unsigned char *cipher16, const unsigned char *plain16) |
static void | AES_decrypt (const AES_state *rounds, int nrounds, unsigned char *plain16, const unsigned char *cipher16) |
void | AES128_init (AES128_ctx *ctx, const unsigned char *key16) |
void | AES128_encrypt (const AES128_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16) |
void | AES128_decrypt (const AES128_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16) |
void | AES192_init (AES192_ctx *ctx, const unsigned char *key24) |
void | AES192_encrypt (const AES192_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16) |
void | AES192_decrypt (const AES192_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16) |
void | AES256_init (AES256_ctx *ctx, const unsigned char *key32) |
void | AES256_encrypt (const AES256_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16) |
void | AES256_decrypt (const AES256_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16) |
Macro Definition Documentation
◆ BIT_RANGE
#define BIT_RANGE | ( | from, | |
to | |||
) | (((1 << ((to) - (from))) - 1) << (from)) |
Definition at line 258 of file ctaes.c.
Referenced by InvShiftRows(), and ShiftRows().
◆ BIT_RANGE_LEFT
#define BIT_RANGE_LEFT | ( | x, | |
from, | |||
to, | |||
shift | |||
) | (((x) & BIT_RANGE((from), (to))) << (shift)) |
Definition at line 260 of file ctaes.c.
Referenced by InvShiftRows(), and ShiftRows().
◆ BIT_RANGE_RIGHT
#define BIT_RANGE_RIGHT | ( | x, | |
from, | |||
to, | |||
shift | |||
) | (((x) & BIT_RANGE((from), (to))) >> (shift)) |
Definition at line 261 of file ctaes.c.
Referenced by InvShiftRows(), and ShiftRows().
◆ ROT
#define ROT | ( | x, | |
b | |||
) | (((x) >> ((b) * 4)) | ((x) << ((4-(b)) * 4))) |
Definition at line 287 of file ctaes.c.
Referenced by MixColumns().
Function Documentation
◆ AddRoundKey()
Definition at line 354 of file ctaes.c.
References AES_state::slice.
Referenced by AES_decrypt(), and AES_encrypt().
◆ AES128_decrypt()
void AES128_decrypt | ( | const AES128_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | plain16, | ||
const unsigned char * | cipher16 | ||
) |
Definition at line 509 of file ctaes.c.
References AES_decrypt(), and ctx.
Referenced by bench_AES128_decrypt(), AES128Decrypt::Decrypt(), and main().
◆ AES128_encrypt()
void AES128_encrypt | ( | const AES128_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | cipher16, | ||
const unsigned char * | plain16 | ||
) |
Definition at line 501 of file ctaes.c.
References AES_encrypt(), and ctx.
Referenced by bench_AES128_encrypt(), AES128Encrypt::Encrypt(), and main().
◆ AES128_init()
void AES128_init | ( | AES128_ctx * | ctx, |
const unsigned char * | key16 | ||
) |
Definition at line 497 of file ctaes.c.
References AES_setup(), and ctx.
Referenced by AES128Decrypt::AES128Decrypt(), AES128Encrypt::AES128Encrypt(), bench_AES128_encrypt_setup(), bench_AES128_init(), and main().
◆ AES192_decrypt()
void AES192_decrypt | ( | const AES192_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | plain16, | ||
const unsigned char * | cipher16 | ||
) |
Definition at line 530 of file ctaes.c.
References AES_decrypt(), and ctx.
Referenced by bench_AES192_decrypt(), and main().
◆ AES192_encrypt()
void AES192_encrypt | ( | const AES192_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | cipher16, | ||
const unsigned char * | plain16 | ||
) |
Definition at line 521 of file ctaes.c.
References AES_encrypt(), and ctx.
Referenced by bench_AES192_encrypt(), and main().
◆ AES192_init()
void AES192_init | ( | AES192_ctx * | ctx, |
const unsigned char * | key24 | ||
) |
Definition at line 517 of file ctaes.c.
References AES_setup(), and ctx.
Referenced by bench_AES192_encrypt_setup(), bench_AES192_init(), and main().
◆ AES256_decrypt()
void AES256_decrypt | ( | const AES256_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | plain16, | ||
const unsigned char * | cipher16 | ||
) |
Definition at line 550 of file ctaes.c.
References AES_decrypt(), and ctx.
Referenced by bench_AES256_decrypt(), AES256Decrypt::Decrypt(), and main().
◆ AES256_encrypt()
void AES256_encrypt | ( | const AES256_ctx * | ctx, |
size_t | blocks, | ||
unsigned char * | cipher16, | ||
const unsigned char * | plain16 | ||
) |
Definition at line 542 of file ctaes.c.
References AES_encrypt(), and ctx.
Referenced by bench_AES256_encrypt(), AES256Encrypt::Encrypt(), and main().
◆ AES256_init()
void AES256_init | ( | AES256_ctx * | ctx, |
const unsigned char * | key32 | ||
) |
Definition at line 538 of file ctaes.c.
References AES_setup(), and ctx.
Referenced by AES256Decrypt::AES256Decrypt(), AES256Encrypt::AES256Encrypt(), bench_AES256_encrypt_setup(), bench_AES256_init(), and main().
◆ AES_decrypt()
|
static |
Definition at line 470 of file ctaes.c.
References AddRoundKey(), InvShiftRows(), LoadBytes(), MixColumns(), SaveBytes(), and SubBytes().
Referenced by AES128_decrypt(), AES192_decrypt(), and AES256_decrypt().
◆ AES_encrypt()
|
static |
Definition at line 449 of file ctaes.c.
References AddRoundKey(), LoadBytes(), MixColumns(), SaveBytes(), ShiftRows(), and SubBytes().
Referenced by AES128_encrypt(), AES192_encrypt(), and AES256_encrypt().
◆ AES_setup()
|
static |
Expand the cipher key into the key schedule.
state must be a pointer to an array of size nrounds + 1. key must be a pointer to 4 * nkeywords bytes.
AES128 uses nkeywords = 4, nrounds = 10 AES192 uses nkeywords = 6, nrounds = 12 AES256 uses nkeywords = 8, nrounds = 14
Definition at line 407 of file ctaes.c.
References GetOneColumn(), KeySetupColumnMix(), KeySetupTransform(), LoadByte(), MultX(), AES_state::slice, and SubBytes().
Referenced by AES128_init(), AES192_init(), and AES256_init().
◆ GetOneColumn()
column_0(s) = column_c(a)
Definition at line 362 of file ctaes.c.
References AES_state::slice.
Referenced by AES_setup().
◆ InvShiftRows()
|
static |
Definition at line 275 of file ctaes.c.
References BIT_RANGE, BIT_RANGE_LEFT, BIT_RANGE_RIGHT, and AES_state::slice.
Referenced by AES_decrypt().
◆ KeySetupColumnMix()
|
static |
column_c1(r) |= (column_0(s) ^= column_c2(a))
Definition at line 370 of file ctaes.c.
References AES_state::slice.
Referenced by AES_setup().
◆ KeySetupTransform()
Rotate the rows in s one position upwards, and xor in r.
Definition at line 378 of file ctaes.c.
References AES_state::slice.
Referenced by AES_setup().
◆ LoadByte()
|
static |
Convert a byte to sliced form, storing it corresponding to given row and column in s.
Definition at line 25 of file ctaes.c.
References AES_state::slice.
Referenced by AES_setup(), and LoadBytes().
◆ LoadBytes()
|
static |
Load 16 bytes of data into 8 sliced integers.
Definition at line 34 of file ctaes.c.
References LoadByte().
Referenced by AES_decrypt(), and AES_encrypt().
◆ MixColumns()
|
static |
Definition at line 289 of file ctaes.c.
References ROT, and AES_state::slice.
Referenced by AES_decrypt(), and AES_encrypt().
◆ MultX()
|
static |
◆ SaveBytes()
|
static |
Convert 8 sliced integers into 16 bytes of data.
Definition at line 45 of file ctaes.c.
References AES_state::slice.
Referenced by AES_decrypt(), and AES_encrypt().
◆ ShiftRows()
|
static |
Definition at line 263 of file ctaes.c.
References BIT_RANGE, BIT_RANGE_LEFT, BIT_RANGE_RIGHT, and AES_state::slice.
Referenced by AES_encrypt().