| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/crypto/aes_decryptor.h" | 5 #include "media/crypto/aes_decryptor.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 scoped_refptr<DecoderBuffer> output = DecoderBuffer::CopyFrom( | 119 scoped_refptr<DecoderBuffer> output = DecoderBuffer::CopyFrom( |
| 120 reinterpret_cast<const uint8*>(sample), sample_size); | 120 reinterpret_cast<const uint8*>(sample), sample_size); |
| 121 CopySubsamples(subsamples, kDstContainsClearBytes, | 121 CopySubsamples(subsamples, kDstContainsClearBytes, |
| 122 reinterpret_cast<const uint8*>(decrypted_text.data()), | 122 reinterpret_cast<const uint8*>(decrypted_text.data()), |
| 123 output->GetWritableData()); | 123 output->GetWritableData()); |
| 124 return output; | 124 return output; |
| 125 } | 125 } |
| 126 | 126 |
| 127 AesDecryptor::AesDecryptor(const KeyAddedCB& key_added_cb, | 127 AesDecryptor::AesDecryptor(const KeyAddedCB& key_added_cb, |
| 128 const KeyErrorCB& key_error_cb, | 128 const KeyErrorCB& key_error_cb, |
| 129 const KeyMessageCB& key_message_cb, | 129 const KeyMessageCB& key_message_cb) |
| 130 const NeedKeyCB& need_key_cb) | |
| 131 : key_added_cb_(key_added_cb), | 130 : key_added_cb_(key_added_cb), |
| 132 key_error_cb_(key_error_cb), | 131 key_error_cb_(key_error_cb), |
| 133 key_message_cb_(key_message_cb), | 132 key_message_cb_(key_message_cb) { |
| 134 need_key_cb_(need_key_cb) { | |
| 135 } | 133 } |
| 136 | 134 |
| 137 AesDecryptor::~AesDecryptor() { | 135 AesDecryptor::~AesDecryptor() { |
| 138 STLDeleteValues(&key_map_); | 136 STLDeleteValues(&key_map_); |
| 139 } | 137 } |
| 140 | 138 |
| 141 bool AesDecryptor::GenerateKeyRequest(const std::string& type, | 139 bool AesDecryptor::GenerateKeyRequest(const std::string& type, |
| 142 const uint8* init_data, | 140 const uint8* init_data, |
| 143 int init_data_length) { | 141 int init_data_length) { |
| 144 std::string session_id_string(base::UintToString(next_session_id_++)); | 142 std::string session_id_string(base::UintToString(next_session_id_++)); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 bool AesDecryptor::DecryptionKey::Init() { | 327 bool AesDecryptor::DecryptionKey::Init() { |
| 330 CHECK(!secret_.empty()); | 328 CHECK(!secret_.empty()); |
| 331 decryption_key_.reset(crypto::SymmetricKey::Import( | 329 decryption_key_.reset(crypto::SymmetricKey::Import( |
| 332 crypto::SymmetricKey::AES, secret_)); | 330 crypto::SymmetricKey::AES, secret_)); |
| 333 if (!decryption_key_) | 331 if (!decryption_key_) |
| 334 return false; | 332 return false; |
| 335 return true; | 333 return true; |
| 336 } | 334 } |
| 337 | 335 |
| 338 } // namespace media | 336 } // namespace media |
| OLD | NEW |