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 "media/cdm/json_web_key.h" | 5 #include "media/cdm/json_web_key.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 KeyIdAndKeyPairs keys; | 33 KeyIdAndKeyPairs keys; |
34 MediaKeys::SessionType session_type; | 34 MediaKeys::SessionType session_type; |
35 EXPECT_EQ(expected_result, | 35 EXPECT_EQ(expected_result, |
36 ExtractKeysFromJWKSet(jwk, &keys, &session_type)); | 36 ExtractKeysFromJWKSet(jwk, &keys, &session_type)); |
37 if (expected_result) { | 37 if (expected_result) { |
38 // Only check if successful. | 38 // Only check if successful. |
39 EXPECT_EQ(expected_type, session_type); | 39 EXPECT_EQ(expected_type, session_type); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void CreateLicenseAndExpect(const uint8* key_id, | 43 void CreateLicenseAndExpect(const uint8_t* key_id, |
44 int key_id_length, | 44 int key_id_length, |
45 MediaKeys::SessionType session_type, | 45 MediaKeys::SessionType session_type, |
46 const std::string& expected_result) { | 46 const std::string& expected_result) { |
47 std::vector<uint8> result; | 47 std::vector<uint8_t> result; |
48 KeyIdList key_ids; | 48 KeyIdList key_ids; |
49 key_ids.push_back(std::vector<uint8>(key_id, key_id + key_id_length)); | 49 key_ids.push_back(std::vector<uint8_t>(key_id, key_id + key_id_length)); |
50 CreateLicenseRequest(key_ids, session_type, &result); | 50 CreateLicenseRequest(key_ids, session_type, &result); |
51 std::string s(result.begin(), result.end()); | 51 std::string s(result.begin(), result.end()); |
52 EXPECT_EQ(expected_result, s); | 52 EXPECT_EQ(expected_result, s); |
53 } | 53 } |
54 | 54 |
55 void ExtractKeyFromLicenseAndExpect(const std::string& license, | 55 void ExtractKeyFromLicenseAndExpect(const std::string& license, |
56 bool expected_result, | 56 bool expected_result, |
57 const uint8* expected_key, | 57 const uint8_t* expected_key, |
58 int expected_key_length) { | 58 int expected_key_length) { |
59 std::vector<uint8> license_vector(license.begin(), license.end()); | 59 std::vector<uint8_t> license_vector(license.begin(), license.end()); |
60 std::vector<uint8> key; | 60 std::vector<uint8_t> key; |
61 EXPECT_EQ(expected_result, | 61 EXPECT_EQ(expected_result, |
62 ExtractFirstKeyIdFromLicenseRequest(license_vector, &key)); | 62 ExtractFirstKeyIdFromLicenseRequest(license_vector, &key)); |
63 if (expected_result) | 63 if (expected_result) |
64 VerifyKeyId(key, expected_key, expected_key_length); | 64 VerifyKeyId(key, expected_key, expected_key_length); |
65 } | 65 } |
66 | 66 |
67 void VerifyKeyId(std::vector<uint8> key, | 67 void VerifyKeyId(std::vector<uint8_t> key, |
68 const uint8* expected_key, | 68 const uint8_t* expected_key, |
69 int expected_key_length) { | 69 int expected_key_length) { |
70 std::vector<uint8> key_result(expected_key, | 70 std::vector<uint8_t> key_result(expected_key, |
71 expected_key + expected_key_length); | 71 expected_key + expected_key_length); |
72 EXPECT_EQ(key_result, key); | 72 EXPECT_EQ(key_result, key); |
73 } | 73 } |
74 | 74 |
75 KeyIdAndKeyPair MakeKeyIdAndKeyPair(const uint8* key, | 75 KeyIdAndKeyPair MakeKeyIdAndKeyPair(const uint8_t* key, |
76 int key_length, | 76 int key_length, |
77 const uint8* key_id, | 77 const uint8_t* key_id, |
78 int key_id_length) { | 78 int key_id_length) { |
79 return std::make_pair(std::string(key_id, key_id + key_id_length), | 79 return std::make_pair(std::string(key_id, key_id + key_id_length), |
80 std::string(key, key + key_length)); | 80 std::string(key, key + key_length)); |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 TEST_F(JSONWebKeyTest, GenerateJWKSet) { | 84 TEST_F(JSONWebKeyTest, GenerateJWKSet) { |
85 const uint8 data1[] = { 0x01, 0x02 }; | 85 const uint8_t data1[] = {0x01, 0x02}; |
86 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 86 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
87 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 87 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
88 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 88 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
89 | 89 |
90 EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}", | 90 EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}", |
91 GenerateJWKSet(data1, arraysize(data1), data1, arraysize(data1))); | 91 GenerateJWKSet(data1, arraysize(data1), data1, arraysize(data1))); |
92 EXPECT_EQ( | 92 EXPECT_EQ( |
93 "{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}", | 93 "{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}", |
94 GenerateJWKSet(data2, arraysize(data2), data2, arraysize(data2))); | 94 GenerateJWKSet(data2, arraysize(data2), data2, arraysize(data2))); |
95 EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}", | 95 EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}", |
96 GenerateJWKSet(data1, arraysize(data1), data2, arraysize(data2))); | 96 GenerateJWKSet(data1, arraysize(data1), data2, arraysize(data2))); |
97 EXPECT_EQ("{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}", | 97 EXPECT_EQ("{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}", |
98 GenerateJWKSet(data2, arraysize(data2), data1, arraysize(data1))); | 98 GenerateJWKSet(data2, arraysize(data2), data1, arraysize(data1))); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 ExtractSessionTypeAndExpect( | 409 ExtractSessionTypeAndExpect( |
410 "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}],\"type\":" | 410 "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}],\"type\":" |
411 "\"unknown\"}", | 411 "\"unknown\"}", |
412 false, MediaKeys::TEMPORARY_SESSION); | 412 false, MediaKeys::TEMPORARY_SESSION); |
413 ExtractSessionTypeAndExpect( | 413 ExtractSessionTypeAndExpect( |
414 "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}],\"type\":3}", | 414 "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}],\"type\":3}", |
415 false, MediaKeys::TEMPORARY_SESSION); | 415 false, MediaKeys::TEMPORARY_SESSION); |
416 } | 416 } |
417 | 417 |
418 TEST_F(JSONWebKeyTest, CreateLicense) { | 418 TEST_F(JSONWebKeyTest, CreateLicense) { |
419 const uint8 data1[] = { 0x01, 0x02 }; | 419 const uint8_t data1[] = {0x01, 0x02}; |
420 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 420 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
421 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 421 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
422 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 422 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
423 | 423 |
424 CreateLicenseAndExpect(data1, | 424 CreateLicenseAndExpect(data1, |
425 arraysize(data1), | 425 arraysize(data1), |
426 MediaKeys::TEMPORARY_SESSION, | 426 MediaKeys::TEMPORARY_SESSION, |
427 "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}"); | 427 "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}"); |
428 CreateLicenseAndExpect( | 428 CreateLicenseAndExpect( |
429 data1, arraysize(data1), MediaKeys::PERSISTENT_LICENSE_SESSION, | 429 data1, arraysize(data1), MediaKeys::PERSISTENT_LICENSE_SESSION, |
430 "{\"kids\":[\"AQI\"],\"type\":\"persistent-license\"}"); | 430 "{\"kids\":[\"AQI\"],\"type\":\"persistent-license\"}"); |
431 CreateLicenseAndExpect( | 431 CreateLicenseAndExpect( |
432 data1, arraysize(data1), MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION, | 432 data1, arraysize(data1), MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION, |
433 "{\"kids\":[\"AQI\"],\"type\":\"persistent-release-message\"}"); | 433 "{\"kids\":[\"AQI\"],\"type\":\"persistent-release-message\"}"); |
434 CreateLicenseAndExpect(data2, | 434 CreateLicenseAndExpect(data2, |
435 arraysize(data2), | 435 arraysize(data2), |
436 MediaKeys::TEMPORARY_SESSION, | 436 MediaKeys::TEMPORARY_SESSION, |
437 "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}"); | 437 "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}"); |
438 CreateLicenseAndExpect(data3, arraysize(data3), | 438 CreateLicenseAndExpect(data3, arraysize(data3), |
439 MediaKeys::PERSISTENT_LICENSE_SESSION, | 439 MediaKeys::PERSISTENT_LICENSE_SESSION, |
440 "{\"kids\":[\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":" | 440 "{\"kids\":[\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":" |
441 "\"persistent-license\"}"); | 441 "\"persistent-license\"}"); |
442 } | 442 } |
443 | 443 |
444 TEST_F(JSONWebKeyTest, ExtractLicense) { | 444 TEST_F(JSONWebKeyTest, ExtractLicense) { |
445 const uint8 data1[] = { 0x01, 0x02 }; | 445 const uint8_t data1[] = {0x01, 0x02}; |
446 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 446 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
447 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 447 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
448 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 448 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
449 | 449 |
450 ExtractKeyFromLicenseAndExpect( | 450 ExtractKeyFromLicenseAndExpect( |
451 "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}", | 451 "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}", |
452 true, | 452 true, |
453 data1, | 453 data1, |
454 arraysize(data1)); | 454 arraysize(data1)); |
455 ExtractKeyFromLicenseAndExpect( | 455 ExtractKeyFromLicenseAndExpect( |
456 "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}", | 456 "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}", |
457 true, | 457 true, |
458 data2, | 458 data2, |
(...skipping 19 matching lines...) Expand all Loading... |
478 ExtractKeyFromLicenseAndExpect("{\"kids\":[]}", false, NULL, 0); | 478 ExtractKeyFromLicenseAndExpect("{\"kids\":[]}", false, NULL, 0); |
479 | 479 |
480 // Correct tag, but list doesn't contain a string. | 480 // Correct tag, but list doesn't contain a string. |
481 ExtractKeyFromLicenseAndExpect("{\"kids\":[[\"AQI\"]]}", false, NULL, 0); | 481 ExtractKeyFromLicenseAndExpect("{\"kids\":[[\"AQI\"]]}", false, NULL, 0); |
482 | 482 |
483 // Correct tag, but invalid base64 encoding. | 483 // Correct tag, but invalid base64 encoding. |
484 ExtractKeyFromLicenseAndExpect("{\"kids\":[\"!@#$%^&*()\"]}", false, NULL, 0); | 484 ExtractKeyFromLicenseAndExpect("{\"kids\":[\"!@#$%^&*()\"]}", false, NULL, 0); |
485 } | 485 } |
486 | 486 |
487 TEST_F(JSONWebKeyTest, Base64UrlEncoding) { | 487 TEST_F(JSONWebKeyTest, Base64UrlEncoding) { |
488 const uint8 data1[] = { 0xfb, 0xfd, 0xfb, 0xfd, 0xfb, 0xfd, 0xfb }; | 488 const uint8_t data1[] = {0xfb, 0xfd, 0xfb, 0xfd, 0xfb, 0xfd, 0xfb}; |
489 | 489 |
490 // Verify that |data1| contains invalid base64url characters '+' and '/' | 490 // Verify that |data1| contains invalid base64url characters '+' and '/' |
491 // and is padded with = when converted to base64. | 491 // and is padded with = when converted to base64. |
492 std::string encoded_text; | 492 std::string encoded_text; |
493 base::Base64Encode( | 493 base::Base64Encode( |
494 std::string(reinterpret_cast<const char*>(&data1[0]), arraysize(data1)), | 494 std::string(reinterpret_cast<const char*>(&data1[0]), arraysize(data1)), |
495 &encoded_text); | 495 &encoded_text); |
496 EXPECT_EQ(encoded_text, "+/37/fv9+w=="); | 496 EXPECT_EQ(encoded_text, "+/37/fv9+w=="); |
497 EXPECT_NE(encoded_text.find('+'), std::string::npos); | 497 EXPECT_NE(encoded_text.find('+'), std::string::npos); |
498 EXPECT_NE(encoded_text.find('/'), std::string::npos); | 498 EXPECT_NE(encoded_text.find('/'), std::string::npos); |
499 EXPECT_NE(encoded_text.find('='), std::string::npos); | 499 EXPECT_NE(encoded_text.find('='), std::string::npos); |
500 | 500 |
501 // base64url characters '-' and '_' not in base64 encoding. | 501 // base64url characters '-' and '_' not in base64 encoding. |
502 EXPECT_EQ(encoded_text.find('-'), std::string::npos); | 502 EXPECT_EQ(encoded_text.find('-'), std::string::npos); |
503 EXPECT_EQ(encoded_text.find('_'), std::string::npos); | 503 EXPECT_EQ(encoded_text.find('_'), std::string::npos); |
504 | 504 |
505 CreateLicenseAndExpect(data1, arraysize(data1), MediaKeys::TEMPORARY_SESSION, | 505 CreateLicenseAndExpect(data1, arraysize(data1), MediaKeys::TEMPORARY_SESSION, |
506 "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}"); | 506 "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}"); |
507 | 507 |
508 ExtractKeyFromLicenseAndExpect( | 508 ExtractKeyFromLicenseAndExpect( |
509 "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}", true, data1, | 509 "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}", true, data1, |
510 arraysize(data1)); | 510 arraysize(data1)); |
511 } | 511 } |
512 | 512 |
513 TEST_F(JSONWebKeyTest, MultipleKeys) { | 513 TEST_F(JSONWebKeyTest, MultipleKeys) { |
514 const uint8 data1[] = { 0x01, 0x02 }; | 514 const uint8_t data1[] = {0x01, 0x02}; |
515 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 515 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
516 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 516 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
517 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 517 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
518 | 518 |
519 std::vector<uint8> result; | 519 std::vector<uint8_t> result; |
520 KeyIdList key_ids; | 520 KeyIdList key_ids; |
521 key_ids.push_back(std::vector<uint8>(data1, data1 + arraysize(data1))); | 521 key_ids.push_back(std::vector<uint8_t>(data1, data1 + arraysize(data1))); |
522 key_ids.push_back(std::vector<uint8>(data2, data2 + arraysize(data2))); | 522 key_ids.push_back(std::vector<uint8_t>(data2, data2 + arraysize(data2))); |
523 key_ids.push_back(std::vector<uint8>(data3, data3 + arraysize(data3))); | 523 key_ids.push_back(std::vector<uint8_t>(data3, data3 + arraysize(data3))); |
524 CreateLicenseRequest(key_ids, MediaKeys::TEMPORARY_SESSION, &result); | 524 CreateLicenseRequest(key_ids, MediaKeys::TEMPORARY_SESSION, &result); |
525 std::string s(result.begin(), result.end()); | 525 std::string s(result.begin(), result.end()); |
526 EXPECT_EQ( | 526 EXPECT_EQ( |
527 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":" | 527 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":" |
528 "\"temporary\"}", | 528 "\"temporary\"}", |
529 s); | 529 s); |
530 } | 530 } |
531 | 531 |
532 TEST_F(JSONWebKeyTest, ExtractKeyIds) { | 532 TEST_F(JSONWebKeyTest, ExtractKeyIds) { |
533 const uint8 data1[] = { 0x01, 0x02 }; | 533 const uint8_t data1[] = {0x01, 0x02}; |
534 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 534 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
535 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 535 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
536 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 536 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
537 | 537 |
538 KeyIdList key_ids; | 538 KeyIdList key_ids; |
539 std::string error_message; | 539 std::string error_message; |
540 | 540 |
541 EXPECT_TRUE(ExtractKeyIdsFromKeyIdsInitData("{\"kids\":[\"AQI\"]}", &key_ids, | 541 EXPECT_TRUE(ExtractKeyIdsFromKeyIdsInitData("{\"kids\":[\"AQI\"]}", &key_ids, |
542 &error_message)); | 542 &error_message)); |
543 EXPECT_EQ(1u, key_ids.size()); | 543 EXPECT_EQ(1u, key_ids.size()); |
544 EXPECT_EQ(0u, error_message.length()); | 544 EXPECT_EQ(0u, error_message.length()); |
545 VerifyKeyId(key_ids[0], data1, arraysize(data1)); | 545 VerifyKeyId(key_ids[0], data1, arraysize(data1)); |
546 | 546 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 EXPECT_EQ(error_message, | 601 EXPECT_EQ(error_message, |
602 "'kids'[0] is not valid base64url encoded. Value: AQI+"); | 602 "'kids'[0] is not valid base64url encoded. Value: AQI+"); |
603 EXPECT_FALSE(ExtractKeyIdsFromKeyIdsInitData("{\"kids\":[\"AQI\",\"AQI/\"]}", | 603 EXPECT_FALSE(ExtractKeyIdsFromKeyIdsInitData("{\"kids\":[\"AQI\",\"AQI/\"]}", |
604 &key_ids, &error_message)); | 604 &key_ids, &error_message)); |
605 EXPECT_EQ(3u, key_ids.size()); // |key_ids| should be unchanged. | 605 EXPECT_EQ(3u, key_ids.size()); // |key_ids| should be unchanged. |
606 EXPECT_EQ(error_message, | 606 EXPECT_EQ(error_message, |
607 "'kids'[1] is not valid base64url encoded. Value: AQI/"); | 607 "'kids'[1] is not valid base64url encoded. Value: AQI/"); |
608 } | 608 } |
609 | 609 |
610 TEST_F(JSONWebKeyTest, CreateInitData) { | 610 TEST_F(JSONWebKeyTest, CreateInitData) { |
611 const uint8 data1[] = { 0x01, 0x02 }; | 611 const uint8_t data1[] = {0x01, 0x02}; |
612 const uint8 data2[] = { 0x01, 0x02, 0x03, 0x04 }; | 612 const uint8_t data2[] = {0x01, 0x02, 0x03, 0x04}; |
613 const uint8 data3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 613 const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
614 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }; | 614 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}; |
615 | 615 |
616 KeyIdList key_ids; | 616 KeyIdList key_ids; |
617 std::string error_message; | 617 std::string error_message; |
618 | 618 |
619 key_ids.push_back(std::vector<uint8>(data1, data1 + arraysize(data1))); | 619 key_ids.push_back(std::vector<uint8_t>(data1, data1 + arraysize(data1))); |
620 std::vector<uint8> init_data1; | 620 std::vector<uint8_t> init_data1; |
621 CreateKeyIdsInitData(key_ids, &init_data1); | 621 CreateKeyIdsInitData(key_ids, &init_data1); |
622 std::string result1(init_data1.begin(), init_data1.end()); | 622 std::string result1(init_data1.begin(), init_data1.end()); |
623 EXPECT_EQ(result1, "{\"kids\":[\"AQI\"]}"); | 623 EXPECT_EQ(result1, "{\"kids\":[\"AQI\"]}"); |
624 | 624 |
625 key_ids.push_back(std::vector<uint8>(data2, data2 + arraysize(data2))); | 625 key_ids.push_back(std::vector<uint8_t>(data2, data2 + arraysize(data2))); |
626 std::vector<uint8> init_data2; | 626 std::vector<uint8_t> init_data2; |
627 CreateKeyIdsInitData(key_ids, &init_data2); | 627 CreateKeyIdsInitData(key_ids, &init_data2); |
628 std::string result2(init_data2.begin(), init_data2.end()); | 628 std::string result2(init_data2.begin(), init_data2.end()); |
629 EXPECT_EQ(result2, "{\"kids\":[\"AQI\",\"AQIDBA\"]}"); | 629 EXPECT_EQ(result2, "{\"kids\":[\"AQI\",\"AQIDBA\"]}"); |
630 | 630 |
631 key_ids.push_back(std::vector<uint8>(data3, data3 + arraysize(data3))); | 631 key_ids.push_back(std::vector<uint8_t>(data3, data3 + arraysize(data3))); |
632 std::vector<uint8> init_data3; | 632 std::vector<uint8_t> init_data3; |
633 CreateKeyIdsInitData(key_ids, &init_data3); | 633 CreateKeyIdsInitData(key_ids, &init_data3); |
634 std::string result3(init_data3.begin(), init_data3.end()); | 634 std::string result3(init_data3.begin(), init_data3.end()); |
635 EXPECT_EQ(result3, | 635 EXPECT_EQ(result3, |
636 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"); | 636 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"); |
637 } | 637 } |
638 | 638 |
639 } // namespace media | 639 } // namespace media |
640 | 640 |
OLD | NEW |