146 lines
5.8 KiB
C++
146 lines
5.8 KiB
C++
// Copyright 2020 Google LLC. All Rights Reserved.
|
|
|
|
#include "api/golden_data.h"
|
|
|
|
namespace widevine {
|
|
|
|
namespace {
|
|
|
|
GoldenData::Content CreateContent(const std::vector<uint8_t>& plaintext,
|
|
const std::vector<uint8_t>& ciphertext,
|
|
const AesIv& iv,
|
|
const AesKey& key,
|
|
const KeyId& undefined_key_id,
|
|
const KeyId& software_crypto_key_id,
|
|
const KeyId& software_decode_key_id,
|
|
const KeyId& hardware_key_id) {
|
|
GoldenData::Content content;
|
|
|
|
content.plaintext = plaintext;
|
|
content.ciphertext = ciphertext;
|
|
content.iv = iv;
|
|
|
|
content.undefined_key.id = undefined_key_id;
|
|
content.undefined_key.level = SecurityLevel::kUndefined;
|
|
content.undefined_key.key = key;
|
|
|
|
content.software_crypto_key.id = software_crypto_key_id;
|
|
content.software_crypto_key.level = SecurityLevel::kSoftwareSecureCrypto;
|
|
content.software_crypto_key.key = key;
|
|
|
|
content.software_decode_key.id = software_decode_key_id;
|
|
content.software_decode_key.level = SecurityLevel::kSoftwareSecureDecode;
|
|
content.software_decode_key.key = key;
|
|
|
|
content.hardware_key.id = hardware_key_id;
|
|
content.hardware_key.level = SecurityLevel::kHardwareSecureCrypto;
|
|
content.hardware_key.key = key;
|
|
|
|
return content;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
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_ = CreateContent(
|
|
/* 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},
|
|
/* iv= */
|
|
{0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31,
|
|
0x32, 0x33, 0x34, 0x35},
|
|
/* key= */
|
|
{0xEB, 0xDD, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B, 0x68, 0xEF, 0x12, 0x2A,
|
|
0xFC, 0xE4, 0xAE, 0x3C},
|
|
/* undefined_key_id= */ {0xFF, 0, 0, 0},
|
|
/* software_crypto_key_id= */ {0xFF, 1, 0, 0},
|
|
/* software_decode_key_id= */ {0xFF, 2, 0, 0},
|
|
/* hardware_key_id= */ {0xFF, 3, 0, 0});
|
|
|
|
// Content generated with:
|
|
// openssl aes-128-ctr -e -in data.txt
|
|
// -K dd3c6cd4ea73b99d55f2e0357e1f560f
|
|
// -iv d50c08b31fc09e9e748431ca972334e6 | xxd -i
|
|
ctr_content_ = CreateContent(
|
|
/* 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},
|
|
/* iv */
|
|
{0xd5, 0x0c, 0x08, 0xb3, 0x1f, 0xc0, 0x9e, 0x9e, 0x74, 0x84, 0x31, 0xca,
|
|
0x97, 0x23, 0x34, 0xe6},
|
|
/* key */
|
|
{0xdd, 0x3c, 0x6c, 0xd4, 0xea, 0x73, 0xb9, 0x9d, 0x55, 0xf2, 0xe0, 0x35,
|
|
0x7e, 0x1f, 0x56, 0x0f},
|
|
/* undefined_key_id= */ {0xFF, 4, 0, 0},
|
|
/* software_crypto_key_id= */ {0xFF, 5, 0, 0},
|
|
/* software_decode_key_id= */ {0xFF, 6, 0, 0},
|
|
/* hardware_key_id= */ {0xFF, 7, 0, 0});
|
|
|
|
// Key data generated with:
|
|
// echo 5ca79528bb76e14bf29c5bc853795a9b |
|
|
// xxd -r -ps |
|
|
// openssl aes-256-cbc -e
|
|
// -K 8e682447b6b46696eb874d1e38467784d849f3ed208f87cc83dbb4e3f357cea3
|
|
// -iv 6fc04cd8423d5f660ca045769a200048 |
|
|
// xxd -i
|
|
entitlement_.entitlement_key.id = GetFreeId();
|
|
entitlement_.entitlement_key.level = SecurityLevel::kSoftwareSecureCrypto;
|
|
entitlement_.entitlement_key.key = {
|
|
0x8e, 0x68, 0x24, 0x47, 0xb6, 0xb4, 0x66, 0x96,
|
|
0xeb, 0x87, 0x4d, 0x1e, 0x38, 0x46, 0x77, 0x84,
|
|
0xd8, 0x49, 0xf3, 0xed, 0x20, 0x8f, 0x87, 0xcc,
|
|
0x83, 0xdb, 0xb4, 0xe3, 0xf3, 0x57, 0xce, 0xa3,
|
|
};
|
|
entitlement_.key_data_iv = {
|
|
0x6f, 0xc0, 0x4c, 0xd8, 0x42, 0x3d, 0x5f, 0x66,
|
|
0x0c, 0xa0, 0x45, 0x76, 0x9a, 0x20, 0x00, 0x48,
|
|
};
|
|
entitlement_.key_data = {
|
|
0xf6, 0xed, 0x76, 0xe4, 0x54, 0x4f, 0x92, 0xd1,
|
|
0xb2, 0xf5, 0x68, 0xa0, 0x5e, 0x9c, 0x76, 0x00,
|
|
0xca, 0xc5, 0x08, 0xc5, 0x1b, 0xe3, 0x4a, 0xe6,
|
|
0xbe, 0x42, 0x40, 0x95, 0x18, 0x72, 0x5e, 0xce,
|
|
};
|
|
// Content generated with:
|
|
// openssl aes-128-ctr -e -in data.txt
|
|
// -K 5ca79528bb76e14bf29c5bc853795a9b
|
|
// -iv 02565ac40a2d159ff79aa97c97cb3b68 | xxd -i
|
|
entitlement_.iv = {
|
|
0x02, 0x56, 0x5a, 0xc4, 0x0a, 0x2d, 0x15, 0x9f,
|
|
0xf7, 0x9a, 0xa9, 0x7c, 0x97, 0xcb, 0x3b, 0x68,
|
|
};
|
|
entitlement_.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', '.',
|
|
};
|
|
entitlement_.ciphertext = {
|
|
0xaf, 0xcb, 0xd3, 0x42, 0x14, 0x46, 0x3c, 0x3a,
|
|
0x38, 0xe8, 0xfd, 0xed, 0x7f, 0x5b, 0x25, 0x78,
|
|
0xc9, 0xfc, 0x7b, 0x7d, 0x00, 0xf8, 0x75, 0xef,
|
|
0xde, 0xd2, 0xd9, 0xdd, 0x8c, 0xcd, 0x20, 0x49
|
|
};
|
|
}
|
|
|
|
KeyId GoldenData::GetFreeId() {
|
|
// All our internal key ids start with 0xFF, so starting with 0xAB should
|
|
// avoid conflicts.
|
|
return {0xAB, 0, 0, next_id_++};
|
|
}
|
|
|
|
} // namespace widevine
|