23 #define FF_ENCRYPTION_INFO_EXTRA 24
48 info->key_id_size = key_id_size;
50 info->iv_size = iv_size;
52 info->subsample_count = subsample_count;
55 if (!
info->key_id || !
info->iv || (!
info->subsamples && subsample_count)) {
72 ret->crypt_byte_block =
info->crypt_byte_block;
73 ret->skip_byte_block =
info->skip_byte_block;
75 memcpy(
ret->key_id,
info->key_id,
info->key_id_size);
76 memcpy(
ret->subsamples,
info->subsamples,
sizeof(*
info->subsamples) *
info->subsample_count);
93 uint64_t key_id_size, iv_size, subsample_count,
i;
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++) {
127 uint8_t *
buffer, *cur_buffer;
130 if (UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA < info->key_id_size ||
137 (
info->subsample_count * 8);
149 memcpy(cur_buffer,
info->key_id,
info->key_id_size);
150 cur_buffer +=
info->key_id_size;
151 memcpy(cur_buffer,
info->iv,
info->iv_size);
152 cur_buffer +=
info->iv_size;
153 for (
i = 0;
i <
info->subsample_count;
i++) {
154 AV_WB32(cur_buffer,
info->subsamples[
i].bytes_of_clear_data);
155 AV_WB32(cur_buffer + 4,
info->subsamples[
i].bytes_of_protected_data);
174 #define FF_ENCRYPTION_INIT_INFO_EXTRA 16
177 uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
187 info->system_id_size = system_id_size;
189 info->num_key_ids = num_key_ids;
190 info->key_id_size = key_id_size;
192 info->data_size = data_size;
195 if ((!
info->system_id && system_id_size) || (!
info->data && data_size) ||
196 (!
info->key_ids && num_key_ids && key_id_size)) {
202 for (
i = 0;
i < num_key_ids;
i++) {
204 if (!
info->key_ids[
i]) {
218 for (
i = 0;
i <
info->num_key_ids;
i++) {
230 const uint8_t *side_data,
size_t side_data_size)
234 uint64_t system_id_size, num_key_ids, key_id_size, data_size,
i, j;
235 uint64_t init_info_count;
237 if (!side_data || side_data_size < 4)
240 init_info_count =
AV_RB32(side_data);
243 for (
i = 0;
i < init_info_count;
i++) {
249 system_id_size =
AV_RB32(side_data);
250 num_key_ids =
AV_RB32(side_data + 4);
251 key_id_size =
AV_RB32(side_data + 8);
252 data_size =
AV_RB32(side_data + 12);
270 info->next = temp_info;
274 memcpy(
info->system_id, side_data, system_id_size);
275 side_data += system_id_size;
276 side_data_size -= system_id_size;
277 for (j = 0; j < num_key_ids; j++) {
278 memcpy(
info->key_ids[j], side_data, key_id_size);
279 side_data += key_id_size;
280 side_data_size -= key_id_size;
282 memcpy(
info->data, side_data, data_size);
283 side_data += data_size;
284 side_data_size -= data_size;
293 uint8_t *
buffer, *cur_buffer;
294 uint32_t
i, init_info_count;
295 uint64_t temp_side_data_size;
297 temp_side_data_size = 4;
299 for (cur_info =
info; cur_info; cur_info = cur_info->
next) {
301 if (init_info_count == UINT32_MAX || temp_side_data_size > UINT32_MAX) {
308 if (temp_side_data_size > UINT32_MAX) {
313 *side_data_size = temp_side_data_size;
319 AV_WB32(cur_buffer, init_info_count);
321 for (cur_info =
info; cur_info; cur_info = cur_info->
next) {