OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | |
9 #include "base/bind.h" | 8 #include "base/bind.h" |
10 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
11 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
12 #include "base/values.h" | 11 #include "base/values.h" |
13 #include "media/base/cdm_callback_promise.h" | 12 #include "media/base/cdm_callback_promise.h" |
14 #include "media/base/cdm_config.h" | 13 #include "media/base/cdm_config.h" |
15 #include "media/base/cdm_key_information.h" | 14 #include "media/base/cdm_key_information.h" |
16 #include "media/base/decoder_buffer.h" | 15 #include "media/base/decoder_buffer.h" |
17 #include "media/base/decrypt_config.h" | 16 #include "media/base/decrypt_config.h" |
18 #include "media/base/decryptor.h" | 17 #include "media/base/decryptor.h" |
(...skipping 18 matching lines...) Expand all Loading... |
37 MATCHER(IsEmpty, "") { return arg.empty(); } | 36 MATCHER(IsEmpty, "") { return arg.empty(); } |
38 MATCHER(IsNotEmpty, "") { return !arg.empty(); } | 37 MATCHER(IsNotEmpty, "") { return !arg.empty(); } |
39 MATCHER(IsJSONDictionary, "") { | 38 MATCHER(IsJSONDictionary, "") { |
40 std::string result(arg.begin(), arg.end()); | 39 std::string result(arg.begin(), arg.end()); |
41 scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(result)); | 40 scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(result)); |
42 return (root.get() && root->GetType() == base::Value::TYPE_DICTIONARY); | 41 return (root.get() && root->GetType() == base::Value::TYPE_DICTIONARY); |
43 } | 42 } |
44 | 43 |
45 namespace media { | 44 namespace media { |
46 | 45 |
47 const uint8 kOriginalData[] = "Original subsample data."; | 46 const uint8_t kOriginalData[] = "Original subsample data."; |
48 const int kOriginalDataSize = 24; | 47 const int kOriginalDataSize = 24; |
49 | 48 |
50 // In the examples below, 'k'(key) has to be 16 bytes, and will always require | 49 // In the examples below, 'k'(key) has to be 16 bytes, and will always require |
51 // 2 bytes of padding. 'kid'(keyid) is variable length, and may require 0, 1, | 50 // 2 bytes of padding. 'kid'(keyid) is variable length, and may require 0, 1, |
52 // or 2 bytes of padding. | 51 // or 2 bytes of padding. |
53 | 52 |
54 const uint8 kKeyId[] = { | 53 const uint8_t kKeyId[] = { |
55 // base64 equivalent is AAECAw | 54 // base64 equivalent is AAECAw |
56 0x00, 0x01, 0x02, 0x03 | 55 0x00, 0x01, 0x02, 0x03}; |
57 }; | |
58 | 56 |
59 // Key is 0x0405060708090a0b0c0d0e0f10111213, | 57 // Key is 0x0405060708090a0b0c0d0e0f10111213, |
60 // base64 equivalent is BAUGBwgJCgsMDQ4PEBESEw. | 58 // base64 equivalent is BAUGBwgJCgsMDQ4PEBESEw. |
61 const char kKeyAsJWK[] = | 59 const char kKeyAsJWK[] = |
62 "{" | 60 "{" |
63 " \"keys\": [" | 61 " \"keys\": [" |
64 " {" | 62 " {" |
65 " \"kty\": \"oct\"," | 63 " \"kty\": \"oct\"," |
66 " \"alg\": \"A128KW\"," | 64 " \"alg\": \"A128KW\"," |
67 " \"kid\": \"AAECAw\"," | 65 " \"kid\": \"AAECAw\"," |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 " \"keys\": [" | 99 " \"keys\": [" |
102 " {" | 100 " {" |
103 " \"kty\": \"oct\"," | 101 " \"kty\": \"oct\"," |
104 " \"alg\": \"A128KW\"," | 102 " \"alg\": \"A128KW\"," |
105 " \"kid\": \"AAECAw\"," | 103 " \"kid\": \"AAECAw\"," |
106 " \"k\": \"AAECAw\"" | 104 " \"k\": \"AAECAw\"" |
107 " }" | 105 " }" |
108 " ]" | 106 " ]" |
109 "}"; | 107 "}"; |
110 | 108 |
111 const uint8 kIv[] = { | 109 const uint8_t kIv[] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, |
112 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, | 110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
114 }; | |
115 | 111 |
116 // kOriginalData encrypted with kKey and kIv but without any subsamples (or | 112 // kOriginalData encrypted with kKey and kIv but without any subsamples (or |
117 // equivalently using kSubsampleEntriesCypherOnly). | 113 // equivalently using kSubsampleEntriesCypherOnly). |
118 const uint8 kEncryptedData[] = { | 114 const uint8_t kEncryptedData[] = { |
119 0x2f, 0x03, 0x09, 0xef, 0x71, 0xaf, 0x31, 0x16, | 115 0x2f, 0x03, 0x09, 0xef, 0x71, 0xaf, 0x31, 0x16, 0xfa, 0x9d, 0x18, 0x43, |
120 0xfa, 0x9d, 0x18, 0x43, 0x1e, 0x96, 0x71, 0xb5, | 116 0x1e, 0x96, 0x71, 0xb5, 0xbf, 0xf5, 0x30, 0x53, 0x9a, 0x20, 0xdf, 0x95}; |
121 0xbf, 0xf5, 0x30, 0x53, 0x9a, 0x20, 0xdf, 0x95 | |
122 }; | |
123 | 117 |
124 // kOriginalData encrypted with kSubsampleKey and kSubsampleIv using | 118 // kOriginalData encrypted with kSubsampleKey and kSubsampleIv using |
125 // kSubsampleEntriesNormal. | 119 // kSubsampleEntriesNormal. |
126 const uint8 kSubsampleEncryptedData[] = { | 120 const uint8_t kSubsampleEncryptedData[] = { |
127 0x4f, 0x72, 0x09, 0x16, 0x09, 0xe6, 0x79, 0xad, | 121 0x4f, 0x72, 0x09, 0x16, 0x09, 0xe6, 0x79, 0xad, 0x70, 0x73, 0x75, 0x62, |
128 0x70, 0x73, 0x75, 0x62, 0x09, 0xbb, 0x83, 0x1d, | 122 0x09, 0xbb, 0x83, 0x1d, 0x4d, 0x08, 0xd7, 0x78, 0xa4, 0xa7, 0xf1, 0x2e}; |
129 0x4d, 0x08, 0xd7, 0x78, 0xa4, 0xa7, 0xf1, 0x2e | |
130 }; | |
131 | 123 |
132 const uint8 kOriginalData2[] = "Changed Original data."; | 124 const uint8_t kOriginalData2[] = "Changed Original data."; |
133 | 125 |
134 const uint8 kIv2[] = { | 126 const uint8_t kIv2[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
137 }; | |
138 | 128 |
139 const uint8 kKeyId2[] = { | 129 const uint8_t kKeyId2[] = { |
140 // base64 equivalent is AAECAwQFBgcICQoLDA0ODxAREhM= | 130 // base64 equivalent is AAECAwQFBgcICQoLDA0ODxAREhM= |
141 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | 131 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, |
142 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | 132 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13}; |
143 0x10, 0x11, 0x12, 0x13 | |
144 }; | |
145 | 133 |
146 const char kKey2AsJWK[] = | 134 const char kKey2AsJWK[] = |
147 "{" | 135 "{" |
148 " \"keys\": [" | 136 " \"keys\": [" |
149 " {" | 137 " {" |
150 " \"kty\": \"oct\"," | 138 " \"kty\": \"oct\"," |
151 " \"alg\": \"A128KW\"," | 139 " \"alg\": \"A128KW\"," |
152 " \"kid\": \"AAECAwQFBgcICQoLDA0ODxAREhM\"," | 140 " \"kid\": \"AAECAwQFBgcICQoLDA0ODxAREhM\"," |
153 " \"k\": \"FBUWFxgZGhscHR4fICEiIw\"" | 141 " \"k\": \"FBUWFxgZGhscHR4fICEiIw\"" |
154 " }" | 142 " }" |
155 " ]" | 143 " ]" |
156 "}"; | 144 "}"; |
157 | 145 |
158 // 'k' in bytes is x14x15x16x17x18x19x1ax1bx1cx1dx1ex1fx20x21x22x23 | 146 // 'k' in bytes is x14x15x16x17x18x19x1ax1bx1cx1dx1ex1fx20x21x22x23 |
159 | 147 |
160 const uint8 kEncryptedData2[] = { | 148 const uint8_t kEncryptedData2[] = { |
161 0x57, 0x66, 0xf4, 0x12, 0x1a, 0xed, 0xb5, 0x79, | 149 0x57, 0x66, 0xf4, 0x12, 0x1a, 0xed, 0xb5, 0x79, 0x1c, 0x8e, 0x25, |
162 0x1c, 0x8e, 0x25, 0xd7, 0x17, 0xe7, 0x5e, 0x16, | 150 0xd7, 0x17, 0xe7, 0x5e, 0x16, 0xe3, 0x40, 0x08, 0x27, 0x11, 0xe9}; |
163 0xe3, 0x40, 0x08, 0x27, 0x11, 0xe9 | |
164 }; | |
165 | 151 |
166 // Subsample entries for testing. The sum of |cypher_bytes| and |clear_bytes| of | 152 // Subsample entries for testing. The sum of |cypher_bytes| and |clear_bytes| of |
167 // all entries must be equal to kOriginalDataSize to make the subsample entries | 153 // all entries must be equal to kOriginalDataSize to make the subsample entries |
168 // valid. | 154 // valid. |
169 | 155 |
170 const SubsampleEntry kSubsampleEntriesNormal[] = { | 156 const SubsampleEntry kSubsampleEntriesNormal[] = { |
171 { 2, 7 }, | 157 { 2, 7 }, |
172 { 3, 11 }, | 158 { 3, 11 }, |
173 { 1, 0 } | 159 { 1, 0 } |
174 }; | 160 }; |
(...skipping 16 matching lines...) Expand all Loading... |
191 { 9, 0 } | 177 { 9, 0 } |
192 }; | 178 }; |
193 | 179 |
194 const SubsampleEntry kSubsampleEntriesCypherOnly[] = { | 180 const SubsampleEntry kSubsampleEntriesCypherOnly[] = { |
195 { 0, 6 }, | 181 { 0, 6 }, |
196 { 0, 8 }, | 182 { 0, 8 }, |
197 { 0, 10 } | 183 { 0, 10 } |
198 }; | 184 }; |
199 | 185 |
200 static scoped_refptr<DecoderBuffer> CreateEncryptedBuffer( | 186 static scoped_refptr<DecoderBuffer> CreateEncryptedBuffer( |
201 const std::vector<uint8>& data, | 187 const std::vector<uint8_t>& data, |
202 const std::vector<uint8>& key_id, | 188 const std::vector<uint8_t>& key_id, |
203 const std::vector<uint8>& iv, | 189 const std::vector<uint8_t>& iv, |
204 const std::vector<SubsampleEntry>& subsample_entries) { | 190 const std::vector<SubsampleEntry>& subsample_entries) { |
205 DCHECK(!data.empty()); | 191 DCHECK(!data.empty()); |
206 scoped_refptr<DecoderBuffer> encrypted_buffer(new DecoderBuffer(data.size())); | 192 scoped_refptr<DecoderBuffer> encrypted_buffer(new DecoderBuffer(data.size())); |
207 memcpy(encrypted_buffer->writable_data(), &data[0], data.size()); | 193 memcpy(encrypted_buffer->writable_data(), &data[0], data.size()); |
208 CHECK(encrypted_buffer.get()); | 194 CHECK(encrypted_buffer.get()); |
209 std::string key_id_string( | 195 std::string key_id_string( |
210 reinterpret_cast<const char*>(key_id.empty() ? NULL : &key_id[0]), | 196 reinterpret_cast<const char*>(key_id.empty() ? NULL : &key_id[0]), |
211 key_id.size()); | 197 key_id.size()); |
212 std::string iv_string( | 198 std::string iv_string( |
213 reinterpret_cast<const char*>(iv.empty() ? NULL : &iv[0]), iv.size()); | 199 reinterpret_cast<const char*>(iv.empty() ? NULL : &iv[0]), iv.size()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 EXPECT_GT(session_id.length(), 0ul); | 277 EXPECT_GT(session_id.length(), 0ul); |
292 session_id_ = session_id; | 278 session_id_ = session_id; |
293 } | 279 } |
294 | 280 |
295 void OnResolve(ExpectedResult expected_result) { | 281 void OnResolve(ExpectedResult expected_result) { |
296 EXPECT_EQ(expected_result, RESOLVED) << "Unexpectedly resolved."; | 282 EXPECT_EQ(expected_result, RESOLVED) << "Unexpectedly resolved."; |
297 } | 283 } |
298 | 284 |
299 void OnReject(ExpectedResult expected_result, | 285 void OnReject(ExpectedResult expected_result, |
300 MediaKeys::Exception exception_code, | 286 MediaKeys::Exception exception_code, |
301 uint32 system_code, | 287 uint32_t system_code, |
302 const std::string& error_message) { | 288 const std::string& error_message) { |
303 EXPECT_EQ(expected_result, REJECTED) | 289 EXPECT_EQ(expected_result, REJECTED) |
304 << "Unexpectedly rejected with message: " << error_message; | 290 << "Unexpectedly rejected with message: " << error_message; |
305 } | 291 } |
306 | 292 |
307 scoped_ptr<SimpleCdmPromise> CreatePromise(ExpectedResult expected_result) { | 293 scoped_ptr<SimpleCdmPromise> CreatePromise(ExpectedResult expected_result) { |
308 scoped_ptr<SimpleCdmPromise> promise( | 294 scoped_ptr<SimpleCdmPromise> promise( |
309 new CdmCallbackPromise<>(base::Bind(&AesDecryptorTest::OnResolve, | 295 new CdmCallbackPromise<>(base::Bind(&AesDecryptorTest::OnResolve, |
310 base::Unretained(this), | 296 base::Unretained(this), |
311 expected_result), | 297 expected_result), |
(...skipping 10 matching lines...) Expand all Loading... |
322 base::Bind(&AesDecryptorTest::OnResolveWithSession, | 308 base::Bind(&AesDecryptorTest::OnResolveWithSession, |
323 base::Unretained(this), | 309 base::Unretained(this), |
324 expected_result), | 310 expected_result), |
325 base::Bind(&AesDecryptorTest::OnReject, | 311 base::Bind(&AesDecryptorTest::OnReject, |
326 base::Unretained(this), | 312 base::Unretained(this), |
327 expected_result))); | 313 expected_result))); |
328 return promise.Pass(); | 314 return promise.Pass(); |
329 } | 315 } |
330 | 316 |
331 // Creates a new session using |key_id|. Returns the session ID. | 317 // Creates a new session using |key_id|. Returns the session ID. |
332 std::string CreateSession(const std::vector<uint8>& key_id) { | 318 std::string CreateSession(const std::vector<uint8_t>& key_id) { |
333 DCHECK(!key_id.empty()); | 319 DCHECK(!key_id.empty()); |
334 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), | 320 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), |
335 GURL::EmptyGURL())); | 321 GURL::EmptyGURL())); |
336 cdm_->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, | 322 cdm_->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, |
337 EmeInitDataType::WEBM, key_id, | 323 EmeInitDataType::WEBM, key_id, |
338 CreateSessionPromise(RESOLVED)); | 324 CreateSessionPromise(RESOLVED)); |
339 // This expects the promise to be called synchronously, which is the case | 325 // This expects the promise to be called synchronously, which is the case |
340 // for AesDecryptor. | 326 // for AesDecryptor. |
341 return session_id_; | 327 return session_id_; |
342 } | 328 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 bool new_key_expected) { | 366 bool new_key_expected) { |
381 DCHECK(!key.empty()); | 367 DCHECK(!key.empty()); |
382 | 368 |
383 if (expected_result == RESOLVED) { | 369 if (expected_result == RESOLVED) { |
384 EXPECT_CALL(*this, | 370 EXPECT_CALL(*this, |
385 OnSessionKeysChangeCalled(session_id, new_key_expected)); | 371 OnSessionKeysChangeCalled(session_id, new_key_expected)); |
386 } else { | 372 } else { |
387 EXPECT_CALL(*this, OnSessionKeysChangeCalled(_, _)).Times(0); | 373 EXPECT_CALL(*this, OnSessionKeysChangeCalled(_, _)).Times(0); |
388 } | 374 } |
389 | 375 |
390 cdm_->UpdateSession(session_id, std::vector<uint8>(key.begin(), key.end()), | 376 cdm_->UpdateSession(session_id, |
| 377 std::vector<uint8_t>(key.begin(), key.end()), |
391 CreatePromise(expected_result)); | 378 CreatePromise(expected_result)); |
392 } | 379 } |
393 | 380 |
394 bool KeysInfoContains(std::vector<uint8> expected) { | 381 bool KeysInfoContains(std::vector<uint8_t> expected) { |
395 for (const auto& key_id : keys_info_) { | 382 for (const auto& key_id : keys_info_) { |
396 if (key_id->key_id == expected) | 383 if (key_id->key_id == expected) |
397 return true; | 384 return true; |
398 } | 385 } |
399 return false; | 386 return false; |
400 } | 387 } |
401 | 388 |
402 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, | 389 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, |
403 const scoped_refptr<DecoderBuffer>&)); | 390 const scoped_refptr<DecoderBuffer>&)); |
404 | 391 |
405 enum DecryptExpectation { | 392 enum DecryptExpectation { |
406 SUCCESS, | 393 SUCCESS, |
407 DATA_MISMATCH, | 394 DATA_MISMATCH, |
408 DATA_AND_SIZE_MISMATCH, | 395 DATA_AND_SIZE_MISMATCH, |
409 DECRYPT_ERROR, | 396 DECRYPT_ERROR, |
410 NO_KEY | 397 NO_KEY |
411 }; | 398 }; |
412 | 399 |
413 void DecryptAndExpect(const scoped_refptr<DecoderBuffer>& encrypted, | 400 void DecryptAndExpect(const scoped_refptr<DecoderBuffer>& encrypted, |
414 const std::vector<uint8>& plain_text, | 401 const std::vector<uint8_t>& plain_text, |
415 DecryptExpectation result) { | 402 DecryptExpectation result) { |
416 scoped_refptr<DecoderBuffer> decrypted; | 403 scoped_refptr<DecoderBuffer> decrypted; |
417 | 404 |
418 switch (result) { | 405 switch (result) { |
419 case SUCCESS: | 406 case SUCCESS: |
420 case DATA_MISMATCH: | 407 case DATA_MISMATCH: |
421 case DATA_AND_SIZE_MISMATCH: | 408 case DATA_AND_SIZE_MISMATCH: |
422 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kSuccess, NotNull())) | 409 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kSuccess, NotNull())) |
423 .WillOnce(SaveArg<1>(&decrypted)); | 410 .WillOnce(SaveArg<1>(&decrypted)); |
424 break; | 411 break; |
425 case DECRYPT_ERROR: | 412 case DECRYPT_ERROR: |
426 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kError, IsNull())) | 413 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kError, IsNull())) |
427 .WillOnce(SaveArg<1>(&decrypted)); | 414 .WillOnce(SaveArg<1>(&decrypted)); |
428 break; | 415 break; |
429 case NO_KEY: | 416 case NO_KEY: |
430 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kNoKey, IsNull())) | 417 EXPECT_CALL(*this, BufferDecrypted(Decryptor::kNoKey, IsNull())) |
431 .WillOnce(SaveArg<1>(&decrypted)); | 418 .WillOnce(SaveArg<1>(&decrypted)); |
432 break; | 419 break; |
433 } | 420 } |
434 | 421 |
435 if (GetParam() == "CdmAdapter") { | 422 if (GetParam() == "CdmAdapter") { |
436 ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/569736 | 423 ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/569736 |
437 decryptor_->Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); | 424 decryptor_->Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); |
438 } else { | 425 } else { |
439 decryptor_->Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); | 426 decryptor_->Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); |
440 } | 427 } |
441 | 428 |
442 std::vector<uint8> decrypted_text; | 429 std::vector<uint8_t> decrypted_text; |
443 if (decrypted.get() && decrypted->data_size()) { | 430 if (decrypted.get() && decrypted->data_size()) { |
444 decrypted_text.assign( | 431 decrypted_text.assign( |
445 decrypted->data(), decrypted->data() + decrypted->data_size()); | 432 decrypted->data(), decrypted->data() + decrypted->data_size()); |
446 } | 433 } |
447 | 434 |
448 switch (result) { | 435 switch (result) { |
449 case SUCCESS: | 436 case SUCCESS: |
450 EXPECT_EQ(plain_text, decrypted_text); | 437 EXPECT_EQ(plain_text, decrypted_text); |
451 break; | 438 break; |
452 case DATA_MISMATCH: | 439 case DATA_MISMATCH: |
453 EXPECT_EQ(plain_text.size(), decrypted_text.size()); | 440 EXPECT_EQ(plain_text.size(), decrypted_text.size()); |
454 EXPECT_NE(plain_text, decrypted_text); | 441 EXPECT_NE(plain_text, decrypted_text); |
455 break; | 442 break; |
456 case DATA_AND_SIZE_MISMATCH: | 443 case DATA_AND_SIZE_MISMATCH: |
457 EXPECT_NE(plain_text.size(), decrypted_text.size()); | 444 EXPECT_NE(plain_text.size(), decrypted_text.size()); |
458 break; | 445 break; |
459 case DECRYPT_ERROR: | 446 case DECRYPT_ERROR: |
460 case NO_KEY: | 447 case NO_KEY: |
461 EXPECT_TRUE(decrypted_text.empty()); | 448 EXPECT_TRUE(decrypted_text.empty()); |
462 break; | 449 break; |
463 } | 450 } |
464 } | 451 } |
465 | 452 |
466 MOCK_METHOD4(OnSessionMessage, | 453 MOCK_METHOD4(OnSessionMessage, |
467 void(const std::string& session_id, | 454 void(const std::string& session_id, |
468 MediaKeys::MessageType message_type, | 455 MediaKeys::MessageType message_type, |
469 const std::vector<uint8>& message, | 456 const std::vector<uint8_t>& message, |
470 const GURL& legacy_destination_url)); | 457 const GURL& legacy_destination_url)); |
471 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); | 458 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); |
472 MOCK_METHOD4(OnLegacySessionError, | 459 MOCK_METHOD4(OnLegacySessionError, |
473 void(const std::string& session_id, | 460 void(const std::string& session_id, |
474 MediaKeys::Exception exception, | 461 MediaKeys::Exception exception, |
475 uint32_t system_code, | 462 uint32_t system_code, |
476 const std::string& error_message)); | 463 const std::string& error_message)); |
477 MOCK_METHOD2(OnSessionExpirationUpdate, | 464 MOCK_METHOD2(OnSessionExpirationUpdate, |
478 void(const std::string& session_id, | 465 void(const std::string& session_id, |
479 const base::Time& new_expiry_time)); | 466 const base::Time& new_expiry_time)); |
480 | 467 |
481 scoped_refptr<MediaKeys> cdm_; | 468 scoped_refptr<MediaKeys> cdm_; |
482 Decryptor* decryptor_; | 469 Decryptor* decryptor_; |
483 Decryptor::DecryptCB decrypt_cb_; | 470 Decryptor::DecryptCB decrypt_cb_; |
484 std::string session_id_; | 471 std::string session_id_; |
485 CdmKeysInfo keys_info_; | 472 CdmKeysInfo keys_info_; |
486 | 473 |
487 // Helper class to load/unload External Clear Key Library, if necessary. | 474 // Helper class to load/unload External Clear Key Library, if necessary. |
488 scoped_ptr<ExternalClearKeyTestHelper> helper_; | 475 scoped_ptr<ExternalClearKeyTestHelper> helper_; |
489 | 476 |
490 base::MessageLoop message_loop_; | 477 base::MessageLoop message_loop_; |
491 | 478 |
492 // Constants for testing. | 479 // Constants for testing. |
493 const std::vector<uint8> original_data_; | 480 const std::vector<uint8_t> original_data_; |
494 const std::vector<uint8> encrypted_data_; | 481 const std::vector<uint8_t> encrypted_data_; |
495 const std::vector<uint8> subsample_encrypted_data_; | 482 const std::vector<uint8_t> subsample_encrypted_data_; |
496 const std::vector<uint8> key_id_; | 483 const std::vector<uint8_t> key_id_; |
497 const std::vector<uint8> iv_; | 484 const std::vector<uint8_t> iv_; |
498 const std::vector<SubsampleEntry> normal_subsample_entries_; | 485 const std::vector<SubsampleEntry> normal_subsample_entries_; |
499 const std::vector<SubsampleEntry> no_subsample_entries_; | 486 const std::vector<SubsampleEntry> no_subsample_entries_; |
500 }; | 487 }; |
501 | 488 |
502 TEST_P(AesDecryptorTest, CreateSessionWithNullInitData) { | 489 TEST_P(AesDecryptorTest, CreateSessionWithNullInitData) { |
503 EXPECT_CALL(*this, | 490 EXPECT_CALL(*this, |
504 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); | 491 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
505 cdm_->CreateSessionAndGenerateRequest( | 492 cdm_->CreateSessionAndGenerateRequest( |
506 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, std::vector<uint8>(), | 493 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
507 CreateSessionPromise(RESOLVED)); | 494 std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
508 } | 495 } |
509 | 496 |
510 TEST_P(AesDecryptorTest, MultipleCreateSession) { | 497 TEST_P(AesDecryptorTest, MultipleCreateSession) { |
511 EXPECT_CALL(*this, | 498 EXPECT_CALL(*this, |
512 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); | 499 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
513 cdm_->CreateSessionAndGenerateRequest( | 500 cdm_->CreateSessionAndGenerateRequest( |
514 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, std::vector<uint8>(), | 501 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
515 CreateSessionPromise(RESOLVED)); | 502 std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
516 | 503 |
517 EXPECT_CALL(*this, | 504 EXPECT_CALL(*this, |
518 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); | 505 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
519 cdm_->CreateSessionAndGenerateRequest( | 506 cdm_->CreateSessionAndGenerateRequest( |
520 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, std::vector<uint8>(), | 507 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
521 CreateSessionPromise(RESOLVED)); | 508 std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
522 | 509 |
523 EXPECT_CALL(*this, | 510 EXPECT_CALL(*this, |
524 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); | 511 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
525 cdm_->CreateSessionAndGenerateRequest( | 512 cdm_->CreateSessionAndGenerateRequest( |
526 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, std::vector<uint8>(), | 513 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
527 CreateSessionPromise(RESOLVED)); | 514 std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
528 } | 515 } |
529 | 516 |
530 TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { | 517 TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { |
531 const uint8 init_data[] = { | 518 const uint8_t init_data[] = { |
532 0x00, 0x00, 0x00, 0x44, // size = 68 | 519 0x00, 0x00, 0x00, 0x44, // size = 68 |
533 0x70, 0x73, 0x73, 0x68, // 'pssh' | 520 0x70, 0x73, 0x73, 0x68, // 'pssh' |
534 0x01, // version | 521 0x01, // version |
535 0x00, 0x00, 0x00, // flags | 522 0x00, 0x00, 0x00, // flags |
536 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // SystemID | 523 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // SystemID |
537 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, | 524 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, |
538 0x00, 0x00, 0x00, 0x02, // key count | 525 0x00, 0x00, 0x00, 0x02, // key count |
539 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, // key1 | 526 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, // key1 |
540 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, | 527 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, |
541 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, // key2 | 528 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, // key2 |
542 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, | 529 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, |
543 0x00, 0x00, 0x00, 0x00 // datasize | 530 0x00, 0x00, 0x00, 0x00 // datasize |
544 }; | 531 }; |
545 | 532 |
546 #if defined(USE_PROPRIETARY_CODECS) | 533 #if defined(USE_PROPRIETARY_CODECS) |
547 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), | 534 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), |
548 GURL::EmptyGURL())); | 535 GURL::EmptyGURL())); |
549 cdm_->CreateSessionAndGenerateRequest( | 536 cdm_->CreateSessionAndGenerateRequest( |
550 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, | 537 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
551 std::vector<uint8>(init_data, init_data + arraysize(init_data)), | 538 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), |
552 CreateSessionPromise(RESOLVED)); | 539 CreateSessionPromise(RESOLVED)); |
553 #else | 540 #else |
554 cdm_->CreateSessionAndGenerateRequest( | 541 cdm_->CreateSessionAndGenerateRequest( |
555 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, | 542 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
556 std::vector<uint8>(init_data, init_data + arraysize(init_data)), | 543 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), |
557 CreateSessionPromise(REJECTED)); | 544 CreateSessionPromise(REJECTED)); |
558 #endif | 545 #endif |
559 } | 546 } |
560 | 547 |
561 TEST_P(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { | 548 TEST_P(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { |
562 const char init_data[] = | 549 const char init_data[] = |
563 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"; | 550 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"; |
564 | 551 |
565 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), | 552 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), |
566 GURL::EmptyGURL())); | 553 GURL::EmptyGURL())); |
567 cdm_->CreateSessionAndGenerateRequest( | 554 cdm_->CreateSessionAndGenerateRequest( |
568 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, | 555 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, |
569 std::vector<uint8>(init_data, init_data + arraysize(init_data) - 1), | 556 std::vector<uint8_t>(init_data, init_data + arraysize(init_data) - 1), |
570 CreateSessionPromise(RESOLVED)); | 557 CreateSessionPromise(RESOLVED)); |
571 } | 558 } |
572 | 559 |
573 TEST_P(AesDecryptorTest, NormalDecryption) { | 560 TEST_P(AesDecryptorTest, NormalDecryption) { |
574 std::string session_id = CreateSession(key_id_); | 561 std::string session_id = CreateSession(key_id_); |
575 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 562 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
576 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 563 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
577 encrypted_data_, key_id_, iv_, no_subsample_entries_); | 564 encrypted_data_, key_id_, iv_, no_subsample_entries_); |
578 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); | 565 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); |
579 } | 566 } |
580 | 567 |
581 TEST_P(AesDecryptorTest, UnencryptedFrame) { | 568 TEST_P(AesDecryptorTest, UnencryptedFrame) { |
582 // An empty iv string signals that the frame is unencrypted. | 569 // An empty iv string signals that the frame is unencrypted. |
583 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 570 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
584 original_data_, key_id_, std::vector<uint8>(), no_subsample_entries_); | 571 original_data_, key_id_, std::vector<uint8_t>(), no_subsample_entries_); |
585 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); | 572 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); |
586 } | 573 } |
587 | 574 |
588 TEST_P(AesDecryptorTest, WrongKey) { | 575 TEST_P(AesDecryptorTest, WrongKey) { |
589 std::string session_id = CreateSession(key_id_); | 576 std::string session_id = CreateSession(key_id_); |
590 UpdateSessionAndExpect(session_id, kWrongKeyAsJWK, RESOLVED, true); | 577 UpdateSessionAndExpect(session_id, kWrongKeyAsJWK, RESOLVED, true); |
591 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 578 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
592 encrypted_data_, key_id_, iv_, no_subsample_entries_); | 579 encrypted_data_, key_id_, iv_, no_subsample_entries_); |
593 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); | 580 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); |
594 } | 581 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); | 615 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); |
629 | 616 |
630 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED, true); | 617 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED, true); |
631 | 618 |
632 // The first key is still available after we added a second key. | 619 // The first key is still available after we added a second key. |
633 ASSERT_NO_FATAL_FAILURE( | 620 ASSERT_NO_FATAL_FAILURE( |
634 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); | 621 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); |
635 | 622 |
636 // The second key is also available. | 623 // The second key is also available. |
637 encrypted_buffer = CreateEncryptedBuffer( | 624 encrypted_buffer = CreateEncryptedBuffer( |
638 std::vector<uint8>(kEncryptedData2, | 625 std::vector<uint8_t>(kEncryptedData2, |
639 kEncryptedData2 + arraysize(kEncryptedData2)), | 626 kEncryptedData2 + arraysize(kEncryptedData2)), |
640 std::vector<uint8>(kKeyId2, kKeyId2 + arraysize(kKeyId2)), | 627 std::vector<uint8_t>(kKeyId2, kKeyId2 + arraysize(kKeyId2)), |
641 std::vector<uint8>(kIv2, kIv2 + arraysize(kIv2)), | 628 std::vector<uint8_t>(kIv2, kIv2 + arraysize(kIv2)), |
642 no_subsample_entries_); | 629 no_subsample_entries_); |
643 ASSERT_NO_FATAL_FAILURE(DecryptAndExpect( | 630 ASSERT_NO_FATAL_FAILURE(DecryptAndExpect( |
644 encrypted_buffer, | 631 encrypted_buffer, |
645 std::vector<uint8>(kOriginalData2, | 632 std::vector<uint8_t>(kOriginalData2, |
646 kOriginalData2 + arraysize(kOriginalData2) - 1), | 633 kOriginalData2 + arraysize(kOriginalData2) - 1), |
647 SUCCESS)); | 634 SUCCESS)); |
648 } | 635 } |
649 | 636 |
650 TEST_P(AesDecryptorTest, CorruptedIv) { | 637 TEST_P(AesDecryptorTest, CorruptedIv) { |
651 std::string session_id = CreateSession(key_id_); | 638 std::string session_id = CreateSession(key_id_); |
652 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 639 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
653 | 640 |
654 std::vector<uint8> bad_iv = iv_; | 641 std::vector<uint8_t> bad_iv = iv_; |
655 bad_iv[1]++; | 642 bad_iv[1]++; |
656 | 643 |
657 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 644 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
658 encrypted_data_, key_id_, bad_iv, no_subsample_entries_); | 645 encrypted_data_, key_id_, bad_iv, no_subsample_entries_); |
659 | 646 |
660 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); | 647 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); |
661 } | 648 } |
662 | 649 |
663 TEST_P(AesDecryptorTest, CorruptedData) { | 650 TEST_P(AesDecryptorTest, CorruptedData) { |
664 std::string session_id = CreateSession(key_id_); | 651 std::string session_id = CreateSession(key_id_); |
665 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 652 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
666 | 653 |
667 std::vector<uint8> bad_data = encrypted_data_; | 654 std::vector<uint8_t> bad_data = encrypted_data_; |
668 bad_data[1]++; | 655 bad_data[1]++; |
669 | 656 |
670 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 657 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
671 bad_data, key_id_, iv_, no_subsample_entries_); | 658 bad_data, key_id_, iv_, no_subsample_entries_); |
672 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); | 659 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); |
673 } | 660 } |
674 | 661 |
675 TEST_P(AesDecryptorTest, EncryptedAsUnencryptedFailure) { | 662 TEST_P(AesDecryptorTest, EncryptedAsUnencryptedFailure) { |
676 std::string session_id = CreateSession(key_id_); | 663 std::string session_id = CreateSession(key_id_); |
677 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 664 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
678 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 665 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
679 encrypted_data_, key_id_, std::vector<uint8>(), no_subsample_entries_); | 666 encrypted_data_, key_id_, std::vector<uint8_t>(), no_subsample_entries_); |
680 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); | 667 DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH); |
681 } | 668 } |
682 | 669 |
683 TEST_P(AesDecryptorTest, SubsampleDecryption) { | 670 TEST_P(AesDecryptorTest, SubsampleDecryption) { |
684 std::string session_id = CreateSession(key_id_); | 671 std::string session_id = CreateSession(key_id_); |
685 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 672 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
686 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 673 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
687 subsample_encrypted_data_, key_id_, iv_, normal_subsample_entries_); | 674 subsample_encrypted_data_, key_id_, iv_, normal_subsample_entries_); |
688 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); | 675 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS); |
689 } | 676 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 " \"kid\": \"\"," | 957 " \"kid\": \"\"," |
971 " \"k\": \"BAUGBwgJCgsMDQ4PEBESEw\"" | 958 " \"k\": \"BAUGBwgJCgsMDQ4PEBESEw\"" |
972 " }" | 959 " }" |
973 " ]" | 960 " ]" |
974 "}"; | 961 "}"; |
975 UpdateSessionAndExpect(session_id, kJwksWithEmptyKeyId, REJECTED, true); | 962 UpdateSessionAndExpect(session_id, kJwksWithEmptyKeyId, REJECTED, true); |
976 CloseSession(session_id); | 963 CloseSession(session_id); |
977 } | 964 } |
978 | 965 |
979 TEST_P(AesDecryptorTest, GetKeyIds) { | 966 TEST_P(AesDecryptorTest, GetKeyIds) { |
980 std::vector<uint8> key_id1(kKeyId, kKeyId + arraysize(kKeyId)); | 967 std::vector<uint8_t> key_id1(kKeyId, kKeyId + arraysize(kKeyId)); |
981 std::vector<uint8> key_id2(kKeyId2, kKeyId2 + arraysize(kKeyId2)); | 968 std::vector<uint8_t> key_id2(kKeyId2, kKeyId2 + arraysize(kKeyId2)); |
982 | 969 |
983 std::string session_id = CreateSession(key_id_); | 970 std::string session_id = CreateSession(key_id_); |
984 EXPECT_FALSE(KeysInfoContains(key_id1)); | 971 EXPECT_FALSE(KeysInfoContains(key_id1)); |
985 EXPECT_FALSE(KeysInfoContains(key_id2)); | 972 EXPECT_FALSE(KeysInfoContains(key_id2)); |
986 | 973 |
987 // Add 1 key, verify it is returned. | 974 // Add 1 key, verify it is returned. |
988 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 975 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
989 EXPECT_TRUE(KeysInfoContains(key_id1)); | 976 EXPECT_TRUE(KeysInfoContains(key_id1)); |
990 EXPECT_FALSE(KeysInfoContains(key_id2)); | 977 EXPECT_FALSE(KeysInfoContains(key_id2)); |
991 | 978 |
992 // Add second key, verify both IDs returned. | 979 // Add second key, verify both IDs returned. |
993 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED, true); | 980 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED, true); |
994 EXPECT_TRUE(KeysInfoContains(key_id1)); | 981 EXPECT_TRUE(KeysInfoContains(key_id1)); |
995 EXPECT_TRUE(KeysInfoContains(key_id2)); | 982 EXPECT_TRUE(KeysInfoContains(key_id2)); |
996 } | 983 } |
997 | 984 |
998 TEST_P(AesDecryptorTest, NoKeysChangeForSameKey) { | 985 TEST_P(AesDecryptorTest, NoKeysChangeForSameKey) { |
999 std::vector<uint8> key_id(kKeyId, kKeyId + arraysize(kKeyId)); | 986 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); |
1000 | 987 |
1001 std::string session_id = CreateSession(key_id_); | 988 std::string session_id = CreateSession(key_id_); |
1002 EXPECT_FALSE(KeysInfoContains(key_id)); | 989 EXPECT_FALSE(KeysInfoContains(key_id)); |
1003 | 990 |
1004 // Add key, verify it is returned. | 991 // Add key, verify it is returned. |
1005 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 992 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
1006 EXPECT_TRUE(KeysInfoContains(key_id)); | 993 EXPECT_TRUE(KeysInfoContains(key_id)); |
1007 | 994 |
1008 // Add key a second time. | 995 // Add key a second time. |
1009 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, false); | 996 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, false); |
(...skipping 12 matching lines...) Expand all Loading... |
1022 INSTANTIATE_TEST_CASE_P(CdmAdapter, | 1009 INSTANTIATE_TEST_CASE_P(CdmAdapter, |
1023 AesDecryptorTest, | 1010 AesDecryptorTest, |
1024 testing::Values("CdmAdapter")); | 1011 testing::Values("CdmAdapter")); |
1025 #endif | 1012 #endif |
1026 | 1013 |
1027 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ | 1014 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ |
1028 // MojoDecryptorService are implemented, add a third version that tests the | 1015 // MojoDecryptorService are implemented, add a third version that tests the |
1029 // CDM via mojo. | 1016 // CDM via mojo. |
1030 | 1017 |
1031 } // namespace media | 1018 } // namespace media |
OLD | NEW |