EXT-X-KEY

Tells the player how the media segments that follow are encrypted, and where to get the key to play them.

Media segment tagAny protocol versionIn: Media playlistRFC 8216, section 4.3.2.4

Syntax

#EXT-X-KEY:<attribute-list>

Attributes

AttributeValueRequiredWhat it means
METHODNONE, AES-128 or SAMPLE-AESYesHow the segments are encrypted. NONE means the segments that follow are not encrypted, and then no other attribute may be present. Added in the RFC 8216bis draft: the optional methods SAMPLE-AES-CTR and AES-256-GCM.
URIURI of the key fileUnless METHOD is NONEWhere the key can be obtained. A relative URI is resolved against the address of the playlist.
IV128-bit number starting with 0x
Default: Media sequence number of the segment
NoInitialization vector used with the key. Without it, the identity key format uses the segment's media sequence number instead. Needs version 2.
KEYFORMAT"identity" or a key system identifier
Default: "identity"
NoHow the key is represented at the URI. "identity" means a plain 16-byte key file; DRM systems use their own values, such as "com.apple.streamingkeydelivery" for FairPlay. Needs version 5.
KEYFORMATVERSIONSPositive integers separated by /, such as "1" or "1/2"
Default: "1"
NoWhich versions of the key format this tag works with. Needs version 5.

What EXT-X-KEY means

EXT-X-KEY says whether the media segments that follow are encrypted, how, and where a player can get the key to decrypt them. It applies to every segment, and to every initialization section declared by EXT-X-MAP, between it and the next EXT-X-KEY with the same KEYFORMAT, or the end of the playlist. A media playlist with no EXT-X-KEY is not encrypted.

Encryption methods

NONE
The segments are not encrypted. No other attribute may be present.
AES-128
Each whole segment is encrypted with AES using a 128-bit key, in CBC mode with PKCS7 padding. The cipher restarts at each segment, using the IV attribute or the segment's media sequence number as the initialization vector.
SAMPLE-AES
Only the audio and video samples inside each segment are encrypted, while the container stays readable. fMP4 segments use the cbcs scheme of MPEG Common Encryption. DRM systems such as Apple's FairPlay use this method.

The RFC 8216bis draft adds two optional methods, SAMPLE-AES-CTR (the cenc scheme, for fMP4) and AES-256-GCM. Neither is part of RFC 8216.

Where it goes

Media playlists only, before the first segment it applies to. Each new EXT-X-KEY starts a new key period, so playlists that rotate keys contain several. Two or more tags with different KEYFORMAT values may apply to the same segments if they lead to the same key, which is how one stream can serve several DRM systems.

Rules from RFC 8216

Common mistakes

How players treat it

With AES-128 or SAMPLE-AES and the default identity key format, the player requests the key file at URI, which holds 16 raw bytes, and decrypts each segment. Key servers often require the same sign-in, cookies or tokens as the page that shows the video. For DRM key formats, the player hands the request to the platform's content protection system, which on the web works through Encrypted Media Extensions.

Example

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="keys/k1.bin",IV=0x1A2B3C4D5E6F708192A3B4C5D6E7F801
#EXTINF:6.000,
segment0.ts
#EXTINF:6.000,
segment1.ts
#EXT-X-KEY:METHOD=NONE
#EXTINF:6.000,
segment2.ts
#EXT-X-ENDLIST

The first two segments use the AES-128 key at keys/k1.bin, resolved against the playlist's address, while METHOD=NONE marks the third segment as unencrypted.

How m3u8.cloud handles it

Playlists with no EXT-X-KEY, or with METHOD=NONE, download normally. Any other method, such as AES-128, SAMPLE-AES or SAMPLE-AES-CTR, or any KEYFORMAT used for DRM, makes m3u8.cloud stop and explain why instead of downloading.

m3u8.cloud never fetches keys and never decrypts. The relay refuses encrypted playlists too.

Check the tags in any playlist

Open the m3u8 inspector