0

I'm trying to decrypt a file with

openssl enc -d -aes128 -in n_1_0_0.ts -out a.ts -K $(hexdump -v -e '/1 "%02X"' < test.php) -iv 0

I get this error

hex string is too short, padding with zero bytes to length
bad decrypt
4618354176:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:crypto/evp/evp_enc.c:610:

test.php is a 16Byte file.

Here are the files - https://drive.google.com/file/d/1nS5ZI_0HlVPNU6MizvQGVpo_EaxqntfW/view?usp=sharing

Necor
  • 93
  • 1
  • 9
  • "too short" is only a warning, and about the IV. The error means at least one of your key, IV or ciphertext is wrong. In general CBC mode should not be used with zero IV, so that _might_ be the error, but your 'key' is meaningful ASCII text which a proper key should practically never be (maybe once every trillion years in some far-distant galaxy, not here) – dave_thompson_085 Jun 25 '21 at 05:51
  • @dave_thompson_085 I'm trying to download a m3u8 file. It doesn't contain an iv but "#EXT-X-MEDIA-SEQUENCE:0". Which means iv is 0 right? – Necor Jun 25 '21 at 10:30
  • Not in general. This has already been addressed and the concept of StackExchange is that you should look at existing answers; see https://stackoverflow.com/questions/16132088/how-to-decrypt-aes-128-encrypted-m3u8-video-files https://stackoverflow.com/questions/47769438/how-to-decrypt-aes-128-encrypted-m3u8-ts-files https://stackoverflow.com/questions/50628791/decrypt-m3u8-playlist-encrypted-with-aes-128-without-iv – dave_thompson_085 Jun 26 '21 at 03:00

1 Answers1

0

As far as warnings are concerned, as mentioned in the comment too, they can be resolved by using the right length for key and iv strings.

For AES-128, your key and iv both are expected to be 128-bit or 16 bytes long. Thus, corresponding hex string should be 32 characters long.

I resolved this warning by appending the following code in python 2.7:

[key].ljust(32, '0')
[iv].ljust(32, '0')

Above code will pad 0's to (placeholder) key and iv variables.

Saad
  • 87
  • 6