| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 | 189 |
| 190 AesDecryptor::AesDecryptor(DecryptorClient* client) | 190 AesDecryptor::AesDecryptor(DecryptorClient* client) |
| 191 : client_(client) { | 191 : client_(client) { |
| 192 } | 192 } |
| 193 | 193 |
| 194 AesDecryptor::~AesDecryptor() { | 194 AesDecryptor::~AesDecryptor() { |
| 195 STLDeleteValues(&key_map_); | 195 STLDeleteValues(&key_map_); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void AesDecryptor::GenerateKeyRequest(const std::string& key_system, | 198 bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, |
| 199 const uint8* init_data, | 199 const uint8* init_data, |
| 200 int init_data_length) { | 200 int init_data_length) { |
| 201 std::string session_id_string(base::UintToString(next_session_id_++)); | 201 std::string session_id_string(base::UintToString(next_session_id_++)); |
| 202 | 202 |
| 203 // For now, just fire the event with the |init_data| as the request. | 203 // For now, just fire the event with the |init_data| as the request. |
| 204 int message_length = init_data_length; | 204 int message_length = init_data_length; |
| 205 scoped_array<uint8> message(new uint8[message_length]); | 205 scoped_array<uint8> message(new uint8[message_length]); |
| 206 memcpy(message.get(), init_data, message_length); | 206 memcpy(message.get(), init_data, message_length); |
| 207 | 207 |
| 208 client_->KeyMessage(key_system, session_id_string, | 208 client_->KeyMessage(key_system, session_id_string, |
| 209 message.Pass(), message_length, ""); | 209 message.Pass(), message_length, ""); |
| 210 return true; |
| 210 } | 211 } |
| 211 | 212 |
| 212 void AesDecryptor::AddKey(const std::string& key_system, | 213 void AesDecryptor::AddKey(const std::string& key_system, |
| 213 const uint8* key, | 214 const uint8* key, |
| 214 int key_length, | 215 int key_length, |
| 215 const uint8* init_data, | 216 const uint8* init_data, |
| 216 int init_data_length, | 217 int init_data_length, |
| 217 const std::string& session_id) { | 218 const std::string& session_id) { |
| 218 CHECK(key); | 219 CHECK(key); |
| 219 CHECK_GT(key_length, 0); | 220 CHECK_GT(key_length, 0); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return false; | 359 return false; |
| 359 | 360 |
| 360 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize); | 361 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize); |
| 361 if (hmac_key_.empty()) | 362 if (hmac_key_.empty()) |
| 362 return false; | 363 return false; |
| 363 | 364 |
| 364 return true; | 365 return true; |
| 365 } | 366 } |
| 366 | 367 |
| 367 } // namespace media | 368 } // namespace media |
| OLD | NEW |