Added grv@ and dvh@ as owners of developer private API.
[chromium-blink-merge.git] / media / cdm / json_web_key.h
blobcb483aeb8bd0af2d6d2e6c119ab63bad40e2af47
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CDM_JSON_WEB_KEY_H_
6 #define MEDIA_CDM_JSON_WEB_KEY_H_
8 #include <string>
9 #include <utility>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "media/base/media_export.h"
15 namespace media {
17 // A JSON Web Key Set looks like the following in JSON:
18 // { "keys": [ JWK1, JWK2, ... ] }
19 // A symmetric keys JWK looks like the following in JSON:
20 // { "kty":"oct",
21 // "kid":"AQIDBAUGBwgJCgsMDQ4PEA",
22 // "k":"FBUWFxgZGhscHR4fICEiIw" }
23 // There may be other properties specified, but they are ignored.
24 // Ref: http://tools.ietf.org/html/draft-ietf-jose-json-web-key and:
25 // http://tools.ietf.org/html/draft-jones-jose-json-private-and-symmetric-key
27 // For EME WD, both 'kid' and 'k' are base64 encoded strings, without trailing
28 // padding.
30 // Vector of [key_id, key_value] pairs. Values are raw binary data, stored in
31 // strings for convenience.
32 typedef std::pair<std::string, std::string> KeyIdAndKeyPair;
33 typedef std::vector<KeyIdAndKeyPair> KeyIdAndKeyPairs;
35 // Converts a single |key|, |key_id| pair to a JSON Web Key Set.
36 MEDIA_EXPORT std::string GenerateJWKSet(const uint8* key, int key_length,
37 const uint8* key_id, int key_id_length);
39 // Extracts the JSON Web Keys from a JSON Web Key Set. If |input| looks like
40 // a valid JWK Set, then true is returned and |keys| is updated to contain
41 // the list of keys found. Otherwise return false.
42 MEDIA_EXPORT bool ExtractKeysFromJWKSet(const std::string& jwk_set,
43 KeyIdAndKeyPairs* keys);
45 } // namespace media
47 #endif // MEDIA_CDM_JSON_WEB_KEY_H_