From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F38F342C81 for ; Sat, 2 Jul 2022 07:46:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84D3D68B851; Sat, 2 Jul 2022 10:46:46 +0300 (EEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3B4268B576 for ; Sat, 2 Jul 2022 10:46:39 +0300 (EEST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LZkc808snzkWMR for ; Sat, 2 Jul 2022 15:44:40 +0800 (CST) Received: from kwepemi500015.china.huawei.com (7.221.188.92) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 2 Jul 2022 15:46:35 +0800 Received: from kwepemi500015.china.huawei.com ([7.221.188.92]) by kwepemi500015.china.huawei.com ([7.221.188.92]) with mapi id 15.01.2375.024; Sat, 2 Jul 2022 15:46:35 +0800 From: lishuangxi To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] avformat/mov h264 cenc entryption file decryption_key failed Thread-Index: AdiN59fXC4WGLptFT6ynM2N2X6FIKQ== Date: Sat, 2 Jul 2022 07:46:35 +0000 Message-ID: <58e836a172fe4587a105b8e634242e50@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.136.96.129] MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: [FFmpeg-devel] [PATCH] avformat/mov h264 cenc entryption file decryption_key failed X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes ticket #9807. Signed-off-by: ShuangxiLi --- libavformat/mov.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 88669faa70..71dce69677 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6819,9 +6819,6 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption { int i, ret; int bytes_of_protected_data; - int partially_encrypted_block_size; - uint8_t *partially_encrypted_block; - uint8_t block[16]; if (!sc->cenc.aes_ctr) { /* initialize the cipher */ @@ -6844,8 +6841,6 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption return 0; } - partially_encrypted_block_size = 0; - for (i = 0; i < sample->subsample_count; i++) { if (sample->subsamples[i].bytes_of_clear_data + sample->subsamples[i].bytes_of_protected_data > size) { av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet size left\n"); @@ -6858,28 +6853,8 @@ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption /* decrypt the encrypted bytes */ - if (partially_encrypted_block_size) { - memcpy(block, partially_encrypted_block, partially_encrypted_block_size); - memcpy(block+partially_encrypted_block_size, input, 16-partially_encrypted_block_size); - av_aes_ctr_crypt(sc->cenc.aes_ctr, block, block, 16); - memcpy(partially_encrypted_block, block, partially_encrypted_block_size); - memcpy(input, block+partially_encrypted_block_size, 16-partially_encrypted_block_size); - input += 16-partially_encrypted_block_size; - size -= 16-partially_encrypted_block_size; - bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data - (16-partially_encrypted_block_size); - } else { - bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data; - } - - if (i < sample->subsample_count-1) { - int num_of_encrypted_blocks = bytes_of_protected_data/16; - partially_encrypted_block_size = bytes_of_protected_data%16; - if (partially_encrypted_block_size) - partially_encrypted_block = input + 16*num_of_encrypted_blocks; - av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, 16*num_of_encrypted_blocks); - } else { - av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, bytes_of_protected_data); - } + bytes_of_protected_data = sample->subsamples[i].bytes_of_protected_data; + av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, bytes_of_protected_data); input += bytes_of_protected_data; size -= bytes_of_protected_data; -- 2.24.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".