| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 AesDecryptor::AesDecryptor(DecryptorClient* client) | 128 AesDecryptor::AesDecryptor(DecryptorClient* client) |
| 129 : client_(client) { | 129 : client_(client) { |
| 130 } | 130 } |
| 131 | 131 |
| 132 AesDecryptor::~AesDecryptor() { | 132 AesDecryptor::~AesDecryptor() { |
| 133 STLDeleteValues(&key_map_); | 133 STLDeleteValues(&key_map_); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, | 136 bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, |
| 137 const std::string& type, |
| 137 const uint8* init_data, | 138 const uint8* init_data, |
| 138 int init_data_length) { | 139 int init_data_length) { |
| 139 std::string session_id_string(base::UintToString(next_session_id_++)); | 140 std::string session_id_string(base::UintToString(next_session_id_++)); |
| 140 | 141 |
| 141 // For now, just fire the event with the |init_data| as the request. | 142 // For now, the AesDecryptor does not care about |key_system| and |type|; |
| 143 // just fire the event with the |init_data| as the request. |
| 142 int message_length = init_data_length; | 144 int message_length = init_data_length; |
| 143 scoped_array<uint8> message(new uint8[message_length]); | 145 scoped_array<uint8> message(new uint8[message_length]); |
| 144 memcpy(message.get(), init_data, message_length); | 146 memcpy(message.get(), init_data, message_length); |
| 145 | 147 |
| 146 client_->KeyMessage(key_system, session_id_string, | 148 client_->KeyMessage(key_system, session_id_string, |
| 147 message.Pass(), message_length, ""); | 149 message.Pass(), message_length, ""); |
| 148 return true; | 150 return true; |
| 149 } | 151 } |
| 150 | 152 |
| 151 void AesDecryptor::AddKey(const std::string& key_system, | 153 void AesDecryptor::AddKey(const std::string& key_system, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 bool AesDecryptor::DecryptionKey::Init() { | 303 bool AesDecryptor::DecryptionKey::Init() { |
| 302 CHECK(!secret_.empty()); | 304 CHECK(!secret_.empty()); |
| 303 decryption_key_.reset(crypto::SymmetricKey::Import( | 305 decryption_key_.reset(crypto::SymmetricKey::Import( |
| 304 crypto::SymmetricKey::AES, secret_)); | 306 crypto::SymmetricKey::AES, secret_)); |
| 305 if (!decryption_key_.get()) | 307 if (!decryption_key_.get()) |
| 306 return false; | 308 return false; |
| 307 return true; | 309 return true; |
| 308 } | 310 } |
| 309 | 311 |
| 310 } // namespace media | 312 } // namespace media |
| OLD | NEW |