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

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.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: –Fix DecodeEncryptedFrame_WrongKey test. 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/filters/ffmpeg_video_decoder_unittest.cc
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 6367ab248b73b4ac3aec8dd2750809f2a2c806b3..7222c7600b1d0f2f851a17c60c2bd31f18d829ec 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -16,6 +16,7 @@
#include "media/base/test_data_util.h"
#include "media/base/video_decoder.h"
#include "media/base/video_frame.h"
+#include "media/crypto/hmac_aes_decryptor.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/filters/ffmpeg_decoder_unittest.h"
#include "media/filters/ffmpeg_glue.h"
@@ -37,9 +38,14 @@ static const gfx::Rect kVisibleRect(320, 240);
static const gfx::Size kNaturalSize(522, 288);
static const AVRational kFrameRate = { 100, 1 };
static const AVRational kAspectRatio = { 1, 1 };
-static const unsigned char kRawKey[] = "A wonderful key!";
+static const unsigned char kRawKey[] =
+ "\x5b\x4e\xe8\xb6\xd0\x7e\x4e\x58\xea\x24\x4c\x40\x13\xfd\xb5\x2d";
static const unsigned char kWrongKey[] = "I'm a wrong key.";
static const unsigned char kKeyId[] = "A normal key ID.";
+static const uint64 kIv = 0;
+static const int kHmacSize = 12;
+static const unsigned char kHmac[] =
+ "\xeb\x1c\xa5\x2e\x51\x27\xd0\x83\xa2\xad\x38\x80";
xhwang 2012/06/14 19:42:27 I suppose this kHmac should match the hmac in the
fgalligan1 2012/07/03 22:00:15 Correct.
ACTION_P(ReturnBuffer, buffer) {
arg0.Run(buffer);
@@ -48,7 +54,7 @@ ACTION_P(ReturnBuffer, buffer) {
class FFmpegVideoDecoderTest : public testing::Test {
public:
FFmpegVideoDecoderTest()
- : decryptor_(new AesDecryptor()),
+ : decryptor_(new HmacAesDecryptor()),
decoder_(new FFmpegVideoDecoder(base::Bind(&Identity<MessageLoop*>,
&message_loop_))),
demuxer_(new StrictMock<MockDemuxerStream>()),
@@ -197,7 +203,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
scoped_refptr<VideoFrame>));
MessageLoop message_loop_;
- scoped_ptr<AesDecryptor> decryptor_;
+ scoped_ptr<Decryptor> decryptor_;
scoped_refptr<FFmpegVideoDecoder> decoder_;
scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_;
MockStatisticsCB statistics_cb_;
@@ -380,7 +386,9 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
// Simulate decoding a single encrypted frame.
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
+ new DecryptConfig(kHmac, kHmacSize,
+ kIv,
+ kKeyId, arraysize(kKeyId) - 1)));
VideoDecoder::DecoderStatus status;
scoped_refptr<VideoFrame> video_frame;
DecodeSingleFrame(encrypted_i_frame_buffer_, &status, &video_frame);
@@ -396,7 +404,9 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) {
// Simulate decoding a single encrypted frame.
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
+ new DecryptConfig(kHmac, kHmacSize,
+ kIv,
+ kKeyId, arraysize(kKeyId) - 1)));
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
@@ -419,27 +429,18 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) {
kWrongKey, arraysize(kWrongKey) - 1);
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
+ new DecryptConfig(kHmac, kHmacSize,
+ kIv,
+ kKeyId, arraysize(kKeyId) - 1)));
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
-#if defined(OS_LINUX)
- // Using the wrong key on linux doesn't cause an decryption error but actually
- // attempts to decode the content, however we're unable to distinguish between
- // the two (see http://crbug.com/124434).
- EXPECT_CALL(statistics_cb_, OnStatistics(_));
-#endif
-
// Our read should still get satisfied with end of stream frame during an
// error.
VideoDecoder::DecoderStatus status;
scoped_refptr<VideoFrame> video_frame;
Read(&status, &video_frame);
-#if defined(OS_LINUX)
- EXPECT_EQ(VideoDecoder::kDecodeError, status);
-#else
EXPECT_EQ(VideoDecoder::kDecryptError, status);
-#endif
EXPECT_FALSE(video_frame);
message_loop_.RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698