| Index: media/cdm/json_web_key.h
|
| diff --git a/media/cdm/json_web_key.h b/media/cdm/json_web_key.h
|
| index cb483aeb8bd0af2d6d2e6c119ab63bad40e2af47..af028f2fe24e8d9b3a9d2ba8293627088190a4c6 100644
|
| --- a/media/cdm/json_web_key.h
|
| +++ b/media/cdm/json_web_key.h
|
| @@ -11,21 +11,42 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "media/base/media_export.h"
|
| +#include "media/base/media_keys.h"
|
|
|
| namespace media {
|
|
|
| +// The ClearKey license request format (ref:
|
| +// https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#clear-key)
|
| +// is a JSON object containing the following members:
|
| +// "kids" : An array of key IDs. Each element of the array is the base64url
|
| +// encoding of the octet sequence containing the key ID value.
|
| +// "type" : The requested SessionType.
|
| +// An example:
|
| +// { "kids":["67ef0gd8pvfd0","77ef0gd8pvfd0"], "type":"temporary" }
|
| +
|
| +// The ClearKey license format is a JSON Web Key (JWK) Set containing
|
| +// representation of the symmetric key to be used for decryption.
|
| +// For each JWK in the set, the parameter values are as follows:
|
| +// "kty" (key type) : "oct" (octet sequence)
|
| +// "alg" (algorithm) : "A128KW" (AES key wrap using a 128-bit key)
|
| +// "k" (key value) : The base64url encoding of the octet sequence
|
| +// containing the symmetric key value.
|
| +// "kid" (key ID) : The base64url encoding of the octet sequence
|
| +// containing the key ID value.
|
| +// The JSON object may have an optional "type" member value, which may be
|
| +// any of the SessionType values. If not specified, the default value of
|
| +// "temporary" is used.
|
| // A JSON Web Key Set looks like the following in JSON:
|
| -// { "keys": [ JWK1, JWK2, ... ] }
|
| +// { "keys": [ JWK1, JWK2, ... ], "type":"temporary" }
|
| // A symmetric keys JWK looks like the following in JSON:
|
| // { "kty":"oct",
|
| +// "alg":"A128KW",
|
| // "kid":"AQIDBAUGBwgJCgsMDQ4PEA",
|
| // "k":"FBUWFxgZGhscHR4fICEiIw" }
|
| +
|
| // There may be other properties specified, but they are ignored.
|
| // Ref: http://tools.ietf.org/html/draft-ietf-jose-json-web-key and:
|
| // http://tools.ietf.org/html/draft-jones-jose-json-private-and-symmetric-key
|
| -//
|
| -// For EME WD, both 'kid' and 'k' are base64 encoded strings, without trailing
|
| -// padding.
|
|
|
| // Vector of [key_id, key_value] pairs. Values are raw binary data, stored in
|
| // strings for convenience.
|
| @@ -37,10 +58,27 @@ MEDIA_EXPORT std::string GenerateJWKSet(const uint8* key, int key_length,
|
| const uint8* key_id, int key_id_length);
|
|
|
| // Extracts the JSON Web Keys from a JSON Web Key Set. If |input| looks like
|
| -// a valid JWK Set, then true is returned and |keys| is updated to contain
|
| -// the list of keys found. Otherwise return false.
|
| +// a valid JWK Set, then true is returned and |keys| and |session_type| are
|
| +// updated to contain the values found. Otherwise return false.
|
| MEDIA_EXPORT bool ExtractKeysFromJWKSet(const std::string& jwk_set,
|
| - KeyIdAndKeyPairs* keys);
|
| + KeyIdAndKeyPairs* keys,
|
| + MediaKeys::SessionType* session_type);
|
| +
|
| +// Create a license request message for the |key_id| and |session_type|
|
| +// specified. Currently ClearKey generates a message for each key individually,
|
| +// so no need to take a list of |key_id|'s. |license| is updated to contain the
|
| +// resulting JSON string.
|
| +MEDIA_EXPORT void CreateLicenseRequest(const uint8* key_id,
|
| + int key_id_length,
|
| + MediaKeys::SessionType session_type,
|
| + std::vector<uint8>* license);
|
| +
|
| +// Extract the first key from the license request message. Returns true if
|
| +// |license| is a valid license request and contains at least one key,
|
| +// otherwise false and |first_key| is not touched.
|
| +MEDIA_EXPORT bool ExtractFirstKeyIdFromLicenseRequest(
|
| + const std::vector<uint8>& license,
|
| + std::vector<uint8>* first_key);
|
|
|
| } // namespace media
|
|
|
|
|