From: lishuangxi <lishuangxi@huawei.com>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avformat/mov: h264 cenc entryption file decryption_key failed
Date: Sat, 2 Jul 2022 08:14:39 +0000
Message-ID: <d725563686bc4d2c86d5c1941f89e8f2@huawei.com> (raw)
Fixes ticket #9807.
Signed-off-by: ShuangxiLi <lishuangxi@huawei.com>
---
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".
next reply other threads:[~2022-07-02 8:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-02 8:14 lishuangxi [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-09 6:55 lishuangxi
2022-07-09 18:22 ` Marton Balint
2022-07-12 17:30 ` Marton Balint
2022-07-02 7:46 [FFmpeg-devel] [PATCH] avformat/mov " lishuangxi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d725563686bc4d2c86d5c1941f89e8f2@huawei.com \
--to=lishuangxi@huawei.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git