Apple HLS Encryption - AES-128 - SAMPLE-AES

Apple HTTP Live Streaming Encryption

HLS DRM does not always need to be a Hollywood grade DRM.  Sometimes it’s enough to just add another layer of security through AES encryption. The bitmovin encoding service and player enable this workflow for HLS and MPEG-DASH.

HLS AES Encryption

Apple HLS supports two encryption methods:

  • AES-128
  • SAMPLE-AES

AES-128 encrypts the whole segment with the Advanced Encryption Standard (AES) using a 128 bit key, Cipher Block Chaining (CBC) and PKCS7 padding. The CBC will be restarted with each segment using the Initialization Vector (IV) provided.

SAMPLE-AES encrypts each individual media sample (e.g., video, audio, etc.) by its own with AES. The specific encryption and packaging depends on the media format, e.g., H.264, AAC, etc. SAMPLE-AES allows fine grained encryption modes, e.g., just encrypt I frames, just encrypt 1 out of 10 samples, etc. This could decrease the complexity of the decryption process. Several advantages result out of this approach as fewer CPU cycles are needed and for example mobile devices need less power consumption, higher resolutions can be effectively decrypted, etc.

Implementing HLS DRM

We support both modes with our encoding service and our player. For the encoding and packaging you can use our REST API or one of our API Clients, like our Java API Client which contains a simple example for HLS encryption. Basically you just need to add a HLSEncryptionConfig to the job and that’s it:


/* Create HlsEncryptionConfig */
HlsEncryptionConfig hlsEncryptionConfig = new HlsEncryptionConfig();
hlsEncryptionConfig.method = HlsMethod.SAMPLE_AES; // Choose the encryption mode
hlsEncryptionConfig.key = "YOUR_KEY";

/* Create Encoding Job */
JobConfig jobConfig = new JobConfig();
...
jobConfig.manifestTypes.addElement(ManifestType.HLS_M3U8);
jobConfig.speed = Speed.STANDARD;
jobConfig.hlsEncryptionConfig = hlsEncryptionConfig;

Java HLS Encryption Example

All information that the player needs for decryption is provided in the M3U8 of the content. You can follow our player setup tutorial and it should work out of the box.

Back to Top
Simple Share Buttons