This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24027 - Define a generic Initialization Data solution for ISO Base Media File Format and/or Common Encryption (will be used by Clear Key)
Summary: Define a generic Initialization Data solution for ISO Base Media File Format ...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: Encrypted Media Extensions (show other bugs)
Version: unspecified
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: David Dorwin
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on: 17673
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-07 01:19 UTC by David Dorwin
Modified: 2014-06-12 16:41 UTC (History)
12 users (show)

See Also:


Attachments

Description David Dorwin 2013-12-07 01:19:57 UTC
[This issue was broken out from bug 17673.]

Bug 17673 is moving in a direction that uses PSSH boxes for Common Encryption (CENC). As a result, it will still be unclear how to implement Clear Key with BMFF/CENC even after that bug is resolved. Since Clear Key is only defined within the context of the spec, we need to define how to implement Clear Key with ISO BMFF and/or CENC.

In addition, we could improve interop by defining a default/generic solution that any key system can use.

Preferably, the eventual solution should work for all ISO Base Media File Format protection systems (not just CENC), though it's possible that turns out not to be ideal.

A CENC-specific solution would involve a specifying a system ID and PSSH format. We could recommend including it in all files, and Clear Key as well as any other key system could use it. Even key systems that support their own system ID could support it, especially if their own ID is not present. This would allow legacy devices that require specific PSSH boxes (mentioned in bug 17673) to be supported while moving toward a more interoperable future.
Comment 1 Adrian Bateman [MSFT] 2013-12-13 00:27:16 UTC
Most likely this bug boils down to defining the shape of PSSH boxes for ClearKey and defining the ClearKey identifier for CENC.

We need to wait for bug 17673 to be finished before we can complete this.
Comment 2 Pavel Pergamenshchik 2014-01-28 00:32:34 UTC
I propose this format.

SystemID value: 58147ec8-0423-4659-92e6-f52c5ce8c3cc (represented here in network byte order)
Contents of Data: 128-bit key ID, with no other information

Example in C-encoded hex, for a KID having the ASCII value "ClearKeyTestKID\0":

static const char* kClearKeyPSSH = {
    0x00, 0x00, 0x00, 0x30, 0x70, 0x73, 0x73, 0x68, // BMFF box header
    0x00, 0x00, 0x00, 0x00,                         // Full box header
    0x58, 0x14, 0x7e, 0xc8, 0x04, 0x23, 0x46, 0x59, // SystemID
    0x92, 0xe6, 0xf5, 0x2c, 0x5c, 0xe8, 0xc3, 0xcc,
    0x00, 0x00, 0x00, 0x10,                         // Size of Data (KID)
    0x43, 0x6c, 0x65, 0x61, 0x72, 0x4b, 0x65, 0x79, // Data (KID):
    0x54, 0x65, 0x73, 0x74, 0x4b, 0x49, 0x44, 0x00  // "ClearKeyTestKID\0"
};
Comment 3 David Dorwin 2014-01-28 04:32:59 UTC
I like this simple format for the Data portion of the PSSH box. I filed bug 24419 to define a license request format for Clear Key so apps don't need to parse a PSSH box.

One question for the group: Does it make sense to support specifying multiple key IDs in the PSSH or should we just rely on the server to translate one to N (i.e audio and video keys)?
I believe some commercial protection systems do former; are there any that do the latter? The Clear Key license format will support multiple key ID-key pairs. Clear Key and this PSSH format should be capable of anything (reasonable within the context of EME/browsers) that commercial key systems support.


This thread questioning the need for system-specific PSSH boxes includes some analysis of some existing PSSH formats:
* http://lists.w3.org/Archives/Public/public-html-media/2013May/0017.html
* http://lists.w3.org/Archives/Public/public-html-media/2013May/0018.html
* http://lists.w3.org/Archives/Public/public-html-media/2013May/0025.html
Comment 4 Mark Watson 2014-01-28 16:13:33 UTC
I think the generic PSSH format should support multiple key ids.

Also, we have found it very useful to include a hash or MAC of the content key, such that the client can easily determine if it has the right key, when it has it.

I can provide a concrete proposal if people think this is a good idea.
Comment 5 David Dorwin 2014-02-13 19:32:28 UTC
I have concerns about adding/requiring a hash. Some system designs might wish to generate the PSSH in an area that does not have access to the actual key. This might be especially true if the PSSH is generated on the frontend or in the application.

