aes-internal-enc.c File Reference
`#include "includes.h"`
`#include "common.h"`
`#include "crypto.h"`
`#include "aes_i.h"`

## Macros

#define | ROUND(i, d, s)

## Functions

static void | rijndaelEncrypt (const u32 rk[], const u8 pt[16], u8 ct[16])
void * | aes_encrypt_init (const u8 *key, size_t len)
void | aes_encrypt (void *ctx, const u8 *plain, u8 *crypt)
void | aes_encrypt_deinit (void *ctx)

## Detailed Description

AES (Rijndael) cipher - encrypt.

Modifications to public domain implementation:

- support only 128-bit keys
- cleanup
- use C pre-processor to make it easier to change S table access
- added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at cost of reduced throughput (quite small difference on Pentium 4, 10-25% when using -O1 or -O2 optimization)

## Macro Definition Documentation

## ROUND

#define ROUND | ( |  | i,
|  |  | d,
|  |  | s
| ) |  |

Value:
d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]

## Function Documentation

## aes_encrypt()

void aes_encrypt | ( | void * | ctx,
|  | const u8 * | plain,
|  | u8 * | crypt
| ) |  |

References rijndaelEncrypt().

Referenced by aes_128_encrypt_block().

## aes_encrypt_deinit()

void aes_encrypt_deinit | ( | void * | ctx | ) |

References AES_PRIV_SIZE, os_free, and os_memset.

Referenced by aes_128_encrypt_block().

## aes_encrypt_init()

void* aes_encrypt_init | ( | const u8 * | key,
|  | size_t | len
| ) |  |

References AES_PRIV_SIZE, len, os_malloc, and rijndaelKeySetupEnc().

Referenced by aes_128_encrypt_block().

## rijndaelEncrypt()

static void rijndaelEncrypt | ( | const u32 | rk[],
|  | const u8 | pt[16],
|  | u8 | ct[16]
| ) |  |

static

References GETU32, PUTU32, ROUND, s, t1, t2, t3, TE41, TE42, TE43, and TE44.

Referenced by aes_encrypt().

TE0
#define TE0(i)
Definition: aes_i.h:79
TE3
#define TE3(i)
Definition: aes_i.h:82
TE1
#define TE1(i)
Definition: aes_i.h:80
d
uint8_t d
Definition: gsm_04_08.h:717
TE2
#define TE2(i)
Definition: aes_i.h:81
s
uint8_t s
Definition: gsm_08_58.h:13