Using OpenSSL to decrypt a .ts file
Asked Answered
M

1

9

Everything is in the same directory.

M3u8 File:

#EXTM3U
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI=MyKeyFile.key
#EXTINF:10,
aes_ts_files/filesequence0000000.ts
#EXTINF:10,
aes_ts_files/filesequence0000001.ts
#EXTINF:10,
aes_ts_files/filesequence0000002.ts
#EXTINF:10,
aes_ts_files/filesequence0000003.ts
#EXTINF:10,
aes_ts_files/filesequence0000004.ts
#EXTINF:10,
aes_ts_files/filesequence0000005.ts
#EXTINF:10,
aes_ts_files/filesequence0000006.ts
#EXTINF:10,
aes_ts_files/filesequence0000007.ts
#EXTINF:10,
aes_ts_files/filesequence0000008.ts
#EXTINF:10,
aes_ts_files/filesequence0000009.ts
#EXTINF:10,
aes_ts_files/filesequence0000010.ts
#EXTINF:10,
aes_ts_files/filesequence0000011.ts
#EXTINF:10,
aes_ts_files/filesequence0000012.ts
#EXTINF:10,
aes_ts_files/filesequence0000013.ts
#EXTINF:10,
aes_ts_files/filesequence0000014.ts
#EXTINF:10,
aes_ts_files/filesequence0000015.ts
#EXTINF:10,
aes_ts_files/filesequence0000016.ts
#EXTINF:10,
aes_ts_files/filesequence0000017.ts
#EXTINF:10,
aes_ts_files/filesequence0000018.ts
#EXTINF:10,
aes_ts_files/filesequence0000019.ts
#EXTINF:10,
aes_ts_files/filesequence0000020.ts
#EXTINF:10,
aes_ts_files/filesequence0000021.ts
#EXTINF:10,
aes_ts_files/filesequence0000022.ts
#EXTINF:3,
aes_ts_files/filesequence0000023.ts
#EXT-X-ENDLIST

MyKeyFile.Key

tßâ0Äb‘˜p.ô[{m‚

I know the content is legit because if I right click on the .m3u8 and select "Play with VLC media player" it works. I need to decrypt the ts files so I can use ffprobe and inspect the content.

Here is the OpenSSL command I've tried:

openssl aes-128-cbc -d -kfile MyKeyFile.key -iv 0 -nosalt -in aes_ts_files/filesequence0000000.ts -out aes_ts_files/filesequence0000000_out.ts

Error Message: bad decrypt 18676:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:c rypto\evp\evp_enc.c:529:

Monetta answered 1/11, 2016 at 18:46 Comment(2)
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Unix & Linux Stack Exchange or Information Security Stack Exchange would be a better place to ask.Creamer
I agree and thank you for correcting me. I'll be more aware of questions I ask going forward.Monetta
X
10

-kfile is used to derive the key from a password stored in the first line of the file.

You already have the actual key so you need to pass it using -K key where key is the key in hex (xxd -p MyKeyFile.key).

The IV is also a hex string and it's equal to the media sequence if not specified.

Xray answered 1/11, 2016 at 22:2 Comment(5)
Thank you for the response. I'm still running into problems. I apologize in advance for my confusion.Monetta
C:\OpenSSL-Win32\bin>openssl aes-128-cbc -d -p MyKeyFile.key -iv 0 -nosalt -in a es_ts_files/filesequence0000000.ts -out aes_ts_files/filesequence0000000_out.ts <br /> enter aes-128-cbc decryption password:Monetta
@Monetta openssl aes-128-cbc -d -in encrypted_segment.ts -out decrypted_segment.ts -nosalt -iv <iv_hex> -K <key_hex> where iv and K are in hex (random example -K 0ffa87119864cffd5f63f89106f1c1c2)Xray
@Xray I have a .key file, how would I get the respective hex string for it?Airspace
@Airspace It's in the answer: xxd -p MyKeyFile.keyXray

© 2022 - 2024 — McMap. All rights reserved.