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/aes_decryptor.h" | 5 #include "media/cdm/aes_decryptor.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return; | 286 return; |
287 } | 287 } |
288 | 288 |
289 std::string key_string(reinterpret_cast<const char*>(response), | 289 std::string key_string(reinterpret_cast<const char*>(response), |
290 response_length); | 290 response_length); |
291 | 291 |
292 KeyIdAndKeyPairs keys; | 292 KeyIdAndKeyPairs keys; |
293 SessionType session_type = MediaKeys::TEMPORARY_SESSION; | 293 SessionType session_type = MediaKeys::TEMPORARY_SESSION; |
294 if (!ExtractKeysFromJWKSet(key_string, &keys, &session_type)) { | 294 if (!ExtractKeysFromJWKSet(key_string, &keys, &session_type)) { |
295 promise->reject( | 295 promise->reject( |
296 INVALID_ACCESS_ERROR, 0, "response is not a valid JSON Web Key Set."); | 296 INVALID_ACCESS_ERROR, 0, "Response is not a valid JSON Web Key Set."); |
297 return; | 297 return; |
298 } | 298 } |
299 | 299 |
300 // Make sure that at least one key was extracted. | 300 // Make sure that at least one key was extracted. |
301 if (keys.empty()) { | 301 if (keys.empty()) { |
302 promise->reject( | 302 promise->reject( |
303 INVALID_ACCESS_ERROR, 0, "response does not contain any keys."); | 303 INVALID_ACCESS_ERROR, 0, "Response does not contain any keys."); |
304 return; | 304 return; |
305 } | 305 } |
306 | 306 |
307 for (KeyIdAndKeyPairs::iterator it = keys.begin(); it != keys.end(); ++it) { | 307 for (KeyIdAndKeyPairs::iterator it = keys.begin(); it != keys.end(); ++it) { |
308 if (it->second.length() != | 308 if (it->second.length() != |
309 static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) { | 309 static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) { |
310 DVLOG(1) << "Invalid key length: " << key_string.length(); | 310 DVLOG(1) << "Invalid key length: " << it->second.length(); |
311 promise->reject(INVALID_ACCESS_ERROR, 0, "Invalid key length."); | 311 promise->reject(INVALID_ACCESS_ERROR, 0, "Invalid key length."); |
312 return; | 312 return; |
313 } | 313 } |
314 if (!AddDecryptionKey(web_session_id, it->first, it->second)) { | 314 if (!AddDecryptionKey(web_session_id, it->first, it->second)) { |
315 promise->reject(INVALID_ACCESS_ERROR, 0, "Unable to add key."); | 315 promise->reject(INVALID_ACCESS_ERROR, 0, "Unable to add key."); |
316 return; | 316 return; |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 { | 320 { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 bool AesDecryptor::DecryptionKey::Init() { | 531 bool AesDecryptor::DecryptionKey::Init() { |
532 CHECK(!secret_.empty()); | 532 CHECK(!secret_.empty()); |
533 decryption_key_.reset(crypto::SymmetricKey::Import( | 533 decryption_key_.reset(crypto::SymmetricKey::Import( |
534 crypto::SymmetricKey::AES, secret_)); | 534 crypto::SymmetricKey::AES, secret_)); |
535 if (!decryption_key_) | 535 if (!decryption_key_) |
536 return false; | 536 return false; |
537 return true; | 537 return true; |
538 } | 538 } |
539 | 539 |
540 } // namespace media | 540 } // namespace media |
OLD | NEW |