26#define FF_ENCRYPTION_INFO_EXTRA 24
96 uint64_t key_id_size, iv_size, subsample_count,
i;
116 memcpy(info->
iv,
buffer + key_id_size + 24, iv_size);
118 buffer += key_id_size + iv_size + 24;
119 for (
i = 0;
i < subsample_count;
i++) {
130 uint8_t *
buffer, *cur_buffer;
154 memcpy(cur_buffer, info->
iv, info->
iv_size);
177#define FF_ENCRYPTION_INIT_INFO_EXTRA 16
180 uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
185 if (num_key_ids && !key_id_size)
197 if ((!info->
system_id && system_id_size) || (!info->
data && data_size) ||
198 (!info->
key_ids && num_key_ids && key_id_size)) {
209 for (
i = 0;
i < num_key_ids;
i++) {
239 const uint8_t *side_data,
size_t side_data_size)
243 uint64_t system_id_size, num_key_ids, key_id_size, data_size,
i, j;
244 uint64_t init_info_count;
246 if (!side_data || side_data_size < 4)
249 init_info_count =
AV_RB32(side_data);
252 for (
i = 0;
i < init_info_count;
i++) {
258 system_id_size =
AV_RB32(side_data);
259 num_key_ids =
AV_RB32(side_data + 4);
260 key_id_size =
AV_RB32(side_data + 8);
261 data_size =
AV_RB32(side_data + 12);
277 info =
ret = temp_info;
279 info->next = temp_info;
283 memcpy(info->system_id, side_data, system_id_size);
284 side_data += system_id_size;
285 side_data_size -= system_id_size;
286 for (j = 0; j < num_key_ids; j++) {
287 memcpy(info->key_ids[j], side_data, key_id_size);
288 side_data += key_id_size;
289 side_data_size -= key_id_size;
291 memcpy(info->data, side_data, data_size);
292 side_data += data_size;
293 side_data_size -= data_size;
300 unsigned int *allocated_size,
304 uint8_t *
buffer, *cur_buffer;
306 uint64_t init_info_count = *side_data ?
AV_RB32(*side_data) : 0;
307 size_t old_side_data_size = *side_data ? *side_data_size : 4;
308 uint64_t new_side_data_size = old_side_data_size;
310 for (cur_info = info; cur_info; cur_info = cur_info->
next) {
312 if (init_info_count == UINT32_MAX || new_side_data_size > UINT32_MAX)
318 if (new_side_data_size > UINT32_MAX)
328 cur_buffer =
buffer + old_side_data_size;
329 for (cur_info = info; cur_info; cur_info = cur_info->
next) {
349 *side_data_size = new_side_data_size;
355 uint8_t *side_data =
NULL;
356 unsigned int allocated_size = 0;
#define i(width, name, range_min, range_max)
#define FF_ENCRYPTION_INIT_INFO_EXTRA
AVEncryptionInfo * av_encryption_info_alloc(uint32_t subsample_count, uint32_t key_id_size, uint32_t iv_size)
Allocates an AVEncryptionInfo structure and sub-pointers to hold the given number of subsamples.
AVEncryptionInfo * av_encryption_info_get_side_data(const uint8_t *buffer, size_t size)
Creates a copy of the AVEncryptionInfo that is contained in the given side data.
#define FF_ENCRYPTION_INFO_EXTRA
This file is part of FFmpeg.
AVEncryptionInfo * av_encryption_info_clone(const AVEncryptionInfo *info)
Allocates an AVEncryptionInfo structure with a copy of the given data.
AVEncryptionInitInfo * av_encryption_init_info_get_side_data(const uint8_t *side_data, size_t side_data_size)
Creates a copy of the AVEncryptionInitInfo that is contained in the given side data.
int av_encryption_init_info_append_side_data(uint8_t **side_data, size_t *side_data_size, unsigned int *allocated_size, const AVEncryptionInitInfo *info)
Appends a copy of the given encryption init info list to encryption init info side data,...
uint8_t * av_encryption_init_info_add_side_data(const AVEncryptionInitInfo *info, size_t *side_data_size)
Allocates and initializes side data that holds a copy of the given encryption init info.
uint8_t * av_encryption_info_add_side_data(const AVEncryptionInfo *info, size_t *size)
Allocates and initializes side data that holds a copy of the given encryption info.
AVEncryptionInitInfo * av_encryption_init_info_alloc(uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
Allocates an AVEncryptionInitInfo structure and sub-pointers to hold the given sizes.
void av_encryption_init_info_free(AVEncryptionInitInfo *info)
Frees the given encryption init info object.
void av_encryption_info_free(AVEncryptionInfo *info)
Frees the given encryption info object.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
This describes encryption info for a packet.
uint32_t skip_byte_block
Only used for pattern encryption.
uint8_t * iv
The initialization vector.
uint32_t crypt_byte_block
Only used for pattern encryption.
uint8_t * key_id
The ID of the key used to encrypt the packet.
AVSubsampleEncryptionInfo * subsamples
An array of subsample encryption info specifying how parts of the sample are encrypted.
uint32_t scheme
The fourcc encryption scheme, in big-endian byte order.
This describes info used to initialize an encryption key system.
uint8_t * data
Key-system specific initialization data.
struct AVEncryptionInitInfo * next
An optional pointer to the next initialization info in the list.
uint8_t ** key_ids
An array of key IDs this initialization data is for.
uint8_t * system_id
A unique identifier for the key system this is for, can be NULL if it is not known.
uint32_t key_id_size
The number of bytes in each key ID.
uint32_t num_key_ids
The number of key IDs.
unsigned int bytes_of_clear_data
The number of bytes that are clear.
unsigned int bytes_of_protected_data
The number of bytes that are protected.