Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: media/crypto/aes_decryptor.cc

Issue 10822026: Implement "Key Presence" step in "Encrypted Block Encounted" algorithm in EME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/crypto/aes_decryptor.h ('k') | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const std::string& session_id) { 260 const std::string& session_id) {
261 } 261 }
262 262
263 void AesDecryptor::Decrypt(const scoped_refptr<DecoderBuffer>& encrypted, 263 void AesDecryptor::Decrypt(const scoped_refptr<DecoderBuffer>& encrypted,
264 const DecryptCB& decrypt_cb) { 264 const DecryptCB& decrypt_cb) {
265 CHECK(encrypted->GetDecryptConfig()); 265 CHECK(encrypted->GetDecryptConfig());
266 const std::string& key_id = encrypted->GetDecryptConfig()->key_id(); 266 const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
267 267
268 DecryptionKey* key = GetKey(key_id); 268 DecryptionKey* key = GetKey(key_id);
269 if (!key) { 269 if (!key) {
270 // TODO(xhwang): Fire a need_key event here and add a test.
271 DVLOG(1) << "Could not find a matching key for the given key ID."; 270 DVLOG(1) << "Could not find a matching key for the given key ID.";
272 decrypt_cb.Run(kError, NULL); 271 decrypt_cb.Run(kNoKey, NULL);
273 return; 272 return;
274 } 273 }
275 274
276 int checksum_size = encrypted->GetDecryptConfig()->checksum().size(); 275 int checksum_size = encrypted->GetDecryptConfig()->checksum().size();
277 // According to the WebM encrypted specification, it is an open question 276 // According to the WebM encrypted specification, it is an open question
278 // what should happen when a frame fails the integrity check. 277 // what should happen when a frame fails the integrity check.
279 // http://wiki.webmproject.org/encryption/webm-encryption-rfc 278 // http://wiki.webmproject.org/encryption/webm-encryption-rfc
280 if (checksum_size > 0 && 279 if (checksum_size > 0 &&
281 !key->hmac_key().empty() && 280 !key->hmac_key().empty() &&
282 !CheckData(*encrypted, key->hmac_key())) { 281 !CheckData(*encrypted, key->hmac_key())) {
(...skipping 20 matching lines...) Expand all
303 decrypt_cb.Run(kError, NULL); 302 decrypt_cb.Run(kError, NULL);
304 return; 303 return;
305 } 304 }
306 } 305 }
307 306
308 decrypted->SetTimestamp(encrypted->GetTimestamp()); 307 decrypted->SetTimestamp(encrypted->GetTimestamp());
309 decrypted->SetDuration(encrypted->GetDuration()); 308 decrypted->SetDuration(encrypted->GetDuration());
310 decrypt_cb.Run(kSuccess, decrypted); 309 decrypt_cb.Run(kSuccess, decrypted);
311 } 310 }
312 311
312 void AesDecryptor::Stop() {
313 }
314
313 void AesDecryptor::SetKey(const std::string& key_id, 315 void AesDecryptor::SetKey(const std::string& key_id,
314 scoped_ptr<DecryptionKey> decryption_key) { 316 scoped_ptr<DecryptionKey> decryption_key) {
315 base::AutoLock auto_lock(key_map_lock_); 317 base::AutoLock auto_lock(key_map_lock_);
316 KeyMap::iterator found = key_map_.find(key_id); 318 KeyMap::iterator found = key_map_.find(key_id);
317 if (found != key_map_.end()) { 319 if (found != key_map_.end()) {
318 delete found->second; 320 delete found->second;
319 key_map_.erase(found); 321 key_map_.erase(found);
320 } 322 }
321 key_map_[key_id] = decryption_key.release(); 323 key_map_[key_id] = decryption_key.release();
322 } 324 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return false; 358 return false;
357 359
358 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize); 360 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize);
359 if (hmac_key_.empty()) 361 if (hmac_key_.empty())
360 return false; 362 return false;
361 363
362 return true; 364 return true;
363 } 365 }
364 366
365 } // namespace media 367 } // namespace media
OLDNEW
« no previous file with comments | « media/crypto/aes_decryptor.h ('k') | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698