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

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

Issue 11830024: Do not require a key before processing unencrypted frames within a potentially encrypted stream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 11 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 | « no previous file | media/filters/pipeline_integration_test.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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 break; 225 break;
226 default: 226 default:
227 NOTREACHED(); 227 NOTREACHED();
228 } 228 }
229 } 229 }
230 230
231 void AesDecryptor::Decrypt(StreamType stream_type, 231 void AesDecryptor::Decrypt(StreamType stream_type,
232 const scoped_refptr<DecoderBuffer>& encrypted, 232 const scoped_refptr<DecoderBuffer>& encrypted,
233 const DecryptCB& decrypt_cb) { 233 const DecryptCB& decrypt_cb) {
234 CHECK(encrypted->GetDecryptConfig()); 234 CHECK(encrypted->GetDecryptConfig());
235 const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
236
237 DecryptionKey* key = GetKey(key_id);
238 if (!key) {
239 DVLOG(1) << "Could not find a matching key for the given key ID.";
240 decrypt_cb.Run(kNoKey, NULL);
241 return;
242 }
243 235
244 scoped_refptr<DecoderBuffer> decrypted; 236 scoped_refptr<DecoderBuffer> decrypted;
245 // An empty iv string signals that the frame is unencrypted. 237 // An empty iv string signals that the frame is unencrypted.
246 if (encrypted->GetDecryptConfig()->iv().empty()) { 238 if (encrypted->GetDecryptConfig()->iv().empty()) {
247 int data_offset = encrypted->GetDecryptConfig()->data_offset(); 239 int data_offset = encrypted->GetDecryptConfig()->data_offset();
248 decrypted = DecoderBuffer::CopyFrom(encrypted->GetData() + data_offset, 240 decrypted = DecoderBuffer::CopyFrom(encrypted->GetData() + data_offset,
249 encrypted->GetDataSize() - data_offset); 241 encrypted->GetDataSize() - data_offset);
250 } else { 242 } else {
243 const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
244 DecryptionKey* key = GetKey(key_id);
245 if (!key) {
246 DVLOG(1) << "Could not find a matching key for the given key ID.";
247 decrypt_cb.Run(kNoKey, NULL);
248 return;
249 }
250
251 crypto::SymmetricKey* decryption_key = key->decryption_key(); 251 crypto::SymmetricKey* decryption_key = key->decryption_key();
252 decrypted = DecryptData(*encrypted, decryption_key); 252 decrypted = DecryptData(*encrypted, decryption_key);
253 if (!decrypted) { 253 if (!decrypted) {
254 DVLOG(1) << "Decryption failed."; 254 DVLOG(1) << "Decryption failed.";
255 decrypt_cb.Run(kError, NULL); 255 decrypt_cb.Run(kError, NULL);
256 return; 256 return;
257 } 257 }
258 } 258 }
259 259
260 decrypted->SetTimestamp(encrypted->GetTimestamp()); 260 decrypted->SetTimestamp(encrypted->GetTimestamp());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 bool AesDecryptor::DecryptionKey::Init() { 328 bool AesDecryptor::DecryptionKey::Init() {
329 CHECK(!secret_.empty()); 329 CHECK(!secret_.empty());
330 decryption_key_.reset(crypto::SymmetricKey::Import( 330 decryption_key_.reset(crypto::SymmetricKey::Import(
331 crypto::SymmetricKey::AES, secret_)); 331 crypto::SymmetricKey::AES, secret_));
332 if (!decryption_key_.get()) 332 if (!decryption_key_.get())
333 return false; 333 return false;
334 return true; 334 return true;
335 } 335 }
336 336
337 } // namespace media 337 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698