iheartradio / open-m3u8

Open Source m3u8 Parser
Other
245 stars 94 forks source link

Iv hex encoding #51

Closed Raniz85 closed 6 years ago

Raniz85 commented 6 years ago

Fix for #50

Wopple commented 6 years ago

Unfortunately, not all the tests pass because of the faulty implementation. Can you please make the following changes? MediaPlaylistLineParserTest.java:

// from
        assertEquals(
                Arrays.asList((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 10, (byte) 11, (byte) 12, (byte) 13,
                              (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 14, (byte) 15, (byte) 9, (byte) 0),
                encryptionData.getInitializationVector());
// to
        assertEquals(
                Arrays.asList((byte) 0x12, (byte) 0x34, (byte) 0xAB, (byte) 0xCD,
                              (byte) 0x56, (byte) 0x78, (byte) 0xEF, (byte) 0x90),
                encryptionData.getInitializationVector());

Constants.java:

// from
    public static final int IV_SIZE = 16;
    //Against the spec but used by Adobe
    public static final int IV_SIZE_ALTERNATIVE = 32;
// to
    public static final int IV_SIZE = 8;
    //Against the spec but used by Adobe
    public static final int IV_SIZE_ALTERNATIVE = 16;

The rest looks good.

@sunglee413 this is good to go once the changes above are made to fix the tests.

Raniz85 commented 6 years ago

The IV sizes shouldn't be changed - an IV in AES is 128 bits, so 16 bytes is correct - so I'll just increase the length of the IV in the test.

Raniz85 commented 6 years ago

Done. ./gradlew check now finishes without errors.

Wopple commented 6 years ago

Yeah, I can't maths. LGTM!