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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "crypto/encryptor.h" | 10 #include "crypto/encryptor.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 DecryptionKey* key = NULL; | 229 DecryptionKey* key = NULL; |
230 { | 230 { |
231 base::AutoLock auto_lock(key_map_lock_); | 231 base::AutoLock auto_lock(key_map_lock_); |
232 KeyMap::const_iterator found = key_map_.find(key_id_string); | 232 KeyMap::const_iterator found = key_map_.find(key_id_string); |
233 if (found != key_map_.end()) | 233 if (found != key_map_.end()) |
234 key = found->second; | 234 key = found->second; |
235 } | 235 } |
236 | 236 |
237 if (!key) { | 237 if (!key) { |
238 // TODO(fgalligan): Fire a need_key event here and add a test. | |
239 DVLOG(1) << "Could not find a matching key for given key ID."; | 238 DVLOG(1) << "Could not find a matching key for given key ID."; |
240 decrypt_cb.Run(kError, NULL); | 239 decrypt_cb.Run(kNoKey, NULL); |
241 return; | 240 return; |
242 } | 241 } |
243 | 242 |
244 int checksum_size = encrypted->GetDecryptConfig()->checksum_size(); | 243 int checksum_size = encrypted->GetDecryptConfig()->checksum_size(); |
245 // According to the WebM encrypted specification, it is an open question | 244 // According to the WebM encrypted specification, it is an open question |
246 // what should happen when a frame fails the integrity check. | 245 // what should happen when a frame fails the integrity check. |
247 // http://wiki.webmproject.org/encryption/webm-encryption-rfc | 246 // http://wiki.webmproject.org/encryption/webm-encryption-rfc |
248 if (checksum_size > 0 && | 247 if (checksum_size > 0 && |
249 !key->hmac_key().empty() && | 248 !key->hmac_key().empty() && |
250 !CheckData(*encrypted, key->hmac_key())) { | 249 !CheckData(*encrypted, key->hmac_key())) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 299 |
301 decryption_key_.reset( | 300 decryption_key_.reset( |
302 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_)); | 301 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_)); |
303 if (!decryption_key_.get()) { | 302 if (!decryption_key_.get()) { |
304 return false; | 303 return false; |
305 } | 304 } |
306 return true; | 305 return true; |
307 } | 306 } |
308 | 307 |
309 } // namespace media | 308 } // namespace media |
OLD | NEW |