This is the second code drop for the white-box api reference implementation and tests. This corrects the errors in the license white-box reference implementation and implements the remaining test cases. It should be noted that there is one test case missing, the test case for handling ChromeOS's unique policy settings. In order to make the tests easier to create and read, a license builder class was created and golden content and keys were wrapped in their own classes. How key errors are communicated was changed in the API. WB_RESULT_NO_SUCH_KEY and WB_RESULT_WRONG_KEY_TYPE were merged into WB_RESULT_KEY_UNAVAILABLE.
93 lines
3.1 KiB
C++
93 lines
3.1 KiB
C++
// Copyright 2020 Google LLC. All Rights Reserved.
|
|
|
|
#include "api/golden_data.h"
|
|
|
|
namespace widevine {
|
|
|
|
GoldenData::GoldenData() {
|
|
// Content generated with:
|
|
// openssl aes-128-cbc -e -in data.txt
|
|
// -K EBDD62F16814D27B68EF122AFCE4AE3C
|
|
// -iv 30313233343536373839303132333435 | xxd -i
|
|
// Extra padding was stripped off.
|
|
cbc_content_ = {
|
|
/* plaintext */ {'t', 'h', 'i', 's', ' ', 'i', 's', ' ', 't', 'h', 'e',
|
|
' ', 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't', ' ',
|
|
':', ' ', '3', '2', ' ', 'b', 'y', 't', 'e', 's'},
|
|
/* ciphertext */
|
|
{0x5e, 0x60, 0x0d, 0x3c, 0x29, 0xb9, 0x49, 0x4c, 0x65, 0x67, 0x7e,
|
|
0x87, 0x82, 0x9d, 0x47, 0x58, 0xb9, 0x86, 0xd0, 0x39, 0x6a, 0x67,
|
|
0x2c, 0x53, 0xe9, 0xbc, 0x99, 0x5b, 0x23, 0x34, 0x9f, 0xf8},
|
|
/* key */
|
|
{0xEB, 0xDD, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B, 0x68, 0xEF, 0x12, 0x2A,
|
|
0xFC, 0xE4, 0xAE, 0x3C},
|
|
/* iv */
|
|
{0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31,
|
|
0x32, 0x33, 0x34, 0x35},
|
|
};
|
|
|
|
cbc_crypto_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_SW_SECURE_CRYPTO,
|
|
{0xFF, 0, 0, 0},
|
|
&cbc_content_,
|
|
};
|
|
|
|
cbc_decode_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_SW_SECURE_DECODE,
|
|
{0xFF, 1, 0, 0},
|
|
&cbc_content_,
|
|
};
|
|
|
|
cbc_hardware_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_HW_SECURE_CRYPTO,
|
|
{0xFF, 2, 0, 0},
|
|
&cbc_content_,
|
|
};
|
|
|
|
// Content generated with:
|
|
// openssl aes-128-ctr -e -in data.txt
|
|
// -K dd3c6cd4ea73b99d55f2e0357e1f560f
|
|
// -iv d50c08b31fc09e9e748431ca972334e6 | xxd -i
|
|
ctr_content_ = {
|
|
/* plaintext */ {'T', 'h', 'i', 'r', 't', 'y', '-', 't', 'w', 'o', ' ',
|
|
'b', 'y', 't', 'e', 's', ' ', 'o', 'f', ' ', 'r', 'a',
|
|
'n', 'd', 'o', 'm', ' ', 'd', 'a', 't', 'a', '.'},
|
|
/* ciphertext */
|
|
{0x5d, 0x83, 0xdd, 0xb9, 0xed, 0x18, 0x2f, 0x10, 0xbf, 0x6f, 0x4d,
|
|
0xb0, 0xb3, 0xeb, 0x0d, 0x20, 0xd7, 0x7e, 0x9a, 0x3a, 0xc4, 0x41,
|
|
0xcf, 0x0a, 0xb3, 0xae, 0x02, 0x01, 0x0a, 0xf2, 0x72, 0x72},
|
|
/* key */
|
|
{0xdd, 0x3c, 0x6c, 0xd4, 0xea, 0x73, 0xb9, 0x9d, 0x55, 0xf2, 0xe0, 0x35,
|
|
0x7e, 0x1f, 0x56, 0x0f},
|
|
/* iv */
|
|
{0xd5, 0x0c, 0x08, 0xb3, 0x1f, 0xc0, 0x9e, 0x9e, 0x74, 0x84, 0x31, 0xca,
|
|
0x97, 0x23, 0x34, 0xe6},
|
|
};
|
|
|
|
ctr_crypto_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_SW_SECURE_CRYPTO,
|
|
{0xFF, 3, 0, 0},
|
|
&ctr_content_,
|
|
};
|
|
|
|
ctr_decode_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_SW_SECURE_DECODE,
|
|
{0xFF, 4, 0, 0},
|
|
&ctr_content_,
|
|
};
|
|
|
|
ctr_hardware_key_ = {
|
|
video_widevine::License_KeyContainer_SecurityLevel_HW_SECURE_CRYPTO,
|
|
{0xFF, 5, 0, 0},
|
|
&ctr_content_,
|
|
};
|
|
}
|
|
|
|
void GoldenData::MakeKeyIdDifferent(std::vector<uint8_t>* key_id) const {
|
|
// All our internal key ids start with 0xFF, so pushing something that is not
|
|
// 0xFF to the front will ensure that they don't collide.
|
|
key_id->insert(key_id->begin(), 0xAB);
|
|
}
|
|
|
|
} // namespace widevine
|