From patchwork Sat Aug 5 03:36:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DHE X-Patchwork-Id: 4628 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp213759vsu; Fri, 4 Aug 2017 20:37:00 -0700 (PDT) X-Received: by 10.28.38.133 with SMTP id m127mr2370238wmm.6.1501904220623; Fri, 04 Aug 2017 20:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501904220; cv=none; d=google.com; s=arc-20160816; b=LjVcO6Cszlcs/+G7FS6doEQO68w7Q/1Olq4+y9dU49B1/Nlel6F8hVmNzF5EiobZ8r 0y7QH01HSrpTMUjVxrMe6+7yAYuRMTbsYdOEuvG1wr3vjhXpJNetXlrvUaxGrKDPvhW1 1xUanARu/JTszv06JBjpIy4SEzqYXr6tRTfFUtzX/+AoETC47RJ65TYkIiQ5tV8/7Kcp rAA1JMzDIB+BGhqXJtF4dhEopZfyMMJ2dHHuH61hbpX1nDesnOhtNdEGpkRf/KpXQOAG ABRVbme0KaIYKQ0z7BViwDjtW9Q1PHAtynrDLrhrLSfORcluEjtZ+1k2rhxtlGfCTM3U 1B+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:mime-version:user-agent:date :message-id:to:from:delivered-to:arc-authentication-results; bh=GExOJsAB0Bd51FGA+J/5Y/28uhUOaXmlw/lEnXjNkr0=; b=h5m/oCbS8zD9m93AvVLU2XSCHw8SyeOnZxE23JxF0OfjNKdop+Jjhpt5hENOph9tba dSpjBhEyas/1mIRzbqhdMHeheMbyA03JzhBkP7U5i3H7Gm4w746I/IiOcQY8eq9RozLl YV5QUpS6sHyK38cpHf0C1pvjkUv6dqp2CbLvEEZK8DU07DEWDxh8q4IPabvdA0f0ySey n9ZVDF71AKp60l8l83L5HDIPxFp6V0AlAceihJbTQlupB+9dtsrc8mBUgC9tF4D6tYcO eGEboWd9SbBBtG/KmdABzImLNJqwRsHv9wfzYANSznTd619rgotTQWVm/I8FBpbU27ed EQ/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c24si4650771wrb.60.2017.08.04.20.37.00; Fri, 04 Aug 2017 20:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 208FA680637; Sat, 5 Aug 2017 06:36:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp1.execulink.net (smtp1.execulink.net [69.63.44.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 224F468060C for ; Sat, 5 Aug 2017 06:36:50 +0300 (EEST) Received: from 23-248-133-105.tpia.execulink.com ([23.248.133.105]) by smtp1.execulink.net with esmtpsa (UNKNOWN:AES256-SHA:256) (Exim 4.77) (envelope-from ) id 1ddptR-0004PI-5q for ffmpeg-devel@ffmpeg.org; Fri, 04 Aug 2017 23:36:49 -0400 From: DeHackEd To: ffmpeg-devel@ffmpeg.org Message-ID: <730e3250-0d57-db82-97f9-1071c6cf3e4d@dehacked.net> Date: Fri, 4 Aug 2017 23:36:48 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Content-Language: en-GB Subject: [FFmpeg-devel] [PATCH v2] libaf/hlsenc: allow dynamic encryption key rotation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Makes behaviour of 805ce25b1d2f optional, re-enables HLS key rotation feature Signed-off-by: DHE --- doc/muxers.texi | 7 ++++++- libavformat/hlsenc.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) v1->v2: Actually works this time diff --git a/doc/muxers.texi b/doc/muxers.texi index 94472ce..a7324a4 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -551,7 +551,7 @@ format. The optional third line specifies the initialization vector (IV) as a hexadecimal string to be used instead of the segment sequence number (default) for encryption. Changes to @var{key_info_file} will result in segment encryption with the new key/IV and an entry in the playlist for the new key -URI/IV. +URI/IV if @code{hls_flags periodic_rekey} is enabled. Key info file format: @example @@ -665,6 +665,11 @@ first segment's information. @item omit_endlist Do not append the @code{EXT-X-ENDLIST} tag at the end of the playlist. +@item periodic_rekey +The file specified by @code{hls_key_info} will be checked periodically and +detect updates to the encryption info. Be sure to replace this file atomically, +including the file containing the AES encryption key. + @item split_by_time Allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is inconsistent, diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 5cf8c89..74a3249 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -85,6 +85,7 @@ typedef enum HLSFlags { HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment duration (microsec) in segment filenames when use_localtime e.g.: %%09t HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size (bytes) in segment filenames when use_localtime e.g.: %%014s HLS_TEMP_FILE = (1 << 11), + HLS_PERIODIC_REKEY = (1 << 12), } HLSFlags; typedef enum { @@ -1236,7 +1237,7 @@ static int hls_start(AVFormatContext *s) " will use -hls_key_info_file priority\n"); } - if (c->number <= 1) { + if (c->number <= 1 || (c->flags & HLS_PERIODIC_REKEY)) { if (c->key_info_file) { if ((err = hls_encryption_start(s)) < 0) goto fail; @@ -1804,6 +1805,7 @@ static const AVOption options[] = { {"second_level_segment_index", "include segment index in segment filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SECOND_LEVEL_SEGMENT_INDEX }, 0, UINT_MAX, E, "flags"}, {"second_level_segment_duration", "include segment duration in segment filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX, E, "flags"}, {"second_level_segment_size", "include segment size in segment filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX, E, "flags"}, + {"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX, E, "flags"}, {"use_localtime", "set filename expansion with strftime at segment creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, {"use_localtime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, "pl_type" },