From patchwork Sat Jul 2 08:14:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lishuangxi X-Patchwork-Id: 36589 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp1514262pzh; Sat, 2 Jul 2022 01:14:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uiCKlspMVCr3j//UWSScQeGtYhSPgclpZkP/tSmVLidR5125eHquoSIOIfaQ3vAdqgjPDa X-Received: by 2002:a05:6402:5249:b0:435:a419:300a with SMTP id t9-20020a056402524900b00435a419300amr23771945edd.56.1656749695134; Sat, 02 Jul 2022 01:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656749695; cv=none; d=google.com; s=arc-20160816; b=foKvDrTDbgoRc6GmglU9gA1va+vWMkN7Acd/bU6IvjGsnPIdRfGMeVKuTJdiuZqiAV iC49bWQKEPYmMSCE8kP/mOBZy+50l408mdTGH0qjwhbEY6gk163Fw0DPrhmkTpq6uqlg movp+8NOyj4z5jvLqV4jrlq8lZd3+l5bYxvJdMJ8r7Uvda5DXRiDtXgj1670LC1OfHp8 lwudfNzAHknSV1JSFQ94wRrSBPyrn46Rp+G19wRh4997iCEzolhjLfwwqwZIJnggVi4z URUju6/2aKqgEkVTIwkfCXRBTkxjUKu0W9sNp+HMlrsbY3l+q+1bJeXrmwTPrFWei+TB mX8g== 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:mime-version:content-language:accept-language :message-id:date:thread-index:thread-topic:to:from:delivered-to; bh=E3gmL9+eo5pks7MPFzy55qn8aAEEIRJPitCr61XVTYU=; b=f+zfw6ysTs6HsDZ0F6LAyMZ/cu0X/j/Pd5EOR9BQqk4MrFi7p0vp7c6F5sACPLQ8Rb 45J/r0FnruzIei+Q3saz64c4/NI1VT3HP9U7IBztuYvp72jaLJ0lJaowNZqgv0iL7Ono 0vIINKw/ZRnWU/R2xghuVPB05u60gchP1bSdub2CsXkfar95z04OZIEvRggK2WIuJqoj BRO7JtRmzyMQkO6ZZKKUotEY/vCbqa5+MvCL6fbK4/Y2guGcx93Kz2GEobBf/KxyaRAh IE5ejG+U8A0jXOULdJqM2SxgO5GE0dxsHIDWiIbLEIgHvYuZ2kaXKkW4ucOGjGA/U2aM MVlg== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rk9-20020a170907214900b00722f4502e2csi27373746ejb.631.2022.07.02.01.14.54; Sat, 02 Jul 2022 01:14:55 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B3A268B860; Sat, 2 Jul 2022 11:14:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 422B468B710 for ; Sat, 2 Jul 2022 11:14:43 +0300 (EEST) Received: from kwepemi100005.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LZlBg4D64zTgD4 for ; Sat, 2 Jul 2022 16:11:07 +0800 (CST) Received: from kwepemi500015.china.huawei.com (7.221.188.92) by kwepemi100005.china.huawei.com (7.221.188.155) 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 16:14:40 +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 16:14:40 +0800 From: lishuangxi To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] avformat/mov: h264 cenc entryption file decryption_key failed Thread-Index: AdiN65WPma/1aeq+SNexmwDfT3I2jA== Date: Sat, 2 Jul 2022 08:14:39 +0000 Message-ID: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1FQ0NlAWx75f 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;