23 #define FF_ENCRYPTION_INFO_EXTRA 24 93 uint64_t key_id_size, iv_size, subsample_count, i;
98 key_id_size =
AV_RB32(buffer + 12);
100 subsample_count =
AV_RB32(buffer + 20);
112 memcpy(info->
key_id, buffer + 24, key_id_size);
113 memcpy(info->
iv, buffer + key_id_size + 24, iv_size);
115 buffer += key_id_size + iv_size + 24;
116 for (i = 0; i < subsample_count; i++) {
130 if (UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA < info->key_id_size ||
151 memcpy(cur_buffer, info->
iv, info->
iv_size);
171 #define FF_ENCRYPTION_INIT_INFO_EXTRA 16 174 uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
192 if ((!info->
system_id && system_id_size) || (!info->
data && data_size) ||
193 (!info->
key_ids && num_key_ids && key_id_size)) {
199 for (i = 0; i < num_key_ids; i++) {
226 const uint8_t *side_data,
size_t side_data_size)
229 uint64_t system_id_size, num_key_ids, key_id_size, data_size, i;
234 system_id_size =
AV_RB32(side_data);
235 num_key_ids =
AV_RB32(side_data + 4);
236 key_id_size =
AV_RB32(side_data + 8);
237 data_size =
AV_RB32(side_data + 12);
247 memcpy(info->
system_id, side_data + 16, system_id_size);
248 side_data += system_id_size + 16;
249 for (i = 0; i < num_key_ids; i++) {
250 memcpy(info->
key_ids[i], side_data, key_id_size);
251 side_data += key_id_size;
253 memcpy(info->
data, side_data, data_size);
261 uint32_t i, max_size;
263 if (UINT32_MAX - FF_ENCRYPTION_INIT_INFO_EXTRA < info->system_id_size ||
276 cur_buffer = buffer =
av_malloc(*side_data_size);
void av_encryption_info_free(AVEncryptionInfo *info)
Frees the given encryption info object.
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.
Memory handling functions.
void av_encryption_init_info_free(AVEncryptionInitInfo *info)
Frees the given encryption init info object.
uint32_t crypt_byte_block
Only used for pattern encryption.
This describes encryption info for a packet.
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...
uint32_t skip_byte_block
Only used for pattern encryption.
uint8_t ** key_ids
An array of key IDs this initialization data is for.
AVEncryptionInfo * av_encryption_info_clone(const AVEncryptionInfo *info)
Allocates an AVEncryptionInfo structure with a copy of the given data.
unsigned int bytes_of_clear_data
The number of bytes that are clear.
uint32_t scheme
The fourcc encryption scheme.
This describes info used to initialize an encryption key system.
uint8_t * iv
The initialization vector.
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.
AVSubsampleEncryptionInfo * subsamples
An array of subsample encryption info specifying how parts of the sample are encrypted.
uint32_t num_key_ids
The number of key IDs.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
unsigned int bytes_of_protected_data
The number of bytes that are protected.
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.
uint32_t key_id_size
The number of bytes in each key ID.
uint8_t * key_id
The ID of the key used to encrypt the packet.
uint8_t * data
Key-system specific initialization data.
#define FF_ENCRYPTION_INFO_EXTRA
This file is part of FFmpeg.
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...
#define FF_ENCRYPTION_INIT_INFO_EXTRA
uint8_t * system_id
A unique identifier for the key system this is for, can be NULL if it is not known.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().