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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 std::string& type, |
138 const uint8* init_data, | 138 const uint8* init_data, |
139 int init_data_length) { | 139 int init_data_length) { |
140 std::string session_id_string(base::UintToString(next_session_id_++)); | 140 std::string session_id_string(base::UintToString(next_session_id_++)); |
141 | 141 |
| 142 if (!init_data || !init_data_length) { |
| 143 DVLOG(1) << "init_data required to generate a key request."; |
| 144 return false; |
| 145 } |
| 146 |
142 // For now, the AesDecryptor does not care about |key_system| and |type|; | 147 // For now, the AesDecryptor does not care about |key_system| and |type|; |
143 // just fire the event with the |init_data| as the request. | 148 // just fire the event with the |init_data| as the request. |
144 int message_length = init_data_length; | 149 int message_length = init_data_length; |
145 scoped_array<uint8> message(new uint8[message_length]); | 150 scoped_array<uint8> message(new uint8[message_length]); |
146 memcpy(message.get(), init_data, message_length); | 151 memcpy(message.get(), init_data, message_length); |
147 | 152 |
148 client_->KeyMessage(key_system, session_id_string, | 153 client_->KeyMessage(key_system, session_id_string, |
149 message.Pass(), message_length, ""); | 154 message.Pass(), message_length, ""); |
150 return true; | 155 return true; |
151 } | 156 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 bool AesDecryptor::DecryptionKey::Init() { | 327 bool AesDecryptor::DecryptionKey::Init() { |
323 CHECK(!secret_.empty()); | 328 CHECK(!secret_.empty()); |
324 decryption_key_.reset(crypto::SymmetricKey::Import( | 329 decryption_key_.reset(crypto::SymmetricKey::Import( |
325 crypto::SymmetricKey::AES, secret_)); | 330 crypto::SymmetricKey::AES, secret_)); |
326 if (!decryption_key_.get()) | 331 if (!decryption_key_.get()) |
327 return false; | 332 return false; |
328 return true; | 333 return true; |
329 } | 334 } |
330 | 335 |
331 } // namespace media | 336 } // namespace media |
OLD | NEW |