FFmpeg
Data Structures | Macros | Functions
aes_ctr.c File Reference
#include "common.h"
#include "aes_ctr.h"
#include "aes.h"
#include "aes_internal.h"
#include "random_seed.h"

Go to the source code of this file.

Data Structures

struct  AVAESCTR
 

Macros

#define AES_BLOCK_SIZE   (16)
 

Functions

struct AVAESCTRav_aes_ctr_alloc (void)
 Allocate an AVAESCTR context. More...
 
void av_aes_ctr_set_iv (struct AVAESCTR *a, const uint8_t *iv)
 Forcefully change the 8-byte iv. More...
 
void av_aes_ctr_set_full_iv (struct AVAESCTR *a, const uint8_t *iv)
 Forcefully change the "full" 16-byte iv, including the counter. More...
 
const uint8_t * av_aes_ctr_get_iv (struct AVAESCTR *a)
 Get the current iv. More...
 
void av_aes_ctr_set_random_iv (struct AVAESCTR *a)
 Generate a random iv. More...
 
int av_aes_ctr_init (struct AVAESCTR *a, const uint8_t *key)
 Initialize an AVAESCTR context. More...
 
void av_aes_ctr_free (struct AVAESCTR *a)
 Release an AVAESCTR context. More...
 
static void av_aes_ctr_increment_be64 (uint8_t *counter)
 
void av_aes_ctr_increment_iv (struct AVAESCTR *a)
 Increment the top 64 bit of the iv (performed after each frame) More...
 
void av_aes_ctr_crypt (struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
 Process a buffer using a previously initialized context. More...
 

Macro Definition Documentation

◆ AES_BLOCK_SIZE

#define AES_BLOCK_SIZE   (16)

Definition at line 28 of file aes_ctr.c.

Function Documentation

◆ av_aes_ctr_alloc()

struct AVAESCTR* av_aes_ctr_alloc ( void  )

Allocate an AVAESCTR context.

Definition at line 37 of file aes_ctr.c.

Referenced by cenc_scheme_decrypt(), cens_scheme_decrypt(), ff_mov_cenc_init(), and main().

◆ av_aes_ctr_set_iv()

void av_aes_ctr_set_iv ( struct AVAESCTR a,
const uint8_t *  iv 
)

Forcefully change the 8-byte iv.

Definition at line 42 of file aes_ctr.c.

Referenced by av_aes_ctr_set_random_iv().

◆ av_aes_ctr_set_full_iv()

void av_aes_ctr_set_full_iv ( struct AVAESCTR a,
const uint8_t *  iv 
)

Forcefully change the "full" 16-byte iv, including the counter.

Definition at line 49 of file aes_ctr.c.

Referenced by cenc_scheme_decrypt(), cens_scheme_decrypt(), and main().

◆ av_aes_ctr_get_iv()

const uint8_t* av_aes_ctr_get_iv ( struct AVAESCTR a)

Get the current iv.

Definition at line 55 of file aes_ctr.c.

Referenced by main(), and mov_cenc_start_packet().

◆ av_aes_ctr_set_random_iv()

void av_aes_ctr_set_random_iv ( struct AVAESCTR a)

Generate a random iv.

Definition at line 60 of file aes_ctr.c.

Referenced by ff_mov_cenc_init(), and main().

◆ av_aes_ctr_init()

int av_aes_ctr_init ( struct AVAESCTR a,
const uint8_t *  key 
)

Initialize an AVAESCTR context.

Parameters
keyencryption key, must have a length of AES_CTR_KEY_SIZE

Definition at line 70 of file aes_ctr.c.

Referenced by cenc_scheme_decrypt(), cens_scheme_decrypt(), ff_mov_cenc_init(), and main().

◆ av_aes_ctr_free()

void av_aes_ctr_free ( struct AVAESCTR a)

Release an AVAESCTR context.

Definition at line 80 of file aes_ctr.c.

Referenced by ff_mov_cenc_free(), main(), and mov_read_close().

◆ av_aes_ctr_increment_be64()

static void av_aes_ctr_increment_be64 ( uint8_t *  counter)
static

Definition at line 85 of file aes_ctr.c.

Referenced by av_aes_ctr_crypt(), and av_aes_ctr_increment_iv().

◆ av_aes_ctr_increment_iv()

void av_aes_ctr_increment_iv ( struct AVAESCTR a)

Increment the top 64 bit of the iv (performed after each frame)

Definition at line 97 of file aes_ctr.c.

Referenced by mov_cenc_end_packet().

◆ av_aes_ctr_crypt()

void av_aes_ctr_crypt ( struct AVAESCTR a,
uint8_t *  dst,
const uint8_t *  src,
int  size 
)

Process a buffer using a previously initialized context.

Parameters
dstdestination array, can be equal to src
srcsource array, can be equal to dst
sizethe size of src and dst

Definition at line 104 of file aes_ctr.c.

Referenced by cenc_scheme_decrypt(), cens_scheme_decrypt(), main(), and mov_cenc_write_encrypted().