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

Side by Side Diff: media/crypto/aes_decryptor_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: Rebase to master Created 8 years, 5 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
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/sys_byteorder.h"
8 #include "media/base/decoder_buffer.h" 9 #include "media/base/decoder_buffer.h"
9 #include "media/base/decrypt_config.h" 10 #include "media/base/decrypt_config.h"
10 #include "media/base/mock_filters.h" 11 #include "media/base/mock_filters.h"
11 #include "media/crypto/aes_decryptor.h" 12 #include "media/crypto/aes_decryptor.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 using ::testing::_; 15 using ::testing::_;
15 using ::testing::Gt; 16 using ::testing::Gt;
16 using ::testing::NotNull; 17 using ::testing::NotNull;
17 using ::testing::SaveArg; 18 using ::testing::SaveArg;
18 using ::testing::StrNe; 19 using ::testing::StrNe;
19 20
20 namespace media { 21 namespace media {
21 22
23 // |encrypted_data| is encrypted from |plain_text| using |key|. |key_id| is
24 // used to distinguish |key|.
25 struct WebmEncryptedData {
26 uint8 plain_text[32];
27 int plain_text_size;
28 uint8 key_id[32];
29 int key_id_size;
30 uint8 key[32];
31 int key_size;
32 uint8 encrypted_data[64];
33 int encrypted_data_size;
34 };
35
36 static const int kIntegrityCheckSize = 12;
ddorwin 2012/07/11 01:00:27 WebM "Check" seems like an action. Maybe "Value" o
fgalligan1 2012/07/11 22:06:33 Done.
22 static const char kClearKeySystem[] = "org.w3.clearkey"; 37 static const char kClearKeySystem[] = "org.w3.clearkey";
23 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; 38
24 // |kEncryptedData| is encrypted from |kOriginalData| using |kRightKey|. 39 // Frames 0 & 1 are encrypted with the same key. Frame 2 is encrypted with a
25 // Modifying any of these independently would fail the test. 40 // different key.
26 static const uint8 kOriginalData[] = { 41 const WebmEncryptedData kEncryptedFrames[] = {
27 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 42 {
28 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e 43 // plaintext
44 "Original data.", 14,
45 // key_id
46 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
47 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13}, 20,
48 // key
49 { 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
50 0x20, 0x21, 0x22, 0x23}, 16,
51 // encrypted_data
52 { 0xfb, 0xe7, 0x1d, 0xbb, 0x4c, 0x23, 0xce, 0xba, 0xcc, 0xf8, 0xda, 0xc0,
53 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xaa, 0xff, 0xb7,
54 0x74, 0x02, 0x4e, 0x1c, 0x75, 0x3d, 0xee, 0xcb, 0x64, 0xf7}, 34
55 }, {
56 // plaintext
57 "Changed Original data.", 22,
58 // key_id
59 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
60 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13}, 20,
61 // key
62 { 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
63 0x20, 0x21, 0x22, 0x23}, 16,
64 // encrypted_data
65 { 0x43, 0xe4, 0x78, 0x7a, 0x43, 0xe1, 0x49, 0xbb, 0x44, 0x38, 0xdf, 0xfc,
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x8e, 0x87, 0x21,
67 0xd3, 0xb9, 0x1c, 0x61, 0xf6, 0x5a, 0x60, 0xaa, 0x07, 0x0e, 0x96, 0xd0,
68 0x54, 0x5d, 0x35, 0x9a, 0x4a, 0xd3}, 42
69 }, {
70 // plaintext
71 "Original data.", 14,
72 // key_id
73 { 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
74 0x30}, 13,
75 // key
76 { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
77 0x3d, 0x3e, 0x3f, 0x40}, 16,
78 // encrypted_data
79 { 0xd9, 0x43, 0x30, 0xfd, 0x82, 0x77, 0x62, 0x04, 0x08, 0xc2, 0x48, 0x89,
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x48, 0x5e, 0x4a, 0x41,
81 0x2a, 0x8b, 0xf4, 0xc6, 0x47, 0x54, 0x90, 0x34, 0xf4, 0x8b}, 34
82 },
29 }; 83 };
30 static const uint8 kEncryptedData[] = { 84
31 0x82, 0x3A, 0x76, 0x92, 0xEC, 0x7F, 0xF8, 0x85,
32 0xEC, 0x23, 0x52, 0xFB, 0x19, 0xB1, 0xB9, 0x09
33 };
34 static const uint8 kRightKey[] = {
35 0x41, 0x20, 0x77, 0x6f, 0x6e, 0x64, 0x65, 0x72,
36 0x66, 0x75, 0x6c, 0x20, 0x6b, 0x65, 0x79, 0x21
37 };
38 static const uint8 kWrongKey[] = { 85 static const uint8 kWrongKey[] = {
39 0x49, 0x27, 0x6d, 0x20, 0x61, 0x20, 0x77, 0x72, 86 0x49, 0x27, 0x6d, 0x20, 0x61, 0x20, 0x77, 0x72,
40 0x6f, 0x6e, 0x67, 0x20, 0x6b, 0x65, 0x79, 0x2e 87 0x6f, 0x6e, 0x67, 0x20, 0x6b, 0x65, 0x79, 0x2e
41 }; 88 };
42 static const uint8 kWrongSizedKey[] = { 0x20, 0x20 }; 89 static const uint8 kWrongSizedKey[] = { 0x20, 0x20 };
43 static const uint8 kKeyId1[] = { 90 static const unsigned char kFrame0InvalidHmac[] = {
ddorwin 2012/07/11 01:00:27 How are these invalid? Size? "Wrong" (does not mat
ddorwin 2012/07/11 01:00:27 Are these really encrypted blocks with wrong Hmac,
fgalligan1 2012/07/11 22:06:33 I changed the names and added comments on what was
44 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44, 0x20, 0x31 91 0xfc, 0xe7, 0x1d, 0xbb, 0x4c, 0x23, 0xce, 0xba, 0xcc, 0xf8, 0xda, 0xc0, 0xff,
92 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xaa, 0xff, 0xb7, 0x74, 0x02,
93 0x4e, 0x1c, 0x75, 0x3d, 0xee, 0xcb, 0x64, 0xf7
45 }; 94 };
46 static const uint8 kKeyId2[] = { 95 static const unsigned char kFrame0InvalidIv[] = {
47 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44, 0x20, 0x32 96 0xfb, 0xe7, 0x1d, 0xbb, 0x4c, 0x23, 0xce, 0xba, 0xcc, 0xf8, 0xda, 0xc0, 0x0f,
97 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xaa, 0xff, 0xb7, 0x74, 0x02,
98 0x4e, 0x1c, 0x75, 0x3d, 0xee, 0xcb, 0x64, 0xf7
99 };
100 static const unsigned char kFrame0InvalidData[] = {
101 0xfb, 0xe7, 0x1d, 0xbb, 0x4c, 0x23, 0xce, 0xba, 0xcc, 0xf8, 0xda, 0xc0, 0xff,
102 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xaa, 0xff, 0xb7, 0x74, 0x02,
103 0x4e, 0x1c, 0x75, 0x3d, 0xee, 0xcb, 0x64, 0xf8
48 }; 104 };
49 105
50 class AesDecryptorTest : public testing::Test { 106 class AesDecryptorTest : public testing::Test {
51 public: 107 public:
52 AesDecryptorTest() : decryptor_(&client_) { 108 AesDecryptorTest() : decryptor_(&client_) {}
53 encrypted_data_ = DecoderBuffer::CopyFrom(kEncryptedData, 109
54 arraysize(kEncryptedData)); 110 protected:
111 scoped_refptr<DecoderBuffer> CreateEncryptedBuffer(const uint8* data,
ddorwin 2012/07/11 01:00:27 WebM
fgalligan1 2012/07/11 22:06:33 Done.
112 int data_size,
113 const uint8* key_id,
114 int key_id_size) {
115 scoped_refptr<DecoderBuffer> encrypted_buffer = DecoderBuffer::CopyFrom(
116 data + kIntegrityCheckSize, data_size - kIntegrityCheckSize);
117 CHECK(encrypted_buffer);
118
119 // Every encrypted Block has an HMAC and IV prepended to it. Current WebM
ddorwin 2012/07/11 01:00:27 Seems like a function level comment. Should at lea
fgalligan1 2012/07/11 22:06:33 Done.
120 // encrypted request for comments specification is here
121 // http://wiki.webmproject.org/encryption/webm-encryption-rfc
122 uint64 network_iv;
123 memcpy(&network_iv,
124 data + kIntegrityCheckSize,
125 sizeof(network_iv));
126 const uint64 iv = base::NetToHost64(network_iv);
127 encrypted_buffer->SetDecryptConfig(
128 scoped_ptr<DecryptConfig>(new DecryptConfig(
129 data, kIntegrityCheckSize,
ddorwin 2012/07/11 01:00:27 Might be more understandable for others if you mad
fgalligan1 2012/07/11 22:06:33 Done.
130 reinterpret_cast<const uint8*>(&iv), sizeof(iv),
131 key_id, key_id_size,
132 sizeof(iv))));
133 return encrypted_buffer;
55 } 134 }
56 135
57 protected: 136 void GenerateKeyRequest(const uint8* key_id, int key_id_size) {
58 void GenerateKeyRequest() {
59 EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(std::string()), 137 EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(std::string()),
60 NotNull(), Gt(0), "")) 138 NotNull(), Gt(0), ""))
61 .WillOnce(SaveArg<1>(&session_id_string_)); 139 .WillOnce(SaveArg<1>(&session_id_string_));
62 decryptor_.GenerateKeyRequest(kClearKeySystem, 140 decryptor_.GenerateKeyRequest(kClearKeySystem, key_id, key_id_size);
63 kInitData, arraysize(kInitData));
64 } 141 }
65 142
66 template <int KeyIdSize, int KeySize> 143 void AddKeyAndExpectToSucceed(const uint8* key_id, int key_id_size,
67 void AddKeyAndExpectToSucceed(const uint8 (&key_id)[KeyIdSize], 144 const uint8* key, int key_size) {
68 const uint8 (&key)[KeySize]) {
69 EXPECT_CALL(client_, KeyAdded(kClearKeySystem, session_id_string_)); 145 EXPECT_CALL(client_, KeyAdded(kClearKeySystem, session_id_string_));
70 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, 146 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size,
71 session_id_string_); 147 session_id_string_);
72 } 148 }
73 149
74 template <int KeyIdSize, int KeySize> 150 void AddKeyAndExpectToFail(const uint8* key_id, int key_id_size,
75 void AddKeyAndExpectToFail(const uint8 (&key_id)[KeyIdSize], 151 const uint8* key, int key_size) {
76 const uint8 (&key)[KeySize]) {
77 EXPECT_CALL(client_, KeyError(kClearKeySystem, session_id_string_, 152 EXPECT_CALL(client_, KeyError(kClearKeySystem, session_id_string_,
78 Decryptor::kUnknownError, 0)); 153 Decryptor::kUnknownError, 0));
79 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, 154 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size,
80 session_id_string_); 155 session_id_string_);
81 } 156 }
82 157
83 template <int KeyIdSize> 158 void DecryptAndExpectToSucceed(const uint8* data, int data_size,
84 void SetKeyIdForEncryptedData(const uint8 (&key_id)[KeyIdSize]) { 159 const uint8* plain_text,
85 encrypted_data_->SetDecryptConfig( 160 int plain_text_size,
86 scoped_ptr<DecryptConfig>(new DecryptConfig(key_id, KeyIdSize))); 161 const uint8* key_id, int key_id_size) {
162 scoped_refptr<DecoderBuffer> encrypted_data =
163 CreateEncryptedBuffer(data, data_size, key_id, key_id_size);
164 scoped_refptr<DecoderBuffer> decrypted =
165 decryptor_.Decrypt(encrypted_data);
166 ASSERT_TRUE(decrypted);
167 ASSERT_EQ(plain_text_size, decrypted->GetDataSize());
168 EXPECT_EQ(0, memcmp(plain_text, decrypted->GetData(), plain_text_size));
87 } 169 }
88 170
89 void DecryptAndExpectToSucceed() { 171 void DecryptAndExpectToFail(const uint8* data, int data_size,
172 const uint8* plain_text, int plain_text_size,
173 const uint8* key_id, int key_id_size) {
174 scoped_refptr<DecoderBuffer> encrypted_data =
175 CreateEncryptedBuffer(data, data_size, key_id, key_id_size);
90 scoped_refptr<DecoderBuffer> decrypted = 176 scoped_refptr<DecoderBuffer> decrypted =
91 decryptor_.Decrypt(encrypted_data_); 177 decryptor_.Decrypt(encrypted_data);
92 ASSERT_TRUE(decrypted);
93 int data_length = sizeof(kOriginalData);
94 ASSERT_EQ(data_length, decrypted->GetDataSize());
95 EXPECT_EQ(0, memcmp(kOriginalData, decrypted->GetData(), data_length));
96 }
97
98 void DecryptAndExpectToFail() {
99 scoped_refptr<DecoderBuffer> decrypted =
100 decryptor_.Decrypt(encrypted_data_);
101 EXPECT_FALSE(decrypted); 178 EXPECT_FALSE(decrypted);
102 } 179 }
103 180
104 scoped_refptr<DecoderBuffer> encrypted_data_; 181 scoped_refptr<DecoderBuffer> encrypted_data_;
105 MockDecryptorClient client_; 182 MockDecryptorClient client_;
106 AesDecryptor decryptor_; 183 AesDecryptor decryptor_;
107 std::string session_id_string_; 184 std::string session_id_string_;
108 }; 185 };
109 186
110 TEST_F(AesDecryptorTest, NormalDecryption) { 187 TEST_F(AesDecryptorTest, NormalDecryption) {
111 GenerateKeyRequest(); 188 const WebmEncryptedData& frame = kEncryptedFrames[0];
112 AddKeyAndExpectToSucceed(kKeyId1, kRightKey); 189 GenerateKeyRequest(frame.key_id, frame.key_id_size);
113 SetKeyIdForEncryptedData(kKeyId1); 190 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
114 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed()); 191 frame.key, frame.key_size);
192 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(frame.encrypted_data,
193 frame.encrypted_data_size,
194 frame.plain_text,
195 frame.plain_text_size,
196 frame.key_id,
197 frame.key_id_size));
xhwang 2012/07/10 06:31:25 Can we pass in |frame| (const WebmEncryptedData&)
ddorwin 2012/07/11 01:00:27 Since it's already this way, we might just leave i
fgalligan1 2012/07/11 22:06:33 OK, did nothing :).
115 } 198 }
116 199
117 TEST_F(AesDecryptorTest, WrongKey) { 200 TEST_F(AesDecryptorTest, WrongKey) {
118 GenerateKeyRequest(); 201 const WebmEncryptedData& frame = kEncryptedFrames[0];
119 AddKeyAndExpectToSucceed(kKeyId1, kWrongKey); 202 GenerateKeyRequest(frame.key_id, frame.key_id_size);
120 SetKeyIdForEncryptedData(kKeyId1); 203 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
121 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail()); 204 kWrongKey, arraysize(kWrongKey));
205 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(frame.encrypted_data,
206 frame.encrypted_data_size,
207 frame.plain_text,
208 frame.plain_text_size,
209 frame.key_id,
210 frame.key_id_size));
122 } 211 }
123 212
124 TEST_F(AesDecryptorTest, MultipleKeys) { 213 TEST_F(AesDecryptorTest, MultipleKeys) {
ddorwin 2012/07/11 01:00:27 Suggest moving above the other MultipleKeys test a
fgalligan1 2012/07/11 22:06:33 Removed.
125 GenerateKeyRequest(); 214 const WebmEncryptedData& frame = kEncryptedFrames[0];
126 AddKeyAndExpectToSucceed(kKeyId1, kRightKey); 215 GenerateKeyRequest(frame.key_id, frame.key_id_size);
127 AddKeyAndExpectToSucceed(kKeyId2, kWrongKey); 216 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
128 SetKeyIdForEncryptedData(kKeyId1); 217 frame.key, frame.key_size);
129 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed()); 218 const WebmEncryptedData& frame2 = kEncryptedFrames[2];
219 AddKeyAndExpectToSucceed(frame2.key_id, frame2.key_id_size,
220 frame2.key, frame2.key_size);
221 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(frame.encrypted_data,
222 frame.encrypted_data_size,
223 frame.plain_text,
224 frame.plain_text_size,
225 frame.key_id,
226 frame.key_id_size));
130 } 227 }
131 228
132 TEST_F(AesDecryptorTest, KeyReplacement) { 229 TEST_F(AesDecryptorTest, KeyReplacement) {
133 GenerateKeyRequest(); 230 const WebmEncryptedData& frame = kEncryptedFrames[0];
134 SetKeyIdForEncryptedData(kKeyId1); 231 GenerateKeyRequest(frame.key_id, frame.key_id_size);
135 AddKeyAndExpectToSucceed(kKeyId1, kWrongKey); 232 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
136 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail()); 233 kWrongKey, arraysize(kWrongKey));
137 AddKeyAndExpectToSucceed(kKeyId1, kRightKey); 234 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(frame.encrypted_data,
138 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed()); 235 frame.encrypted_data_size,
236 frame.plain_text,
237 frame.plain_text_size,
238 frame.key_id,
239 frame.key_id_size));
240 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
241 frame.key, frame.key_size);
242 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(frame.encrypted_data,
243 frame.encrypted_data_size,
244 frame.plain_text,
245 frame.plain_text_size,
246 frame.key_id,
247 frame.key_id_size));
139 } 248 }
140 249
141 TEST_F(AesDecryptorTest, WrongSizedKey) { 250 TEST_F(AesDecryptorTest, WrongSizedKey) {
142 GenerateKeyRequest(); 251 const WebmEncryptedData& frame = kEncryptedFrames[0];
143 AddKeyAndExpectToFail(kKeyId1, kWrongSizedKey); 252 GenerateKeyRequest(frame.key_id, frame.key_id_size);
253 AddKeyAndExpectToFail(frame.key_id, frame.key_id_size,
254 kWrongSizedKey, arraysize(kWrongSizedKey));
144 } 255 }
145 256
146 } // media 257 TEST_F(AesDecryptorTest, MultipleKeysAndFrames) {
258 const WebmEncryptedData& frame = kEncryptedFrames[0];
259 GenerateKeyRequest(frame.key_id, frame.key_id_size);
260 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
261 frame.key, frame.key_size);
262 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(frame.encrypted_data,
263 frame.encrypted_data_size,
264 frame.plain_text,
265 frame.plain_text_size,
266 frame.key_id,
267 frame.key_id_size));
268
269 const WebmEncryptedData& frame2 = kEncryptedFrames[2];
ddorwin 2012/07/11 01:00:27 Probably more interesting if the keys are added be
fgalligan1 2012/07/11 22:06:33 I changed this to add_key1, decrypt_key1, add_key2
270 GenerateKeyRequest(frame2.key_id, frame2.key_id_size);
271 AddKeyAndExpectToSucceed(frame2.key_id, frame2.key_id_size,
272 frame2.key, frame2.key_size);
273 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed(frame2.encrypted_data,
274 frame2.encrypted_data_size,
275 frame2.plain_text,
276 frame2.plain_text_size,
277 frame2.key_id,
278 frame2.key_id_size));
279 }
280
281 TEST_F(AesDecryptorTest, HmacCheckFailure) {
282 const WebmEncryptedData& frame = kEncryptedFrames[0];
283 GenerateKeyRequest(frame.key_id, frame.key_id_size);
284 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
285 frame.key, frame.key_size);
286 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(kFrame0InvalidHmac,
287 frame.encrypted_data_size,
288 frame.plain_text,
289 frame.plain_text_size,
290 frame.key_id,
291 frame.key_id_size));
292 }
293
294 TEST_F(AesDecryptorTest, IvCheckFailure) {
295 const WebmEncryptedData& frame = kEncryptedFrames[0];
296 GenerateKeyRequest(frame.key_id, frame.key_id_size);
297 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
298 frame.key, frame.key_size);
299 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(kFrame0InvalidIv,
300 frame.encrypted_data_size,
301 frame.plain_text,
302 frame.plain_text_size,
303 frame.key_id,
304 frame.key_id_size));
305 }
306
307 TEST_F(AesDecryptorTest, DataCheckFailure) {
308 const WebmEncryptedData& frame = kEncryptedFrames[0];
309 GenerateKeyRequest(frame.key_id, frame.key_id_size);
310 AddKeyAndExpectToSucceed(frame.key_id, frame.key_id_size,
311 frame.key, frame.key_size);
312 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(kFrame0InvalidData,
313 frame.encrypted_data_size,
314 frame.plain_text,
315 frame.plain_text_size,
316 frame.key_id,
317 frame.key_id_size));
318 }
319
320 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698