Projects
home:alucardx:ffmpeg-dev
ffmpeg-7
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
ffmpeg-support-kid-key.patch
Added
@@ -0,0 +1,454 @@ +--- a/doc/demuxers.texi ++++ b/doc/demuxers.texi +@@ -281,7 +281,11 @@ + @table @option + + @item cenc_decryption_key +-16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). ++Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). ++ ++ at item cenc_decryption_keys ++Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption ++(CENC/AES-128 CTR; ISO/IEC 23001-7). + + @end table + +@@ -931,7 +935,11 @@ + specify. + + @item decryption_key +-16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). ++Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). ++ ++ at item decryption_keys ++Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption ++(CENC/AES-128 CTR; ISO/IEC 23001-7). + + @item max_stts_delta + Very high sample deltas written in a trak's stts box may occasionally be intended but usually they are written in +--- a/libavformat/dashdec.c ++++ b/libavformat/dashdec.c +@@ -153,6 +153,7 @@ + AVDictionary *avio_opts; + int max_url_size; + char *cenc_decryption_key; ++ char *cenc_decryption_keys; + + /* Flags for init section*/ + int is_init_section_common_video; +@@ -1906,6 +1907,8 @@ + + if (c->cenc_decryption_key) + av_dict_set(&in_fmt_opts, "decryption_key", c->cenc_decryption_key, 0); ++ if (c->cenc_decryption_keys) ++ av_dict_set(&in_fmt_opts, "decryption_keys", c->cenc_decryption_keys, 0); + + // provide additional information from mpd if available + ret = avformat_open_input(&pls->ctx, "", in_fmt, &in_fmt_opts); //pls->init_section->url +@@ -2347,7 +2350,8 @@ + OFFSET(allowed_extensions), AV_OPT_TYPE_STRING, + {.str = "aac,m4a,m4s,m4v,mov,mp4,webm,ts"}, + INT_MIN, INT_MAX, FLAGS}, +- { "cenc_decryption_key", "Media decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS }, ++ { "cenc_decryption_key", "Media default decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS }, ++ { "cenc_decryption_keys", "Media decryption keys by KID (hex)", OFFSET(cenc_decryption_keys), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS }, + {NULL} + }; + +--- a/libavformat/isom.h ++++ b/libavformat/isom.h +@@ -340,8 +340,8 @@ + void *audible_iv; + int audible_iv_size; + struct AVAES *aes_decrypt; +- uint8_t *decryption_key; +- int decryption_key_len; ++ uint8_t *decryption_default_key; ++ int decryption_default_key_len; + int enable_drefs; + int32_t movie_display_matrix33; ///< display matrix from mvhd + int have_read_mfra_size; +@@ -356,6 +356,7 @@ + int thmb_item_id; + int64_t idat_offset; + int interleaved_read; ++ AVDictionary* decryption_keys; + } MOVContext; + + int ff_mp4_read_descr_len(AVIOContext *pb); +--- a/libavformat/mov.c ++++ b/libavformat/mov.c +@@ -7414,19 +7414,62 @@ + return 0; + } + ++static int get_key_from_kid(uint8_t* out, int len, MOVContext *c, AVEncryptionInfo *sample) { ++ AVDictionaryEntry *key_entry_hex; ++ char kid_hex16*2+1; ++ ++ if (c->decryption_default_key && c->decryption_default_key_len != len) { ++ av_log(c->fc, AV_LOG_ERROR, "invalid default decryption key length: got %d, expected %d\n", c->decryption_default_key_len, len); ++ return -1; ++ } ++ ++ if (!c->decryption_keys) { ++ av_assert0(c->decryption_default_key); ++ memcpy(out, c->decryption_default_key, len); ++ return 0; ++ } ++ ++ if (sample->key_id_size != 16) { ++ av_log(c->fc, AV_LOG_ERROR, "invalid key ID size: got %u, expected 16\n", sample->key_id_size); ++ return -1; ++ } ++ ++ ff_data_to_hex(kid_hex, sample->key_id, 16, 1); ++ key_entry_hex = av_dict_get(c->decryption_keys, kid_hex, NULL, AV_DICT_DONT_STRDUP_KEY|AV_DICT_DONT_STRDUP_VAL); ++ if (!key_entry_hex) { ++ if (!c->decryption_default_key) { ++ av_log(c->fc, AV_LOG_ERROR, "unable to find KID %s\n", kid_hex); ++ return -1; ++ } ++ memcpy(out, c->decryption_default_key, len); ++ return 0; ++ } ++ if (strlen(key_entry_hex->value) != len*2) { ++ return -1; ++ } ++ ff_hex_to_data(out, key_entry_hex->value); ++ return 0; ++} ++ + static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size) + { + int i, ret; + int bytes_of_protected_data; ++ uint8_t decryption_keyAES_CTR_KEY_SIZE; + + if (!sc->cenc.aes_ctr) { ++ ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample); ++ if (ret < 0) { ++ return ret; ++ } ++ + /* initialize the cipher */ + sc->cenc.aes_ctr = av_aes_ctr_alloc(); + if (!sc->cenc.aes_ctr) { + return AVERROR(ENOMEM); + } + +- ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key); ++ ret = av_aes_ctr_init(sc->cenc.aes_ctr, decryption_key); + if (ret < 0) { + return ret; + } +@@ -7472,15 +7515,21 @@ + int i, ret; + int num_of_encrypted_blocks; + uint8_t iv16; ++ uint8_t decryption_key16; + + if (!sc->cenc.aes_ctx) { ++ ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample); ++ if (ret < 0) { ++ return ret; ++ } ++ + /* initialize the cipher */ + sc->cenc.aes_ctx = av_aes_alloc(); + if (!sc->cenc.aes_ctx) { + return AVERROR(ENOMEM); + } + +- ret = av_aes_init(sc->cenc.aes_ctx, c->decryption_key, 16 * 8, 1); ++ ret = av_aes_init(sc->cenc.aes_ctx, decryption_key, 16 * 8, 1); + if (ret < 0) { + return ret; + } +@@ -7531,15 +7580,21 @@ + { + int i, ret, rem_bytes; + uint8_t *data; ++ uint8_t decryption_keyAES_CTR_KEY_SIZE; + + if (!sc->cenc.aes_ctr) { ++ ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample); ++ if (ret < 0) { ++ return ret; ++ } ++ + /* initialize the cipher */ + sc->cenc.aes_ctr = av_aes_ctr_alloc(); + if (!sc->cenc.aes_ctr) { + return AVERROR(ENOMEM); + } + +- ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key); ++ ret = av_aes_ctr_init(sc->cenc.aes_ctr, decryption_key); + if (ret < 0) { + return ret; + } +@@ -7597,15 +7652,21 @@ + int i, ret, rem_bytes; + uint8_t iv16; + uint8_t *data; ++ uint8_t decryption_key16; + + if (!sc->cenc.aes_ctx) { ++ ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample); ++ if (ret < 0) {
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.