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

Unified Diff: media/crypto/aes_decryptor.cc

Issue 10535029: Add support for encrypted WebM files as defined in the RFC. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated encrypted WebM test data. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/crypto/aes_decryptor.cc
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc
index cbb75b37bd33457f74b9f540d652ae01bbd77c19..7b8feca73ebae36b6ec6f4f5186718d773643f99 100644
--- a/media/crypto/aes_decryptor.cc
+++ b/media/crypto/aes_decryptor.cc
@@ -14,40 +14,6 @@
namespace media {
-// TODO(xhwang): Get real IV from frames.
-static const char kInitialCounter[] = "0000000000000000";
-
-// Decrypt |input| using |key|.
-// Return a DecoderBuffer with the decrypted data if decryption succeeded.
-// Return NULL if decryption failed.
-static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
- crypto::SymmetricKey* key) {
- CHECK(input.GetDataSize());
- CHECK(key);
-
- // Initialize encryption data.
- // The IV must be exactly as long as the cipher block size.
- crypto::Encryptor encryptor;
- if (!encryptor.Init(key, crypto::Encryptor::CBC, kInitialCounter)) {
- DVLOG(1) << "Could not initialize encryptor.";
- return NULL;
- }
-
- std::string decrypted_text;
- base::StringPiece encrypted_text(
- reinterpret_cast<const char*>(input.GetData()),
- input.GetDataSize());
- if (!encryptor.Decrypt(encrypted_text, &decrypted_text)) {
- DVLOG(1) << "Could not decrypt data.";
- return NULL;
- }
-
- // TODO(xhwang): Find a way to avoid this data copy.
- return DecoderBuffer::CopyFrom(
- reinterpret_cast<const uint8*>(decrypted_text.data()),
- decrypted_text.size());
-}
-
AesDecryptor::AesDecryptor() {}
AesDecryptor::~AesDecryptor() {
@@ -99,7 +65,8 @@ scoped_refptr<DecoderBuffer> AesDecryptor::Decrypt(
key = found->second;
}
- scoped_refptr<DecoderBuffer> decrypted = DecryptData(*encrypted, key);
+ scoped_refptr<DecoderBuffer> decrypted =
+ Decryptor::DecryptData(*encrypted, key, 0);
if (decrypted) {
decrypted->SetTimestamp(encrypted->GetTimestamp());

Powered by Google App Engine
This is Rietveld 408576698