Projects
home:alucardx:ffmpeg-dev
ffmpeg-6
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
Difference Between Revision 3 and
Essentials
/
A_tw-ffmpeg-6
View file
ffmpeg-6.spec
Changed
@@ -122,6 +122,7 @@ Patch91: ffmpeg-dlopen-openh264.patch Patch92: ffmpeg-CVE-2023-50007.patch Patch93: ffmpeg-CVE-2023-50008.patch +Patch95: ffmpeg-support-kid-key.patch BuildRequires: ladspa-devel BuildRequires: libgsm-devel BuildRequires: libmp3lame-devel >= 3.98.3 @@ -844,6 +845,7 @@ Patch91: ffmpeg-dlopen-openh264.patch Patch92: ffmpeg-CVE-2023-50007.patch Patch93: ffmpeg-CVE-2023-50008.patch +Patch95: ffmpeg-support-kid-key.patch BuildRequires: c_compiler Requires: this-is-only-for-build-envs
View file
ffmpeg-support-kid-key.patch
Added
@@ -0,0 +1,473 @@ +diff --git a/doc/demuxers.texi b/doc/demuxers.texi +index ca1563abb0..9d0ab6025c 100644 +--- a/doc/demuxers.texi ++++ b/doc/demuxers.texi +@@ -281,7 +281,11 @@ This demuxer accepts the following option: + @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 + +@@ -769,7 +773,11 @@ Fixed key used for handling Audible AAX/AAX+ files. It has been pre-set so shoul + 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 +diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c +index 1215407f3c..091deac854 100644 +--- a/libavformat/dashdec.c ++++ b/libavformat/dashdec.c +@@ -153,6 +153,7 @@ typedef struct DASHContext { + 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; +@@ -1903,6 +1904,8 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation + + 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 +@@ -2344,7 +2347,8 @@ static const AVOption dash_options = { + 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} + }; + +diff --git a/libavformat/isom.h b/libavformat/isom.h +index 3d375d7a46..83bacb96a1 100644 +--- a/libavformat/isom.h ++++ b/libavformat/isom.h +@@ -312,8 +312,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; +@@ -328,6 +328,7 @@ + } *avif_info; + int avif_info_size; + int interleaved_read; ++ AVDictionary* decryption_keys; + } MOVContext; + + int ff_mp4_read_descr_len(AVIOContext *pb); +diff --git a/libavformat/mov.c b/libavformat/mov.c +index 34ca8095c2..550bce86f5 100644 +--- a/libavformat/mov.c ++++ b/libavformat/mov.c +@@ -7130,19 +7130,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; + } +@@ -7188,15 +7231,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; + } +@@ -7247,15 +7296,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; + } +@@ -7313,15 +7368,21 @@
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
.