Bitcoin ABC 0.30.5
P2P Digital Currency
Macros | Functions
ctaes.c File Reference
#include "ctaes.h"
Include dependency graph for ctaes.c:
This graph shows which files directly or indirectly include this file:

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, uint8_t 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 uint8_t *data16)
 Load 16 bytes of data into 8 sliced integers. More...
 
static void SaveBytes (uint8_t *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, uint8_t *cipher16, const uint8_t *plain16)
 
static void AES_decrypt (const AES_state *rounds, int nrounds, uint8_t *plain16, const uint8_t *cipher16)
 
void AES128_init (AES128_ctx *ctx, const uint8_t *key16)
 
void AES128_encrypt (const AES128_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
 
void AES128_decrypt (const AES128_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
 
void AES192_init (AES192_ctx *ctx, const uint8_t *key24)
 
void AES192_encrypt (const AES192_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
 
void AES192_decrypt (const AES192_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
 
void AES256_init (AES256_ctx *ctx, const uint8_t *key32)
 
void AES256_encrypt (const AES256_ctx *ctx, size_t blocks, uint8_t *cipher16, const uint8_t *plain16)
 
void AES256_decrypt (const AES256_ctx *ctx, size_t blocks, uint8_t *plain16, const uint8_t *cipher16)
 

Macro Definition Documentation

◆ BIT_RANGE

#define BIT_RANGE (   from,
  to 
)    (((1 << ((to) - (from))) - 1) << (from))

Definition at line 267 of file ctaes.c.

◆ BIT_RANGE_LEFT

#define BIT_RANGE_LEFT (   x,
  from,
  to,
  shift 
)     (((x)&BIT_RANGE((from), (to))) << (shift))

Definition at line 269 of file ctaes.c.

◆ BIT_RANGE_RIGHT

#define BIT_RANGE_RIGHT (   x,
  from,
  to,
  shift 
)     (((x)&BIT_RANGE((from), (to))) >> (shift))

Definition at line 271 of file ctaes.c.

◆ ROT

#define ROT (   x,
 
)    (((x) >> ((b)*4)) | ((x) << ((4 - (b)) * 4)))

Definition at line 298 of file ctaes.c.

Function Documentation

◆ AddRoundKey()

static void AddRoundKey ( AES_state s,
const AES_state round 
)
static

Definition at line 367 of file ctaes.c.

Here is the caller graph for this function:

◆ AES128_decrypt()

void AES128_decrypt ( const AES128_ctx ctx,
size_t  blocks,
uint8_t *  plain16,
const uint8_t *  cipher16 
)

Definition at line 531 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES128_encrypt()

void AES128_encrypt ( const AES128_ctx ctx,
size_t  blocks,
uint8_t *  cipher16,
const uint8_t *  plain16 
)

Definition at line 522 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES128_init()

void AES128_init ( AES128_ctx ctx,
const uint8_t *  key16 
)

Definition at line 518 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES192_decrypt()

void AES192_decrypt ( const AES192_ctx ctx,
size_t  blocks,
uint8_t *  plain16,
const uint8_t *  cipher16 
)

Definition at line 553 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES192_encrypt()

void AES192_encrypt ( const AES192_ctx ctx,
size_t  blocks,
uint8_t *  cipher16,
const uint8_t *  plain16 
)

Definition at line 544 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES192_init()

void AES192_init ( AES192_ctx ctx,
const uint8_t *  key24 
)

Definition at line 540 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES256_decrypt()

void AES256_decrypt ( const AES256_ctx ctx,
size_t  blocks,
uint8_t *  plain16,
const uint8_t *  cipher16 
)

Definition at line 575 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES256_encrypt()

void AES256_encrypt ( const AES256_ctx ctx,
size_t  blocks,
uint8_t *  cipher16,
const uint8_t *  plain16 
)

Definition at line 566 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES256_init()

void AES256_init ( AES256_ctx ctx,
const uint8_t *  key32 
)

Definition at line 562 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES_decrypt()

static void AES_decrypt ( const AES_state rounds,
int  nrounds,
uint8_t *  plain16,
const uint8_t *  cipher16 
)
static

Definition at line 490 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES_encrypt()

static void AES_encrypt ( const AES_state rounds,
int  nrounds,
uint8_t *  cipher16,
const uint8_t *  plain16 
)
static

Definition at line 468 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AES_setup()

static void AES_setup ( AES_state rounds,
const uint8_t *  key,
int  nkeywords,
int  nrounds 
)
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 423 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOneColumn()

static void GetOneColumn ( AES_state s,
const AES_state a,
int  c 
)
static

column_0(s) = column_c(a)

Definition at line 375 of file ctaes.c.

Here is the caller graph for this function:

◆ InvShiftRows()

static void InvShiftRows ( AES_state s)
static

Definition at line 286 of file ctaes.c.

Here is the caller graph for this function:

◆ KeySetupColumnMix()

static void KeySetupColumnMix ( AES_state s,
AES_state r,
const AES_state a,
int  c1,
int  c2 
)
static

column_c1(r) |= (column_0(s) ^= column_c2(a))

Definition at line 383 of file ctaes.c.

Here is the caller graph for this function:

◆ KeySetupTransform()

static void KeySetupTransform ( AES_state s,
const AES_state r 
)
static

Rotate the rows in s one position upwards, and xor in r.

Definition at line 393 of file ctaes.c.

Here is the caller graph for this function:

◆ LoadByte()

static void LoadByte ( AES_state s,
uint8_t  byte,
int  r,
int  c 
)
static

Convert a byte to sliced form, storing it corresponding to given row and column in s.

Definition at line 29 of file ctaes.c.

Here is the caller graph for this function:

◆ LoadBytes()

static void LoadBytes ( AES_state s,
const uint8_t *  data16 
)
static

Load 16 bytes of data into 8 sliced integers.

Definition at line 38 of file ctaes.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MixColumns()

static void MixColumns ( AES_state s,
int  inv 
)
static

Definition at line 300 of file ctaes.c.

Here is the caller graph for this function:

◆ MultX()

static void MultX ( AES_state s)
static

Definition at line 402 of file ctaes.c.

Here is the caller graph for this function:

◆ SaveBytes()

static void SaveBytes ( uint8_t *  data16,
const AES_state s 
)
static

Convert 8 sliced integers into 16 bytes of data.

Definition at line 49 of file ctaes.c.

Here is the caller graph for this function:

◆ ShiftRows()

static void ShiftRows ( AES_state s)
static

Definition at line 274 of file ctaes.c.

Here is the caller graph for this function:

◆ SubBytes()

static void SubBytes ( AES_state s,
int  inv 
)
static

Definition at line 68 of file ctaes.c.

Here is the caller graph for this function: