# HLS key rotation is wrong

**URL:** https://community.wowza.com/t/hls-key-rotation-is-wrong/41586
**Category:** Wowza Streaming Engine
**Created:** [December 3, 2013, 12:34pm UTC](https://community.wowza.com/t/hls-key-rotation-is-wrong/41586 "2013-12-03T12:34:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![joh\_sun](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@joh\_sun](https://community.wowza.com/u/joh_sun)
#### Post date: [December 3, 2013, 12:34pm UTC](https://community.wowza.com/t/hls-key-rotation-is-wrong/41586/1 "2013-12-03T12:34:30Z")

</div>

Hi,

I used the onHTTPCupertinoEncryptionKeyVODChunk to encypt the HLS Vod, when I add the key rotation feature:

encInfo.setEncMethod(CupertinoEncInfo.METHOD\_AES\_128);

if( ( chunkId ) \>= 4 ) {

encInfo.setEncUrl(“[http://mycompanykeyserver.com/authenticate.aspx](http://mycompanykeyserver.com/authenticate.aspx)”);

encInfo.setEncKeyBytes( “0123456789ABCDEF”.getBytes() );

}

else {

encInfo.setEncUrl(“[http://mycompanykeyserver.com/authenticat1e.aspx](http://mycompanykeyserver.com/authenticat1e.aspx)”);

encInfo.setEncKeyBytes( “1123456789ABCDEF”.getBytes() );

}

encInfo.setEncIVBytes(BufferUtils.decodeHexString(“FEDCBA9876543210FEDCBA9876543210”));

#EXT-X-KEY:METHOD=AES-128,URI=“[http://mycompanykeyserver.com/authenticat1e.aspx](http://mycompanykeyserver.com/authenticat1e.aspx)”,IV=0xfedcba9876543210fedcba9876543210

#EXTINF:11.25,

media\_0.ts

#EXTINF:11.25,

media\_1.ts

#EXTINF:11.25,

media\_2.ts

#EXT-X-KEY:METHOD=AES-128,URI=“[http://mycompanykeyserver.com/authenticate.aspx](http://mycompanykeyserver.com/authenticate.aspx)”,IV=0xfedcba9876543210fedcba9876543210

#EXTINF:11.25,

media\_3.ts

#EXTINF:10.208,

media\_4.ts

I can’t decrypt the media\_3.ts using the key 0123456789ABCDEF, but I can decrypt the media\_3.ts using the key 1123456789ABCDEF correctly.

Is there something wrong with me?

---

<div class="post-metadata">

### Author: ![joh\_sun](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@joh\_sun](https://community.wowza.com/u/joh_sun)
#### Post date: [December 3, 2013, 12:39pm UTC](https://community.wowza.com/t/hls-key-rotation-is-wrong/41586/2 "2013-12-03T12:39:54Z")

</div>

I am using wowza 3.6.3 official version

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [December 3, 2013, 3:03pm UTC](https://community.wowza.com/t/hls-key-rotation-is-wrong/41586/3 "2013-12-03T15:03:12Z")

</div>

There is apparently a typo in the name of the page. You have authenticate.aspx, then authenticat1e.aspx

Richard

---

<div class="post-metadata">

### Author: ![joh\_sun](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@joh\_sun](https://community.wowza.com/u/joh_sun)
#### Post date: [December 4, 2013, 2:32pm UTC](https://community.wowza.com/t/hls-key-rotation-is-wrong/41586/4 "2013-12-04T14:32:30Z")

</div>

#EXT-X-KEY:METHOD=AES-128,URI=“[http://mycompanykeyserver.com/authenticate.aspx](http://mycompanykeyserver.com/authenticate.aspx)”,IV=0xfedcba9876543210fedcba9876 543210

#EXTINF:11.25,

media\_3.ts

According to the m3u8 file, The media\_3.ts would use the 0123456789ABCDEF to decrypt, but I can’t decrypt this file using 0123456789ABCDEF(“[http://mycompanykeyserver.com/authenticate.aspx](http://mycompanykeyserver.com/authenticate.aspx)”), but it’s right when using 1123456789ABCDEF([http://mycompanykeyserver.com/authenticat1e.aspx](http://mycompanykeyserver.com/authenticat1e.aspx))
