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

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

Issue 10823110: Add support for v0.3 of the encrypted WebM specification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments from Patch Set 4. 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/base/decrypt_config.cc ('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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // what should happen when a frame fails the integrity check. 278 // what should happen when a frame fails the integrity check.
279 // http://wiki.webmproject.org/encryption/webm-encryption-rfc 279 // http://wiki.webmproject.org/encryption/webm-encryption-rfc
280 if (checksum_size > 0 && 280 if (checksum_size > 0 &&
281 !key->hmac_key().empty() && 281 !key->hmac_key().empty() &&
282 !CheckData(*encrypted, key->hmac_key())) { 282 !CheckData(*encrypted, key->hmac_key())) {
283 DVLOG(1) << "Integrity check failed."; 283 DVLOG(1) << "Integrity check failed.";
284 decrypt_cb.Run(kError, NULL); 284 decrypt_cb.Run(kError, NULL);
285 return; 285 return;
286 } 286 }
287 287
288 // TODO(strobe): Currently, presence of checksum is used to indicate the use 288 scoped_refptr<DecoderBuffer> decrypted;
289 // of normal or WebM decryption keys. Consider a more explicit signaling 289 // An empty iv string signals that the frame is unencrypted.
290 // mechanism and the removal of the webm_decryption_key member. 290 if (encrypted->GetDecryptConfig()->iv().empty()) {
291 crypto::SymmetricKey* decryption_key = (checksum_size > 0) ? 291 int data_offset = encrypted->GetDecryptConfig()->data_offset();
292 key->webm_decryption_key() : key->decryption_key(); 292 decrypted = DecoderBuffer::CopyFrom(encrypted->GetData() + data_offset,
293 scoped_refptr<DecoderBuffer> decrypted = 293 encrypted->GetDataSize() - data_offset);
294 DecryptData(*encrypted, decryption_key); 294 } else {
295 if (!decrypted) { 295 // TODO(strobe): Currently, presence of checksum is used to indicate the use
296 DVLOG(1) << "Decryption failed."; 296 // of normal or WebM decryption keys. Consider a more explicit signaling
297 decrypt_cb.Run(kError, NULL); 297 // mechanism and the removal of the webm_decryption_key member.
298 return; 298 crypto::SymmetricKey* decryption_key = (checksum_size > 0) ?
299 key->webm_decryption_key() : key->decryption_key();
300 decrypted = DecryptData(*encrypted, decryption_key);
301 if (!decrypted) {
302 DVLOG(1) << "Decryption failed.";
303 decrypt_cb.Run(kError, NULL);
304 return;
305 }
299 } 306 }
300 307
301 decrypted->SetTimestamp(encrypted->GetTimestamp()); 308 decrypted->SetTimestamp(encrypted->GetTimestamp());
302 decrypted->SetDuration(encrypted->GetDuration()); 309 decrypted->SetDuration(encrypted->GetDuration());
303 decrypt_cb.Run(kSuccess, decrypted); 310 decrypt_cb.Run(kSuccess, decrypted);
304 } 311 }
305 312
306 void AesDecryptor::SetKey(const std::string& key_id, 313 void AesDecryptor::SetKey(const std::string& key_id,
307 scoped_ptr<DecryptionKey> decryption_key) { 314 scoped_ptr<DecryptionKey> decryption_key) {
308 base::AutoLock auto_lock(key_map_lock_); 315 base::AutoLock auto_lock(key_map_lock_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 return false; 356 return false;
350 357
351 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize); 358 hmac_key_ = DeriveKey(secret_, kWebmHmacSeed, kWebmSha1DigestSize);
352 if (hmac_key_.empty()) 359 if (hmac_key_.empty())
353 return false; 360 return false;
354 361
355 return true; 362 return true;
356 } 363 }
357 364
358 } // namespace media 365 } // namespace media
OLDNEW
« no previous file with comments | « media/base/decrypt_config.cc ('k') | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698