• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef MEDIA_CDM_JSON_WEB_KEY_H_
6 #define MEDIA_CDM_JSON_WEB_KEY_H_
7 
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 #include "base/basictypes.h"
13 #include "media/base/media_export.h"
14 
15 namespace media {
16 
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
26 //
27 // For EME WD, both 'kid' and 'k' are base64 encoded strings, without trailing
28 // padding.
29 
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;
34 
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);
38 
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);
44 
45 }  // namespace media
46 
47 #endif  // MEDIA_CDM_JSON_WEB_KEY_H_
48