FFmpeg
Macros | Functions | Variables
aes.c File Reference
#include <string.h>
#include "config.h"
#include "aes.h"
#include "aes_internal.h"
#include "error.h"
#include "intreadwrite.h"
#include "macros.h"
#include "mem.h"

Go to the source code of this file.

Macros

#define ROT(x, s)   (((x) << (s)) | ((x) >> (32-(s))))
 

Functions

struct AVAESav_aes_alloc (void)
 Allocate an AVAES context. More...
 
static void addkey (av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key)
 
static void addkey_s (av_aes_block *dst, const uint8_t *src, const av_aes_block *round_key)
 
static void addkey_d (uint8_t *dst, const av_aes_block *src, const av_aes_block *round_key)
 
static void subshift (av_aes_block s0[2], int s, const uint8_t *box)
 
static int mix_core (uint32_t multbl[][256], int a, int b, int c, int d)
 
static void mix (av_aes_block state[2], uint32_t multbl[][256], int s1, int s3)
 
static void aes_crypt (AVAES *a, int s, const uint8_t *sbox, uint32_t multbl[][256])
 
static void aes_encrypt (AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int rounds)
 
static void aes_decrypt (AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int rounds)
 
void av_aes_crypt (AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
 Encrypt or decrypt a buffer using a previously initialized context. More...
 
static void init_multbl2 (uint32_t tbl[][256], const int c[4], const uint8_t *log8, const uint8_t *alog8, const uint8_t *sbox)
 
int av_aes_init (AVAES *a, const uint8_t *key, int key_bits, int decrypt)
 Initialize an AVAES context. More...
 

Variables

const int av_aes_size = sizeof(AVAES)
 
static const uint8_t rcon [10]
 
static uint8_t sbox [256]
 
static uint8_t inv_sbox [256]
 
static uint32_t enc_multbl [4][256]
 
static uint32_t dec_multbl [4][256]
 

Macro Definition Documentation

◆ ROT

#define ROT (   x,
  s 
)    (((x) << (s)) | ((x) >> (32-(s))))

Definition at line 57 of file aes.c.

Function Documentation

◆ addkey()

static void addkey ( av_aes_block dst,
const av_aes_block src,
const av_aes_block round_key 
)
inlinestatic

Definition at line 60 of file aes.c.

Referenced by aes_crypt().

◆ addkey_s()

static void addkey_s ( av_aes_block dst,
const uint8_t *  src,
const av_aes_block round_key 
)
inlinestatic

Definition at line 67 of file aes.c.

Referenced by aes_decrypt(), and aes_encrypt().

◆ addkey_d()

static void addkey_d ( uint8_t *  dst,
const av_aes_block src,
const av_aes_block round_key 
)
inlinestatic

Definition at line 74 of file aes.c.

Referenced by aes_decrypt(), and aes_encrypt().

◆ subshift()

static void subshift ( av_aes_block  s0[2],
int  s,
const uint8_t *  box 
)
static

Definition at line 81 of file aes.c.

Referenced by aes_crypt(), and av_aes_init().

◆ mix_core()

static int mix_core ( uint32_t  multbl[][256],
int  a,
int  b,
int  c,
int  d 
)
inlinestatic

Definition at line 104 of file aes.c.

Referenced by mix().

◆ mix()

static void mix ( av_aes_block  state[2],
uint32_t  multbl[][256],
int  s1,
int  s3 
)
inlinestatic

Definition at line 113 of file aes.c.

Referenced by aes_crypt(), and av_aes_init().

◆ aes_crypt()

static void aes_crypt ( AVAES a,
int  s,
const uint8_t *  sbox,
uint32_t  multbl[][256] 
)
inlinestatic

Definition at line 122 of file aes.c.

Referenced by aes_decrypt(), and aes_encrypt().

◆ aes_encrypt()

static void aes_encrypt ( AVAES a,
uint8_t *  dst,
const uint8_t *  src,
int  count,
uint8_t *  iv,
int  rounds 
)
static

Definition at line 135 of file aes.c.

Referenced by av_aes_init().

◆ aes_decrypt()

static void aes_decrypt ( AVAES a,
uint8_t *  dst,
const uint8_t *  src,
int  count,
uint8_t *  iv,
int  rounds 
)
static

Definition at line 151 of file aes.c.

Referenced by av_aes_init().

◆ init_multbl2()

static void init_multbl2 ( uint32_t  tbl[][256],
const int  c[4],
const uint8_t *  log8,
const uint8_t *  alog8,
const uint8_t *  sbox 
)
static

Definition at line 173 of file aes.c.

Referenced by av_aes_init().

Variable Documentation

◆ rcon

const uint8_t rcon[10]
static
Initial value:
= {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
}

Definition at line 40 of file aes.c.

Referenced by av_aes_init().

◆ sbox

uint8_t sbox[256]
static

Definition at line 44 of file aes.c.

Referenced by aes_crypt(), aes_encrypt(), av_aes_init(), and init_multbl2().

◆ inv_sbox

uint8_t inv_sbox[256]
static

Definition at line 45 of file aes.c.

Referenced by aes_decrypt(), and av_aes_init().

◆ enc_multbl

uint32_t enc_multbl[4][256]
static

Definition at line 50 of file aes.c.

Referenced by aes_encrypt(), and av_aes_init().

◆ dec_multbl

uint32_t dec_multbl[4][256]
static

Definition at line 51 of file aes.c.

Referenced by aes_decrypt(), and av_aes_init().