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_unittest.cc

Issue 11139008: Change WebM parser to treat IVs from encrypted WebM as raw data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | media/filters/pipeline_integration_test.cc » ('j') | media/webm/webm_cluster_parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/crypto/aes_decryptor_unittest.cc
diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc
index 1b9d52e51b24be3322e45c14441b07f60adf2a8c..f2be41cfecd618926011396d204b98cd58caf60e 100644
--- a/media/crypto/aes_decryptor_unittest.cc
+++ b/media/crypto/aes_decryptor_unittest.cc
@@ -92,8 +92,8 @@ const WebmEncryptedData kWebmEncryptedFrames[] = {
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40
}, 16,
// encrypted_data
- { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x9c, 0x71, 0x26, 0x57, 0x3e, 0x25, 0x37,
+ { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x9c, 0x71, 0x26, 0x57, 0x3e, 0x25, 0x37,
0xf7, 0x31, 0x81, 0x19, 0x64, 0xce, 0xbc
}, 23
},
@@ -164,13 +164,12 @@ static const SubsampleEntry kSubsampleEntries[] = {
// Returns a 16 byte CTR counter block. The CTR counter block format is a
// CTR IV appended with a CTR block counter. |iv| is a CTR IV. |iv_size| is
// the size of |iv| in bytes.
-static std::string GenerateCounterBlock(const uint8* iv, int iv_size) {
- const int kDecryptionKeySize = 16;
- CHECK_GT(iv_size, 0);
- CHECK_LE(iv_size, kDecryptionKeySize);
+static std::string GenerateCounterBlock(const std::string& iv) {
+ CHECK_GT(iv.size(), 0UL);
+ CHECK_LE(iv.size(), static_cast<size_t>(DecryptConfig::kDecryptionKeySize));
- std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
- counter_block.append(kDecryptionKeySize - iv_size, 0);
+ std::string counter_block(iv);
+ counter_block.append(DecryptConfig::kDecryptionKeySize - iv.size(), 0);
ddorwin 2012/10/13 00:26:17 Why wasn't the scoping necessary before?
fgalligan1 2012/10/13 06:20:31 The old version defined the value at the top of th
return counter_block;
}
@@ -197,12 +196,10 @@ static scoped_refptr<DecoderBuffer> CreateWebMEncryptedBuffer(
std::string counter_block_str;
if (signal_byte & kWebMFlagEncryptedFrame) {
- uint64 network_iv;
- memcpy(&network_iv, data + data_offset, sizeof(network_iv));
- const uint64 iv = base::NetToHost64(network_iv);
- counter_block_str =
- GenerateCounterBlock(reinterpret_cast<const uint8*>(&iv), sizeof(iv));
- data_offset += sizeof(iv);
+ const std::string iv(reinterpret_cast<const char*>(data + data_offset),
+ kWebMIvSize);
+ data_offset += kWebMIvSize;
+ counter_block_str = GenerateCounterBlock(iv);
}
encrypted_buffer->SetDecryptConfig(
@@ -434,7 +431,6 @@ TEST_F(AesDecryptorTest, MultipleKeysAndFrames) {
ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(encrypted_data1,
frame1.plain_text,
frame1.plain_text_size));
-
scoped_refptr<DecoderBuffer> encrypted_data2 =
ddorwin 2012/10/13 00:26:17 Is there a reason the empty line was removed?
fgalligan1 2012/10/13 06:20:31 No. I'll put it back to make less noise.
CreateWebMEncryptedBuffer(frame2.encrypted_data,
frame2.encrypted_data_size,
« no previous file with comments | « no previous file | media/filters/pipeline_integration_test.cc » ('j') | media/webm/webm_cluster_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698