SPEKE API v2 - Encryption contract - Secure Packager and Encoder Key Exchange API Specification

SPEKE API v2 - Encryption contract

The encryption contract defines which content keys are protecting which tracks inside a given streamset, based on the tracks characteristics.

Using multiple content keys for different tracks in a streamset, despite being a recommended industry best practice, is not mandatory, but recommended - at least two different content keys, one for audio tracks and one for video tracks. Using a single content key to encrypt multiple tracks is possible but needs to be explicitly signaled in the CPIX document sent by the encryptor to to key provider. Generally speaking, the encryptor always describes precisely how many content keys are required and how they are leveraged to encrypt the various media tracks.

Principles

The encryption contract is located in the <cpix:ContentKeyUsageRuleList> section of the CPIX document. In this section, each content key defined in the <cpix:ContentKeyList> section corresponds to a specific <cpix:ContentKeyUsageRule> element, which shall include:

  • a ContentKeyUsageRule@intendedTrackType attribute that can reference one or more sub-components, separated by the '+' sign if multiple sub-components are used. The value of ContentKeyUsageRule@intendedTrackType shall be unique in an encryption contract, and can not be used in multiple ContentKeyUsageRule elements.

  • one or more <cpix:AudioFilter> or <cpix:VideoFilter> child element, depending on the value of ContentKeyUsageRule@intendedTrackType attribute.

The rules governing this relationship are the following:

  • When all the audio and video tracks of the streamset need to be protected with a unique content key, the string 'ALL' must be used as the ContentKeyUsageRule@intendedTrackType attribute value. Example 1 shows such a use case. In this situation, both a <cpix:AudioFilter /> and a <cpix:VideoFilter /> child elements without any attribute shall be included. Any other combination of <cpix:AudioFilter> and/or <cpix:VideoFilter> elements is invalid in this particular context.

  • For all other use cases, the value of the ContentKeyUsageRule@intendedTrackType attribute can be freely defined, and the number of <cpix:AudioFilter /> and a <cpix:VideoFilter /> child elements must correspond to the number of sub-components aggregated through the '+' sign. Examples 2/3/4/5/6/7/9/10 illustrate this requirement, when a single sub-component is present in the ContentKeyUsageRule@intendedTrackType attribute value. Example 8 illustrate it when multiple sub-components are used: ContentKeyUsageRule@intendedTrackType="SD+HD" is described by two distinct <cpix:VideoFilter> child elements with different attributes values, and ContentKeyUsageRule@intendedTrackType="HDR+HFR+UHD" is described by three distinct <cpix:VideoFilter> child elements with different attributes values.

Filters

CPIX defines multiple filtering elements and attributes, but SPEKE supports only a subset of it. The following table summarizes these differences:

CPIX filter type Overall SPEKE support Filter attributes supported by SPEKE Filter attributes not supported by SPEKE

<cpix:VideoFilter>

Yes

minPixels, maxPixels, hdr, minFps, maxFps (optional attributes)

wcg

<cpix:AudioFilter>

Yes

minChannels, maxChannels (optional attributes)

<cpix:KeyPeriodFilter>

Yes

periodId (mandatory attribute)

<cpix:BitrateFilter>

No

N/A

N/A

<cpix:LabelFilter>

No

N/A

N/A

As per the CPIX specification for VideoFilter, [minPixels, maxPixels] is an all inclusive range in both dimensions, while (minFps, maxFps] is inclusive only for the maxFps dimension. For AudioFilter, [minChannels, maxChannels] is an inclusive range in both dimensions.

Problematic situations

There are situations where the information provided in the encryption contract might be partial, ambiguous or erroneous. In these cases, it is important that the encryptor and the key provider behave appropriately and guarantee a proper protection of the contents. The following table presents the recommended behavior in these situations:

In this situation The encryptor should/shall …​ The key provider should/shall …​

No rule applies to one or more tracks in the streamset (see example 3 below)

The encryptor should look at its configuration (external to the CPIX payload) and verify that the concerned tracks don’t require encryption. If it’s not the expectation, the encryptor should throw an error and stop processing.

Not relevant: the key provider doesn’t have knowledge of the streamset structure.

Multiple rules overlap and suggest multiple content keys to encrypt a specific track

The encryptor should apply the last ContentKeyUsageRule successfully evaluated in the order of the document.

