OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/cdm/json_web_key.h" | 5 #include "media/cdm/json_web_key.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base64url.h" | 9 #include "base/base64url.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 base::StringPiece(reinterpret_cast<const char*>(key), key_length), | 56 base::StringPiece(reinterpret_cast<const char*>(key), key_length), |
57 base::Base64UrlEncodePolicy::OMIT_PADDING, &key_string); | 57 base::Base64UrlEncodePolicy::OMIT_PADDING, &key_string); |
58 base::Base64UrlEncode( | 58 base::Base64UrlEncode( |
59 base::StringPiece(reinterpret_cast<const char*>(key_id), key_id_length), | 59 base::StringPiece(reinterpret_cast<const char*>(key_id), key_id_length), |
60 base::Base64UrlEncodePolicy::OMIT_PADDING, &key_id_string); | 60 base::Base64UrlEncodePolicy::OMIT_PADDING, &key_id_string); |
61 | 61 |
62 scoped_ptr<base::DictionaryValue> jwk(new base::DictionaryValue()); | 62 scoped_ptr<base::DictionaryValue> jwk(new base::DictionaryValue()); |
63 jwk->SetString(kKeyTypeTag, kKeyTypeOct); | 63 jwk->SetString(kKeyTypeTag, kKeyTypeOct); |
64 jwk->SetString(kKeyTag, key_string); | 64 jwk->SetString(kKeyTag, key_string); |
65 jwk->SetString(kKeyIdTag, key_id_string); | 65 jwk->SetString(kKeyIdTag, key_id_string); |
66 return jwk.Pass(); | 66 return jwk; |
67 } | 67 } |
68 | 68 |
69 std::string GenerateJWKSet(const uint8_t* key, | 69 std::string GenerateJWKSet(const uint8_t* key, |
70 int key_length, | 70 int key_length, |
71 const uint8_t* key_id, | 71 const uint8_t* key_id, |
72 int key_id_length) { | 72 int key_id_length) { |
73 // Create the JWK, and wrap it into a JWK Set. | 73 // Create the JWK, and wrap it into a JWK Set. |
74 scoped_ptr<base::ListValue> list(new base::ListValue()); | 74 scoped_ptr<base::ListValue> list(new base::ListValue()); |
75 list->Append( | 75 list->Append( |
76 CreateJSONDictionary(key, key_length, key_id, key_id_length).release()); | 76 CreateJSONDictionary(key, key_length, key_id, key_id_length).release()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 DVLOG(1) << "Invalid '" << kKeyIdsTag << "' value: " << encoded_key; | 408 DVLOG(1) << "Invalid '" << kKeyIdsTag << "' value: " << encoded_key; |
409 return false; | 409 return false; |
410 } | 410 } |
411 | 411 |
412 std::vector<uint8_t> result(decoded_string.begin(), decoded_string.end()); | 412 std::vector<uint8_t> result(decoded_string.begin(), decoded_string.end()); |
413 first_key->swap(result); | 413 first_key->swap(result); |
414 return true; | 414 return true; |
415 } | 415 } |
416 | 416 |
417 } // namespace media | 417 } // namespace media |
OLD | NEW |