8

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:

user3541092
  • 267
  • 1
  • 3
  • 12
  • 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](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) or [Information Security Stack Exchange](http://security.stackexchange.com/) would be a better place to ask. – jww Nov 01 '16 at 21:39
  • 1
    I agree and thank you for correcting me. I'll be more aware of questions I ask going forward. – user3541092 Nov 02 '16 at 18:26

1 Answers1

8

-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.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • Thank you for the response. I'm still running into problems. I apologize in advance for my confusion. – user3541092 Nov 02 '16 at 20:06
  • 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
    enter aes-128-cbc decryption password:
    – user3541092 Nov 02 '16 at 20:06
  • 1
    @user3541092 `openssl aes-128-cbc -d -in encrypted_segment.ts -out decrypted_segment.ts -nosalt -iv -K ` where `iv` and `K` are in hex (random example `-K 0ffa87119864cffd5f63f89106f1c1c2`) – aergistal Nov 03 '16 at 08:42
  • @aergistal I have a `.key` file, how would I get the respective hex string for it? – Script47 Oct 01 '19 at 21:54
  • 1
    @Script47 It's in the answer: `xxd -p MyKeyFile.key` – aergistal Oct 02 '19 at 07:22