Not relevant: the key provider doesn’t have knowledge of the streamset structure.

The encryption contract changes in a single SPEKE request/response cycle

The encryptor shall raise an exception and stop processing, as the key provider is not responsible for defining the encryption contract.

To prevent this situation to happen in the first place, the key provider must not modify an encryption contract received in the CPIX payload of the SPEKE request.

Malformed encryption contract: intendedTrackType/Filters cardinality constraint exception, unsupported filters or attributes

The encryptor shall raise an exception, stop processing and not send the SPEKE request to the key provider, as it would most likely result in erroneous content protection or leave some tracks unprotected.

The key provider shall raise an exception and return a 'Malformed encryption contract' error.

Well formed encryption contract, but in breach of the DRM security levels constraints: as an example, a single content key being requested to protect both audio tracks and UHD video tracks

If the encryptor has got knowledge of the DRM security levels constraints, it should raise an exception, stop processing and not send the SPEKE request to the key provider, as it would most likely result in erroneous content protection.

The key provider shall raise an exception and return a 'Requested CPIX encryption contract not supported' error.

Missing encryption contract

The encryptor shall not send CPIX documents which don’t contain any VideoFilter or AudioFilter element.

The key provider shall raise an exception and return a 'Missing CPIX encryption contract' error.

Examples of Encryption Contracts

Example 1: one content key for all audio and video tracks

<cpix:ContentKeyUsageRuleList> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="ALL"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> <cpix:VideoFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 2: one content key for all video tracks, one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="VIDEO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter /> </cpix:ContentKeyUsageRule> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 3: one content key for all video tracks, unencrypted audio tracks

