Go to the documentation of this file.
31 #define AES_BLOCK_SIZE (16)
54 memcpy(
a->counter, iv,
sizeof(
a->counter));
77 memset(
a->counter, 0,
sizeof(
a->counter));
109 const uint8_t* src_end =
src + count;
110 const uint8_t* cur_end_pos;
111 uint8_t* encrypted_counter_pos;
113 while (
src < src_end) {
114 if (
a->block_offset == 0) {
120 encrypted_counter_pos =
a->encrypted_counter +
a->block_offset;
122 cur_end_pos =
FFMIN(cur_end_pos, src_end);
124 a->block_offset += cur_end_pos -
src;
127 while (
src < cur_end_pos) {
128 *
dst++ = *
src++ ^ *encrypted_counter_pos++;
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
Generate a random iv.
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
const uint8_t * av_aes_ctr_get_iv(struct AVAESCTR *a)
Get the current iv.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
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.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the 8-byte 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.
uint8_t encrypted_counter[AES_BLOCK_SIZE]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
uint8_t counter[AES_BLOCK_SIZE]
void av_aes_ctr_increment_iv(struct AVAESCTR *a)
Increment the top 64 bit of the iv (performed after each frame)
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.
static void av_aes_ctr_increment_be64(uint8_t *counter)