It's also unclear how the CDM would use the hash. There is nothing in EME that requires that the key(s) be provided in the next response or all at once, though I guess some key systems might enforce that. There could also be ambiguity/complexity in dealing with cases involving multiple keys (request or license), especially when the number of keys in the license do not match the number of key IDs/hashes in the license request.


Assigning to Mark to make a proposal.
Comment 6 Mark Watson 2014-02-18 16:24:53 UTC
My proposal, in outline, would be that the PSSH box contain
- one or more 16-byte Key Ids
- for each Key Id, optionally, a 16-byte MAC of the Key Id, calculated as the HMAC-SHA256 of the Key Id using the Content Key as the key for the HMAC calculation

The purpose of the MAC is to enable the CDM to validate the key that it receives for a given Key Id immediately that it receives it, before using it for decryption.

The MAC can be optional, so that service providers can decide whether providing it (with the consequence that the content keys must be available to the packaging system that generated this box) is worthwhile. I would expect, though, that the PSSH is usually constructed when the file is encrypted - since the form of the encryption is very ISO BMFF-specific - and s the encryption key(s) would be available.
Comment 7 Joe Steele 2014-02-18 23:19:35 UTC
I think you mean a 32 byte MAC of the KeyID right? 

This looks like a good format. And many (most?) OTT providers should be able to generate this either at packaging time or at license generation time without trouble.
Comment 8 David Dorwin 2014-02-19 22:47:27 UTC
(In reply to Mark Watson from comment #6)
> My proposal, in outline, would be that the PSSH box contain
> - one or more 16-byte Key Ids
> - for each Key Id, optionally, a 16-byte MAC of the Key Id, calculated as
> the HMAC-SHA256 of the Key Id using the Content Key as the key for the HMAC
> calculation

This sounds fine. The question is how do we specify the count (easier) and whether to expect the MAC.

> I would
> expect, though, that the PSSH is usually constructed when the file is
> encrypted - since the form of the encryption is very ISO BMFF-specific - and
> s the encryption key(s) would be available.

To clarify, the first paragraph of comment #5 was referring to also being able to generate the PSSH to provide to createSession(). I agree that the encryption key should always be available during packaging.


(In reply to Joe Steele from comment #7)
> This looks like a good format. And many (most?) OTT providers should be able
> to generate this either at packaging time or at license generation time
> without trouble.

Yes, but it's not needed at license generation time - the license contains the key but not the Initialization Data. On the other hand, an application might want to generate valid Initalization Data at license request generation time (createSession()).
Comment 9 Joe Steele 2014-02-19 23:47:39 UTC
(In reply to David Dorwin from comment #8)
> (In reply to Joe Steele from comment #7)
> > This looks like a good format. And many (most?) OTT providers should be able
> > to generate this either at packaging time or at license generation time
> > without trouble.
> 
> Yes, but it's not needed at license generation time - the license contains
> the key but not the Initialization Data. On the other hand, an application
> might want to generate valid Initalization Data at license request
> generation time (createSession()).

You are right. I guess I was thinking of generating it on the server as well to confirm the key prior to sending to the client. But I don't believe we send this MAC in the key request for ClearKey do we? So it must be validated on the client side.
Comment 10 David Dorwin 2014-02-19 23:51:27 UTC
(In reply to Joe Steele from comment #9)
> (In reply to David Dorwin from comment #8)
> > (In reply to Joe Steele from comment #7)
> > > This looks like a good format. And many (most?) OTT providers should be able
> > > to generate this either at packaging time or at license generation time
> > > without trouble.
> > 
> > Yes, but it's not needed at license generation time - the license contains
> > the key but not the Initialization Data. On the other hand, an application
> > might want to generate valid Initalization Data at license request
> > generation time (createSession()).
> 
> You are right. I guess I was thinking of generating it on the server as well
> to confirm the key prior to sending to the client. But I don't believe we
> send this MAC in the key request for ClearKey do we? So it must be validated
> on the client side.

My understanding is that the main purpose is for the CDM to use the MAC to verify the contents of the license are what it needs. It's still unclear how the CDM would do this and what it would report should the verification fail.

Clear Key does not use the MAC. This would only apply to other key systems that support this common PSSH format.
Comment 11 Mark Watson 2014-03-04 16:50:59 UTC
For the question of what to do if the MAC doesn't validate, this should be the same as any other fatal problem with the license. Don't we just fire a keyerror event ?
Comment 12 Joe Steele 2014-03-17 21:29:48 UTC
I think a key error should be fired in this case. We don't have a good name right now - but I think it would be good to distinguish this from an error resulting from a failed decryption. This would aid debugging. 

For example:
  MEDIA_KEY_ERROR_BAD_KEY means the MAC did not validate (for this key system)
  MEDIA_KEY_ERROR_BAD_DECRYPT means the content was garbled somehow
Comment 13 Mark Watson 2014-03-18 14:55:00 UTC
Concretely, we could use the new version of the PSSH box, defined as follows:

aligned(8) class ProtectionSystemSpecificHeaderBox extends FullBox(‘pssh’, version, flags=0) 
{  
	unsigned int(8)[16]   SystemID;
	if (version > 0) 
 	{ 
  		unsigned int(32)    KID_count;   
  		{ 
   			unsigned int(8)[16]  KID; 
  		} [KID_count]; 
 	} 
 	unsigned int(32)    DataSize;  
 	unsigned int(8)[DataSize] Data;  
}

For the clear-key case, the Data would be defined to contain

{
	unsigned int(8)[16]  keyMac;
} [KID_count];

or Data may be empty if the MACs are not provided.

For each key,

keyMac = HMAC-SHA256( CK, KID ), where CK is the content key with key id KID.
Comment 14 David Dorwin 2014-04-01 01:12:20 UTC
(In reply to Mark Watson from comment #13)
The KID_count and KID portion apparently come from a draft of the second edition of the CENC spec. This is a dependency we would have to consider. Also, it's unclear if this is actually the intended usage for these values.
Comment 15 Mark Watson 2014-04-28 22:40:15 UTC
(In reply to David Dorwin from comment #14)
> (In reply to Mark Watson from comment #13)
> The KID_count and KID portion apparently come from a draft of the second
> edition of the CENC spec. This is a dependency we would have to consider.
> Also, it's unclear if this is actually the intended usage for these values.

Per an email discussion with Kilroy Hughes, the intended usage of the KID_count and KIDs is to indicate in a DRM-agnostic way the KIDs of the keys that are described by this PSSH. This enables DRM-independent de- or re-fragmentation of the file.

The same KIDs would usually also be specified in the DRM-specific contents of the PSSH box.
Comment 16 Joe Steele 2014-04-28 22:51:52 UTC
(In reply to Mark Watson from comment #15)
> (In reply to David Dorwin from comment #14)
> > (In reply to Mark Watson from comment #13)
> > The KID_count and KID portion apparently come from a draft of the second
> > edition of the CENC spec. This is a dependency we would have to consider.
> > Also, it's unclear if this is actually the intended usage for these values.
> 
> Per an email discussion with Kilroy Hughes, the intended usage of the
> KID_count and KIDs is to indicate in a DRM-agnostic way the KIDs of the keys
> that are described by this PSSH. This enables DRM-independent de- or
> re-fragmentation of the file.
> 
> The same KIDs would usually also be specified in the DRM-specific contents
> of the PSSH box.

This is inline with Adobe's usage of KID and KID_count.
Comment 17 David Dorwin 2014-05-05 23:42:24 UTC
Using the KID array sounds fine. I think we should hold off on defining the Data until we have more implementation experience. That will allow Clear Key-compatible content to be created without worrying about later incompatibilities.

Mark, will you add this modified proposal to https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/cenc-format.html ?
Comment 18 David Dorwin 2014-05-14 02:27:23 UTC
The proposed specification is as follows:

SystemID: 1077efec-c0b2-4d02-ace3-3c1e52e2fb4b.
version: 1 or higher (as appropriate)
KID & KID_count: the key IDs represented by the PSSH box (i.e. those used by the moov/moof.
Data and DataSize: Reserved for future use/specification. DataSize must be 0 for now.
Comment 19 David Dorwin 2014-05-16 01:31:06 UTC
The text should also note that Clear Key, which is defined in the main spec, uses this SystemID and format.
Comment 20 David Dorwin 2014-05-19 19:03:45 UTC
Implemented in https://dvcs.w3.org/hg/html-media/rev/3d777e556c04
Comment 21 David Dorwin 2014-06-02 23:18:16 UTC
I added an example PSSH box in https://dvcs.w3.org/hg/html-media/rev/f1578a4341e7.
Comment 22 Mark Watson 2014-06-12 16:41:09 UTC
I implemented Postel's rule for the Data field of the PSSH in https://dvcs.w3.org/hg/html-media/rev/b7426450ef2b