summaryrefslogtreecommitdiffstats
path: root/media/crypto
diff options
context:
space:
mode:
authorfgalligan@chromium.org <fgalligan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 00:17:14 +0000
committerfgalligan@chromium.org <fgalligan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 00:17:14 +0000
commit1804c33f0d9234d240117afc87e46272e0761466 (patch)
tree9e191247534f4dc0274677077f3fc233a5dcca07 /media/crypto
parent61b98c6d9eb9e7aa6095f730b5f89d151930a2a5 (diff)
downloadchromium_src-1804c33f0d9234d240117afc87e46272e0761466.zip
chromium_src-1804c33f0d9234d240117afc87e46272e0761466.tar.gz
chromium_src-1804c33f0d9234d240117afc87e46272e0761466.tar.bz2
Change WebM parser to treat IVs from encrypted WebM as raw data.
The encrypted WebM spec RFC changed to treat IVs as raw data. BUG=155641 TEST=All media_unittests pass. TBR=sky Review URL: https://chromiumcodereview.appspot.com/11139008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/crypto')
-rw-r--r--media/crypto/aes_decryptor_unittest.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc
index 1b9d52e..0f3537e 100644
--- a/media/crypto/aes_decryptor_unittest.cc
+++ b/media/crypto/aes_decryptor_unittest.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
-#include "base/sys_byteorder.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/base/mock_filters.h"
@@ -92,8 +91,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
},
@@ -161,16 +160,16 @@ static const SubsampleEntry kSubsampleEntries[] = {
{ 1, 0 }
};
-// 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.
+// Generates a 16 byte CTR counter block. The CTR counter block format is a
+// CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV.
+// |iv_size| is the size of |iv| in btyes. Returns a string of
+// kDecryptionKeySize 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);
+ CHECK_LE(iv_size, DecryptConfig::kDecryptionKeySize);
std::string counter_block(reinterpret_cast<const char*>(iv), iv_size);
- counter_block.append(kDecryptionKeySize - iv_size, 0);
+ counter_block.append(DecryptConfig::kDecryptionKeySize - iv_size, 0);
return counter_block;
}
@@ -187,9 +186,10 @@ static scoped_refptr<DecoderBuffer> CreateWebMEncryptedBuffer(
scoped_refptr<DecoderBuffer> encrypted_buffer = DecoderBuffer::CopyFrom(
data, data_size);
CHECK(encrypted_buffer);
+ DCHECK_EQ(kWebMSignalByteSize, 1);
uint8 signal_byte = data[0];
- int data_offset = sizeof(signal_byte);
+ int data_offset = kWebMSignalByteSize;
// Setting the DecryptConfig object of the buffer while leaving the
// initialization vector empty will tell the decryptor that the frame is
@@ -197,12 +197,8 @@ 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);
+ counter_block_str = GenerateCounterBlock(data + data_offset, kWebMIvSize);
+ data_offset += kWebMIvSize;
}
encrypted_buffer->SetDecryptConfig(