<cpix:ContentKeyUsageRuleList> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="VIDEO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 4: multiple content keys for different video tracks (SD/HD), one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for SD video tracks (up to 1024x576) --> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="SD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter maxPixels="589824" /> </cpix:ContentKeyUsageRule> <!-- Rule for HD video tracks (more than 1024x576) --> <cpix:ContentKeyUsageRule kid="37e3de05-9a3b-4c69-8970-63c17a95e0b7" intendedTrackType="HD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="589825" /> </cpix:ContentKeyUsageRule> <!-- Rule for all audio tracks --> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 5: multiple content keys for different video tracks (SD/HD/UHD), one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for SD video tracks (up to 1024x576) --> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="SD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter maxPixels="589824" /> </cpix:ContentKeyUsageRule> <!-- Rule for HD video tracks (more than 1024x576, up to 1920x1080) --> <cpix:ContentKeyUsageRule kid="37e3de05-9a3b-4c69-8970-63c17a95e0b7" intendedTrackType="HD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="589825" maxPixels="2073600" /> </cpix:ContentKeyUsageRule> <!-- Rule for UHD video tracks (more than 1920x1080) --> <cpix:ContentKeyUsageRule kid="75c6fa78-8b5d-6d75-9653-26f41b78d1a3" intendedTrackType="UHD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="2073601" /> </cpix:ContentKeyUsageRule> <!-- Rule for all audio tracks --> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 6: multiple content keys for different video tracks (SD/HD/UHD1/UHD2), one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for SD video tracks (up to 1024x576) --> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="SD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter maxPixels="589824" /> </cpix:ContentKeyUsageRule> <!-- Rule for HD video tracks (more than 1024x576, up to 1920x1080) --> <cpix:ContentKeyUsageRule kid="37e3de05-9a3b-4c69-8970-63c17a95e0b7" intendedTrackType="HD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="589825" maxPixels="2073600" /> </cpix:ContentKeyUsageRule> <!-- Rule for UHD1 video tracks (more than 1920x1080, up to 4096x2160) --> <cpix:ContentKeyUsageRule kid="75c6fa78-8b5d-6d75-9653-26f41b78d1a3" intendedTrackType="UHD1"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="2073601" maxPixels="8847360" /> </cpix:ContentKeyUsageRule> <!-- Rule for UHD2 video tracks (more than 4096x2160) --> <cpix:ContentKeyUsageRule kid="63d2ec36-6b7c-9f34-4546-97d01f36f7c5" intendedTrackType="UHD2"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="8847361" /> </cpix:ContentKeyUsageRule> <!-- Rule for all audio tracks --> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 7: multiple content keys for different video tracks (SD/HD1/HD2/UHD1/UHD2), one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for SD video tracks (up to 1024x576) --> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="SD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter maxPixels="589824" /> </cpix:ContentKeyUsageRule> <!-- Rule for HD1 video tracks (more than 1024x576, up to 1280x720) --> <cpix:ContentKeyUsageRule kid="37e3de05-9a3b-4c69-8970-63c17a95e0b7" intendedTrackType="HD1"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="589825" maxPixels="921600" /> </cpix:ContentKeyUsageRule> <!-- Rule for HD2 video tracks (more than 1280x720, up to 1920x1080) --> <cpix:ContentKeyUsageRule kid="cda406d8-9d87-4f76-92da-31110e756176" intendedTrackType="HD2"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="921601" maxPixels="2073600" /> </cpix:ContentKeyUsageRule> <!-- Rule for UHD1 video tracks (more than 1920x1080, up to 4096x2160) --> <cpix:ContentKeyUsageRule kid="75c6fa78-8b5d-6d75-9653-26f41b78d1a3" intendedTrackType="UHD1"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="2073601" maxPixels="8847360" /> </cpix:ContentKeyUsageRule> <!-- Rule for UHD2 video tracks (more than 4096x2160) --> <cpix:ContentKeyUsageRule kid="63d2ec36-6b7c-9f34-4546-97d01f36f7c5" intendedTrackType="UHD2"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter minPixels="8847361" /> </cpix:ContentKeyUsageRule> <!-- Rule for all audio tracks --> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 8: multiple content keys for different video tracks (based on multiple attributes types), one content key for all audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for SD and HD video tracks--> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="SD+HD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter maxPixels="442368" maxFps="30" hdr="false"/> <cpix:VideoFilter minPixels="442369" maxPixels="2073600" maxFps="30" hdr="false"/> </cpix:ContentKeyUsageRule> <!-- Rule for HDR, HFR and UHD video tracks--> <cpix:ContentKeyUsageRule kid="37e3de05-9a3b-4c69-8970-63c17a95e0b7" intendedTrackType="HDR+HFR+UHD"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter hdr="true" /> <cpix:VideoFilter minFps="30" /> <cpix:VideoFilter minPixels="20736001" /> </cpix:ContentKeyUsageRule> <!-- Rule for all audio tracks--> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter /> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 9: one content keys for all video tracks, multiple content keys for stereo and multichannel audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for video tracks--> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="VIDEO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter /> </cpix:ContentKeyUsageRule> <!-- Rule for stereo audio tracks--> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="STEREO_AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter maxChannels="2"/> </cpix:ContentKeyUsageRule> <!-- Rule for multichannel audio tracks--> <cpix:ContentKeyUsageRule kid="7ae8e96f-309e-42c3-a510-24023d923373" intendedTrackType="MULTICHANNEL_AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <AudioFilter minChannels="3"/> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>

Example 10: one content keys for all video tracks, multiple content keys for stereo and two types of multichannel audio tracks

<cpix:ContentKeyUsageRuleList> <!-- Rule for video tracks--> <cpix:ContentKeyUsageRule kid="98ee5596-cd3e-a20d-163a-e382420c6eff" intendedTrackType="VIDEO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:VideoFilter /> </cpix:ContentKeyUsageRule> <!-- Rule for stereo audio tracks--> <cpix:ContentKeyUsageRule kid="53abdba2-f210-43cb-bc90-f18f9a890a02" intendedTrackType="STEREO_AUDIO"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter maxChannels="2"/> </cpix:ContentKeyUsageRule> <!-- Rule for multichannel audio tracks (3 to 6 channels)--> <cpix:ContentKeyUsageRule kid="7ae8e96f-309e-42c3-a510-24023d923373" intendedTrackType="MULTICHANNEL_AUDIO_3_6"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter minChannels="3" maxChannels="6"/> </cpix:ContentKeyUsageRule> <!-- Rule for multichannel audio tracks (7 channels and more)--> <cpix:ContentKeyUsageRule kid="81eb3761-55ff-4d22-a31d-94f01bbfd8ba" intendedTrackType="MULTICHANNEL_AUDIO_7"> <cpix:KeyPeriodFilter periodId="keyPeriod_0909829f-40ff-4625-90fa-75da3e53278f"/> <cpix:AudioFilter minChannels="7"/> </cpix:ContentKeyUsageRule> </cpix:ContentKeyUsageRuleList>