Go to the documentation of this file.
28 #define AES_BLOCK_SIZE (16)
51 memcpy(
a->counter, iv,
sizeof(
a->counter));
74 memset(
a->counter, 0,
sizeof(
a->counter));
106 const uint8_t* src_end =
src + count;
107 const uint8_t* cur_end_pos;
108 uint8_t* encrypted_counter_pos;
110 while (
src < src_end) {
111 if (
a->block_offset == 0) {
117 encrypted_counter_pos =
a->encrypted_counter +
a->block_offset;
119 cur_end_pos =
FFMIN(cur_end_pos, src_end);
121 a->block_offset += cur_end_pos -
src;
124 while (
src < cur_end_pos) {
125 *dst++ = *
src++ ^ *encrypted_counter_pos++;
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
const uint8_t * av_aes_ctr_get_iv(struct AVAESCTR *a)
Get the current iv.
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
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.
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
Generate a random iv.
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.
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the 8-byte iv.
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_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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 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)
static void av_aes_ctr_increment_be64(uint8_t *counter)