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

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

Issue 2095523002: Make //crypto factories return std::unique_ptr<>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I'm blind Created 4 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/cdm/aes_decryptor.h" 5 #include "media/cdm/aes_decryptor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <list> 8 #include <list>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } else { 474 } else {
475 const std::string& key_id = encrypted->decrypt_config()->key_id(); 475 const std::string& key_id = encrypted->decrypt_config()->key_id();
476 base::AutoLock auto_lock(key_map_lock_); 476 base::AutoLock auto_lock(key_map_lock_);
477 DecryptionKey* key = GetKey_Locked(key_id); 477 DecryptionKey* key = GetKey_Locked(key_id);
478 if (!key) { 478 if (!key) {
479 DVLOG(1) << "Could not find a matching key for the given key ID."; 479 DVLOG(1) << "Could not find a matching key for the given key ID.";
480 decrypt_cb.Run(kNoKey, NULL); 480 decrypt_cb.Run(kNoKey, NULL);
481 return; 481 return;
482 } 482 }
483 483
484 crypto::SymmetricKey* decryption_key = key->decryption_key(); 484 decrypted = DecryptData(*encrypted.get(), key->decryption_key());
485 decrypted = DecryptData(*encrypted.get(), decryption_key); 485 if (!decrypted) {
486 if (!decrypted.get()) {
487 DVLOG(1) << "Decryption failed."; 486 DVLOG(1) << "Decryption failed.";
488 decrypt_cb.Run(kError, NULL); 487 decrypt_cb.Run(kError, NULL);
489 return; 488 return;
490 } 489 }
491 } 490 }
492 491
493 decrypted->set_timestamp(encrypted->timestamp()); 492 decrypted->set_timestamp(encrypted->timestamp());
494 decrypted->set_duration(encrypted->duration()); 493 decrypted->set_duration(encrypted->duration());
495 decrypt_cb.Run(kSuccess, decrypted); 494 decrypt_cb.Run(kSuccess, decrypted);
496 } 495 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 599 }
601 600
602 AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret) 601 AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret)
603 : secret_(secret) { 602 : secret_(secret) {
604 } 603 }
605 604
606 AesDecryptor::DecryptionKey::~DecryptionKey() {} 605 AesDecryptor::DecryptionKey::~DecryptionKey() {}
607 606
608 bool AesDecryptor::DecryptionKey::Init() { 607 bool AesDecryptor::DecryptionKey::Init() {
609 CHECK(!secret_.empty()); 608 CHECK(!secret_.empty());
610 decryption_key_.reset(crypto::SymmetricKey::Import( 609 decryption_key_ =
611 crypto::SymmetricKey::AES, secret_)); 610 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_);
612 if (!decryption_key_) 611 if (!decryption_key_)
613 return false; 612 return false;
614 return true; 613 return true;
615 } 614 }
616 615
617 } // namespace media 616 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/common/transport_encryption_handler.cc ('k') | net/extras/sqlite/sqlite_channel_id_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698