Refactor oemcrypto mock into stand alone reference code
Merge from Widevine repo of http://go/wvgerrit/46204 Refactor utility code - split the mock, step 1 Merge from Widevine repo of http://go/wvgerrit/46205 Move some OEMCrypto types to common header - split the mock, step 2 Merge from Widevine repo of http://go/wvgerrit/46206 Split mock into two -- step 3 Merge from Widevine repo of http://go/wvgerrit/47460 Split the mock into two -- step 3.5 The CL moves several files used by oemcrypto and cdm into a common subdirectory, so that it may more easily be shared with partners. The CORE_DISALLOW_COPY_AND_ASSIGN macro was moved to its own header in the util/include directory. This CL removes some references to the mock from other code, and puts some constants and types, such as the definition of the keybox, into a header in oemcrypto. Test: tested as part of http://go/ag/4674759 bug: 76393338 Change-Id: I75b4bde7062ed8ee572c97ebc2f4da018f4be0c9
This commit is contained in:
@@ -2,6 +2,9 @@ LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
vendor/widevine/libwvdrmengine/cdm/util/include \
|
||||
|
||||
LOCAL_MODULE:=oemcrypto_test
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/../include \
|
||||
$(LOCAL_PATH)/../mock/src \
|
||||
vendor/widevine/libwvdrmengine/cdm/core/include \
|
||||
vendor/widevine/libwvdrmengine/cdm/util/include \
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libcdm \
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "wv_keybox.h"
|
||||
#include "oemcrypto_types.h"
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
|
||||
@@ -26,14 +26,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "log.h"
|
||||
#include "oec_device_features.h"
|
||||
#include "oec_test_data.h"
|
||||
#include "oemcrypto_key_mock.h"
|
||||
#include "oemcrypto_types.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_keybox.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -102,9 +100,9 @@ Session::Session()
|
||||
: open_(false),
|
||||
forced_session_id_(false),
|
||||
session_id_(0),
|
||||
mac_key_server_(wvcdm::MAC_KEY_SIZE),
|
||||
mac_key_client_(wvcdm::MAC_KEY_SIZE),
|
||||
enc_key_(wvcdm::KEY_SIZE),
|
||||
mac_key_server_(MAC_KEY_SIZE),
|
||||
mac_key_client_(MAC_KEY_SIZE),
|
||||
enc_key_(KEY_SIZE),
|
||||
public_rsa_(0),
|
||||
message_size_(sizeof(MessageData)),
|
||||
// Most tests only use 4 keys. Other tests will explicitly call
|
||||
@@ -187,7 +185,7 @@ void Session::DeriveKey(const uint8_t* key, const vector<uint8_t>& context,
|
||||
CMAC_CTX* cmac_ctx = CMAC_CTX_new();
|
||||
ASSERT_NE(static_cast<void*>(NULL), cmac_ctx);
|
||||
|
||||
ASSERT_EQ(1, CMAC_Init(cmac_ctx, key, wvcdm::KEY_SIZE, cipher, 0));
|
||||
ASSERT_EQ(1, CMAC_Init(cmac_ctx, key, KEY_SIZE, cipher, 0));
|
||||
|
||||
std::vector<uint8_t> message;
|
||||
message.push_back(counter);
|
||||
@@ -223,7 +221,7 @@ void Session::DeriveKeys(const uint8_t* master_key,
|
||||
}
|
||||
|
||||
void Session::GenerateDerivedKeysFromKeybox(
|
||||
const wvoec_mock::WidevineKeybox& keybox) {
|
||||
const wvoec::WidevineKeybox& keybox) {
|
||||
GenerateNonce();
|
||||
vector<uint8_t> mac_context;
|
||||
vector<uint8_t> enc_context;
|
||||
@@ -269,9 +267,9 @@ void Session::LoadTestKeys(const std::string& pst, bool new_mac_keys) {
|
||||
key_array_, pst_ptr, pst.length(), NULL,
|
||||
OEMCrypto_ContentLicense));
|
||||
// Update new generated keys.
|
||||
memcpy(&mac_key_server_[0], license_.mac_keys, wvcdm::MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_client_[0], license_.mac_keys + wvcdm::MAC_KEY_SIZE,
|
||||
wvcdm::MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_server_[0], license_.mac_keys, MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_client_[0], license_.mac_keys + MAC_KEY_SIZE,
|
||||
MAC_KEY_SIZE);
|
||||
} else {
|
||||
ASSERT_EQ(
|
||||
OEMCrypto_SUCCESS,
|
||||
@@ -299,9 +297,9 @@ void Session::LoadEnitlementTestKeys(const std::string& pst,
|
||||
key_array_, pst_ptr, pst.length(), NULL,
|
||||
OEMCrypto_EntitlementLicense));
|
||||
// Update new generated keys.
|
||||
memcpy(&mac_key_server_[0], license_.mac_keys, wvcdm::MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_client_[0], license_.mac_keys + wvcdm::MAC_KEY_SIZE,
|
||||
wvcdm::MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_server_[0], license_.mac_keys, MAC_KEY_SIZE);
|
||||
memcpy(&mac_key_client_[0], license_.mac_keys + MAC_KEY_SIZE,
|
||||
MAC_KEY_SIZE);
|
||||
} else {
|
||||
ASSERT_EQ(
|
||||
expected_sts,
|
||||
@@ -479,7 +477,7 @@ void Session::FillSimpleMessage(uint32_t duration, uint32_t control,
|
||||
memset(license_.keys[i].key_id, i, license_.keys[i].key_id_length);
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].key_data,
|
||||
sizeof(license_.keys[i].key_data)));
|
||||
license_.keys[i].key_data_length = wvcdm::KEY_SIZE;
|
||||
license_.keys[i].key_data_length = KEY_SIZE;
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].key_iv,
|
||||
sizeof(license_.keys[i].key_iv)));
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].control_iv,
|
||||
@@ -493,14 +491,14 @@ void Session::FillSimpleMessage(uint32_t duration, uint32_t control,
|
||||
} else if (global_features.api_version == 12) {
|
||||
// For version 12, we require OEMCrypto to handle kc12 for all licenses.
|
||||
memcpy(license_.keys[i].control.verification, "kc12", 4);
|
||||
} else if (control & wvoec_mock::kControlSecurityPatchLevelMask) {
|
||||
} else if (control & wvoec::kControlSecurityPatchLevelMask) {
|
||||
// For versions before 12, we require the special key control block only
|
||||
// when there are newer features present.
|
||||
memcpy(license_.keys[i].control.verification, "kc11", 4);
|
||||
} else if (control & wvoec_mock::kControlRequireAntiRollbackHardware) {
|
||||
} else if (control & wvoec::kControlRequireAntiRollbackHardware) {
|
||||
memcpy(license_.keys[i].control.verification, "kc10", 4);
|
||||
} else if (control & (wvoec_mock::kControlHDCPVersionMask |
|
||||
wvoec_mock::kControlReplayMask)) {
|
||||
} else if (control & (wvoec::kControlHDCPVersionMask |
|
||||
wvoec::kControlReplayMask)) {
|
||||
memcpy(license_.keys[i].control.verification, "kc09", 4);
|
||||
} else {
|
||||
memcpy(license_.keys[i].control.verification, "kctl", 4);
|
||||
@@ -526,7 +524,7 @@ void Session::FillSimpleEntitlementMessage(
|
||||
memset(license_.keys[i].key_id, i, license_.keys[i].key_id_length);
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].key_data,
|
||||
sizeof(license_.keys[i].key_data)));
|
||||
license_.keys[i].key_data_length = wvcdm::KEY_SIZE * 2; // AES-256 keys
|
||||
license_.keys[i].key_data_length = KEY_SIZE * 2; // AES-256 keys
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].key_iv,
|
||||
sizeof(license_.keys[i].key_iv)));
|
||||
EXPECT_EQ(1, GetRandBytes(license_.keys[i].control_iv,
|
||||
@@ -540,14 +538,14 @@ void Session::FillSimpleEntitlementMessage(
|
||||
} else if (global_features.api_version == 12) {
|
||||
// For version 12, we require OEMCrypto to handle kc12 for all licenses.
|
||||
memcpy(license_.keys[i].control.verification, "kc12", 4);
|
||||
} else if (control & wvoec_mock::kControlSecurityPatchLevelMask) {
|
||||
} else if (control & wvoec::kControlSecurityPatchLevelMask) {
|
||||
// For versions before 12, we require the special key control block only
|
||||
// when there are newer features present.
|
||||
memcpy(license_.keys[i].control.verification, "kc11", 4);
|
||||
} else if (control & wvoec_mock::kControlRequireAntiRollbackHardware) {
|
||||
} else if (control & wvoec::kControlRequireAntiRollbackHardware) {
|
||||
memcpy(license_.keys[i].control.verification, "kc10", 4);
|
||||
} else if (control & (wvoec_mock::kControlHDCPVersionMask |
|
||||
wvoec_mock::kControlReplayMask)) {
|
||||
} else if (control & (wvoec::kControlHDCPVersionMask |
|
||||
wvoec::kControlReplayMask)) {
|
||||
memcpy(license_.keys[i].control.verification, "kc09", 4);
|
||||
} else {
|
||||
memcpy(license_.keys[i].control.verification, "kctl", 4);
|
||||
@@ -591,21 +589,21 @@ void Session::EncryptAndSign() {
|
||||
encrypted_license() = license_;
|
||||
|
||||
uint8_t iv_buffer[16];
|
||||
memcpy(iv_buffer, &license_.mac_key_iv[0], wvcdm::KEY_IV_SIZE);
|
||||
memcpy(iv_buffer, &license_.mac_key_iv[0], KEY_IV_SIZE);
|
||||
AES_KEY aes_key;
|
||||
AES_set_encrypt_key(&enc_key_[0], 128, &aes_key);
|
||||
AES_cbc_encrypt(&license_.mac_keys[0], &encrypted_license().mac_keys[0],
|
||||
2 * wvcdm::MAC_KEY_SIZE, &aes_key, iv_buffer, AES_ENCRYPT);
|
||||
2 * MAC_KEY_SIZE, &aes_key, iv_buffer, AES_ENCRYPT);
|
||||
|
||||
for (unsigned int i = 0; i < num_keys_; i++) {
|
||||
memcpy(iv_buffer, &license_.keys[i].control_iv[0], wvcdm::KEY_IV_SIZE);
|
||||
memcpy(iv_buffer, &license_.keys[i].control_iv[0], KEY_IV_SIZE);
|
||||
AES_set_encrypt_key(&license_.keys[i].key_data[0], 128, &aes_key);
|
||||
AES_cbc_encrypt(
|
||||
reinterpret_cast<const uint8_t*>(&license_.keys[i].control),
|
||||
reinterpret_cast<uint8_t*>(&encrypted_license().keys[i].control),
|
||||
wvcdm::KEY_SIZE, &aes_key, iv_buffer, AES_ENCRYPT);
|
||||
KEY_SIZE, &aes_key, iv_buffer, AES_ENCRYPT);
|
||||
|
||||
memcpy(iv_buffer, &license_.keys[i].key_iv[0], wvcdm::KEY_IV_SIZE);
|
||||
memcpy(iv_buffer, &license_.keys[i].key_iv[0], KEY_IV_SIZE);
|
||||
AES_set_encrypt_key(&enc_key_[0], 128, &aes_key);
|
||||
AES_cbc_encrypt(
|
||||
&license_.keys[i].key_data[0], &encrypted_license().keys[i].key_data[0],
|
||||
@@ -620,14 +618,14 @@ void Session::EncryptAndSign() {
|
||||
void Session::EncryptProvisioningMessage(
|
||||
RSAPrivateKeyMessage* data, RSAPrivateKeyMessage* encrypted,
|
||||
const vector<uint8_t>& encryption_key) {
|
||||
ASSERT_EQ(encryption_key.size(), wvcdm::KEY_SIZE);
|
||||
ASSERT_EQ(encryption_key.size(), KEY_SIZE);
|
||||
*encrypted = *data;
|
||||
size_t padding = wvcdm::KEY_SIZE - (data->rsa_key_length % wvcdm::KEY_SIZE);
|
||||
size_t padding = KEY_SIZE - (data->rsa_key_length % KEY_SIZE);
|
||||
memset(data->rsa_key + data->rsa_key_length, static_cast<uint8_t>(padding),
|
||||
padding);
|
||||
encrypted->rsa_key_length = data->rsa_key_length + padding;
|
||||
uint8_t iv_buffer[16];
|
||||
memcpy(iv_buffer, &data->rsa_key_iv[0], wvcdm::KEY_IV_SIZE);
|
||||
memcpy(iv_buffer, &data->rsa_key_iv[0], KEY_IV_SIZE);
|
||||
AES_KEY aes_key;
|
||||
AES_set_encrypt_key(&encryption_key[0], 128, &aes_key);
|
||||
AES_cbc_encrypt(&data->rsa_key[0], &encrypted->rsa_key[0],
|
||||
@@ -740,8 +738,8 @@ void Session::TestDecryptCTR(bool select_key_first,
|
||||
for (size_t i = 0; i < unencryptedData.size(); i++)
|
||||
unencryptedData[i] = i % 256;
|
||||
EXPECT_EQ(1, GetRandBytes(&unencryptedData[0], unencryptedData.size()));
|
||||
vector<uint8_t> encryptionIv(wvcdm::KEY_IV_SIZE);
|
||||
EXPECT_EQ(1, GetRandBytes(&encryptionIv[0], wvcdm::KEY_IV_SIZE));
|
||||
vector<uint8_t> encryptionIv(KEY_IV_SIZE);
|
||||
EXPECT_EQ(1, GetRandBytes(&encryptionIv[0], KEY_IV_SIZE));
|
||||
vector<uint8_t> encryptedData(unencryptedData.size());
|
||||
EncryptCTR(unencryptedData, license_.keys[key_index].key_data,
|
||||
&encryptionIv[0], &encryptedData);
|
||||
@@ -893,7 +891,7 @@ void Session::MakeRSACertificate(struct RSAPrivateKeyMessage* encrypted,
|
||||
memcpy(message.rsa_key, rsa_key.data(), rsa_key.size());
|
||||
message.rsa_key_length = rsa_key.size();
|
||||
}
|
||||
EXPECT_EQ(1, GetRandBytes(message.rsa_key_iv, wvcdm::KEY_IV_SIZE));
|
||||
EXPECT_EQ(1, GetRandBytes(message.rsa_key_iv, KEY_IV_SIZE));
|
||||
message.nonce = nonce_;
|
||||
|
||||
EncryptProvisioningMessage(&message, encrypted, *encryption_key);
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "oec_device_features.h"
|
||||
#include "oemcrypto_types.h"
|
||||
#include "pst_report.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -66,10 +66,10 @@ const size_t kMaxDecryptSize = 100 * 1024; // In specification.
|
||||
typedef struct {
|
||||
uint8_t key_id[kTestKeyIdMaxLength];
|
||||
size_t key_id_length;
|
||||
uint8_t key_data[wvcdm::MAC_KEY_SIZE];
|
||||
uint8_t key_data[MAC_KEY_SIZE];
|
||||
size_t key_data_length;
|
||||
uint8_t key_iv[wvcdm::KEY_IV_SIZE];
|
||||
uint8_t control_iv[wvcdm::KEY_IV_SIZE];
|
||||
uint8_t key_iv[KEY_IV_SIZE];
|
||||
uint8_t control_iv[KEY_IV_SIZE];
|
||||
KeyControlBlock control;
|
||||
// Note: cipher_mode may not be part of a real signed message. For these
|
||||
// tests, it is convenient to keep it in this structure anyway.
|
||||
@@ -79,8 +79,8 @@ typedef struct {
|
||||
// This structure will be signed to simulate a message from the server.
|
||||
struct MessageData {
|
||||
MessageKeyData keys[kMaxNumKeys];
|
||||
uint8_t mac_key_iv[wvcdm::KEY_IV_SIZE];
|
||||
uint8_t mac_keys[2 * wvcdm::MAC_KEY_SIZE];
|
||||
uint8_t mac_key_iv[KEY_IV_SIZE];
|
||||
uint8_t mac_keys[2 * MAC_KEY_SIZE];
|
||||
uint8_t pst[kMaxPSTLength];
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ struct MessageData {
|
||||
// server.
|
||||
struct RSAPrivateKeyMessage {
|
||||
uint8_t rsa_key[kMaxTestRSAKeyLength];
|
||||
uint8_t rsa_key_iv[wvcdm::KEY_IV_SIZE];
|
||||
uint8_t rsa_key_iv[KEY_IV_SIZE];
|
||||
size_t rsa_key_length;
|
||||
uint32_t nonce;
|
||||
};
|
||||
@@ -107,10 +107,10 @@ struct Test_PST_Report {
|
||||
};
|
||||
|
||||
struct EntitledContentKeyData {
|
||||
uint8_t entitlement_key_id[wvcdm::KEY_SIZE];
|
||||
uint8_t content_key_id[wvcdm::KEY_SIZE];
|
||||
uint8_t content_key_data_iv[wvcdm::KEY_SIZE];
|
||||
uint8_t content_key_data[wvcdm::KEY_SIZE];
|
||||
uint8_t entitlement_key_id[KEY_SIZE];
|
||||
uint8_t content_key_id[KEY_SIZE];
|
||||
uint8_t content_key_data_iv[KEY_SIZE];
|
||||
uint8_t content_key_data[KEY_SIZE];
|
||||
};
|
||||
|
||||
// Increment counter for AES-CTR. The CENC spec specifies we increment only
|
||||
@@ -152,7 +152,7 @@ class Session {
|
||||
vector<uint8_t>* enc_context);
|
||||
// Generate known mac and enc keys using OEMCrypto_GenerateDerivedKeys and
|
||||
// also fill out enc_key_, mac_key_server_, and mac_key_client_.
|
||||
void GenerateDerivedKeysFromKeybox(const wvoec_mock::WidevineKeybox& keybox);
|
||||
void GenerateDerivedKeysFromKeybox(const wvoec::WidevineKeybox& keybox);
|
||||
// Generate known mac and enc keys using OEMCrypto_DeriveKeysFromSessionKey
|
||||
// and also fill out enc_key_, mac_key_server_, and mac_key_client_.
|
||||
void GenerateDerivedKeysFromSessionKey();
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <string>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "wv_keybox.h"
|
||||
#include "oemcrypto_types.h"
|
||||
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace wvoec {
|
||||
// The first keybox, kTestKeybox, with deviceID "TestKey01" is used for most of
|
||||
// the tests. It should be loaded by OEMCrypto when OEMCrypto_LoadTestKeybox
|
||||
// is called.
|
||||
static const wvoec_mock::WidevineKeybox kTestKeybox = {
|
||||
static const wvoec::WidevineKeybox kTestKeybox = {
|
||||
// Sample keybox used for test vectors
|
||||
{
|
||||
// deviceID = WidevineTestOnlyKeybox000
|
||||
@@ -55,7 +56,7 @@ static const wvoec_mock::WidevineKeybox kTestKeybox = {
|
||||
// These are old test keyboxes. The first keybox can be used to update an
|
||||
// older OEMCrypto because it is the same keybox that was previously used in
|
||||
// unit tests.
|
||||
static const wvoec_mock::WidevineKeybox kValidKeybox01 = {
|
||||
static const wvoec::WidevineKeybox kValidKeybox01 = {
|
||||
// Sample keybox used for test vectors
|
||||
{
|
||||
// deviceID
|
||||
@@ -87,7 +88,7 @@ static const wvoec_mock::WidevineKeybox kValidKeybox01 = {
|
||||
}
|
||||
};
|
||||
|
||||
static const wvoec_mock::WidevineKeybox kValidKeybox02 = {
|
||||
static const wvoec::WidevineKeybox kValidKeybox02 = {
|
||||
// Sample keybox used for test vectors
|
||||
{
|
||||
// deviceID
|
||||
@@ -119,7 +120,7 @@ static const wvoec_mock::WidevineKeybox kValidKeybox02 = {
|
||||
}
|
||||
};
|
||||
|
||||
static const wvoec_mock::WidevineKeybox kValidKeybox03 = {
|
||||
static const wvoec::WidevineKeybox kValidKeybox03 = {
|
||||
// Sample keybox used for test vectors
|
||||
{
|
||||
// deviceID
|
||||
|
||||
@@ -82,10 +82,10 @@ void SessionUtil::CreateWrappedRSAKey(uint32_t allowed_schemes,
|
||||
}
|
||||
}
|
||||
|
||||
void SessionUtil::InstallKeybox(const wvoec_mock::WidevineKeybox& keybox,
|
||||
void SessionUtil::InstallKeybox(const wvoec::WidevineKeybox& keybox,
|
||||
bool good) {
|
||||
uint8_t wrapped[sizeof(wvoec_mock::WidevineKeybox)];
|
||||
size_t length = sizeof(wvoec_mock::WidevineKeybox);
|
||||
uint8_t wrapped[sizeof(wvoec::WidevineKeybox)];
|
||||
size_t length = sizeof(wvoec::WidevineKeybox);
|
||||
keybox_ = keybox;
|
||||
ASSERT_EQ(
|
||||
OEMCrypto_SUCCESS,
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
// If force is true, we assert that the key loads successfully.
|
||||
void CreateWrappedRSAKey(uint32_t allowed_schemes, bool force);
|
||||
|
||||
void InstallKeybox(const wvoec_mock::WidevineKeybox& keybox, bool good);
|
||||
void InstallKeybox(const wvoec::WidevineKeybox& keybox, bool good);
|
||||
|
||||
void EnsureTestKeys();
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
std::vector<uint8_t> encoded_rsa_key_;
|
||||
std::vector<uint8_t> wrapped_rsa_key_;
|
||||
wvoec_mock::WidevineKeybox keybox_;
|
||||
wvoec::WidevineKeybox keybox_;
|
||||
};
|
||||
|
||||
} // namespace wvoec
|
||||
|
||||
@@ -34,11 +34,12 @@
|
||||
#include "oec_session_util.h"
|
||||
#include "oec_test_data.h"
|
||||
#include "oemcrypto_session_tests_helper.h"
|
||||
#include "oemcrypto_key_mock.h"
|
||||
#include "properties.h"
|
||||
#include "oemcrypto_types.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_keybox.h"
|
||||
|
||||
#ifdef CDM_TESTS
|
||||
#include "properties.h"
|
||||
#endif
|
||||
|
||||
using ::testing::Bool;
|
||||
using ::testing::Combine;
|
||||
@@ -64,11 +65,7 @@ void PrintTo(const tuple<OEMCrypto_CENCEncryptPatternDesc, OEMCryptoCipherMode,
|
||||
namespace {
|
||||
int GetRandBytes(unsigned char* buf, int num) {
|
||||
// returns 1 on success, -1 if not supported, or 0 if other failure.
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
return RAND_pseudo_bytes(buf, num);
|
||||
#else
|
||||
return RAND_bytes(buf, num);
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -80,7 +77,9 @@ class OEMCryptoClientTest : public ::testing::Test, public SessionUtil {
|
||||
|
||||
virtual void SetUp() {
|
||||
::testing::Test::SetUp();
|
||||
#ifdef CDM_TESTS
|
||||
wvcdm::Properties::Init();
|
||||
#endif
|
||||
wvcdm::g_cutoff = wvcdm::LOG_INFO;
|
||||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
@@ -682,7 +681,7 @@ TEST_F(OEMCryptoSessionTestKeyboxTest, GoodForceKeybox) {
|
||||
ASSERT_EQ(DeviceFeatures::FORCE_TEST_KEYBOX,
|
||||
global_features.derive_key_method)
|
||||
<< "ForceKeybox tests will modify the installed keybox.";
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
wvoec::WidevineKeybox keybox = kValidKeybox02;
|
||||
OEMCryptoResult sts;
|
||||
InstallKeybox(keybox, true);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
@@ -698,7 +697,7 @@ TEST_F(OEMCryptoSessionTestKeyboxTest, BadCRCForceKeybox) {
|
||||
ASSERT_EQ(DeviceFeatures::FORCE_TEST_KEYBOX,
|
||||
global_features.derive_key_method)
|
||||
<< "ForceKeybox tests will modify the installed keybox.";
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
wvoec::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.crc_[1] ^= 42;
|
||||
OEMCryptoResult sts;
|
||||
InstallKeybox(keybox, false);
|
||||
@@ -710,7 +709,7 @@ TEST_F(OEMCryptoSessionTestKeyboxTest, BadMagicForceKeybox) {
|
||||
ASSERT_EQ(DeviceFeatures::FORCE_TEST_KEYBOX,
|
||||
global_features.derive_key_method)
|
||||
<< "ForceKeybox tests will modify the installed keybox.";
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
wvoec::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.magic_[1] ^= 42;
|
||||
OEMCryptoResult sts;
|
||||
InstallKeybox(keybox, false);
|
||||
@@ -722,7 +721,7 @@ TEST_F(OEMCryptoSessionTestKeyboxTest, BadDataForceKeybox) {
|
||||
ASSERT_EQ(DeviceFeatures::FORCE_TEST_KEYBOX,
|
||||
global_features.derive_key_method)
|
||||
<< "ForceKeybox tests will modify the installed keybox.";
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
wvoec::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.data_[1] ^= 42;
|
||||
OEMCryptoResult sts;
|
||||
InstallKeybox(keybox, false);
|
||||
@@ -775,7 +774,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
}
|
||||
@@ -792,7 +791,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeySeveralNonce) {
|
||||
s.GenerateNonce(); // three.
|
||||
s.GenerateNonce(); // four.
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceEnabled, first_nonce));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, first_nonce));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
}
|
||||
@@ -965,7 +964,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithBadRange4) {
|
||||
|
||||
vector<uint8_t> bad_buffer(
|
||||
s.encrypted_license().keys[1].key_data,
|
||||
s.encrypted_license().keys[1].key_data + wvcdm::KEY_SIZE);
|
||||
s.encrypted_license().keys[1].key_data + wvoec::KEY_SIZE);
|
||||
s.key_array()[1].key_data = &bad_buffer[0];
|
||||
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -1039,7 +1038,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithBadNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
wvoec::kControlNonceEnabled,
|
||||
42)); // bad nonce.
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -1057,7 +1056,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithRepeatNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
uint32_t nonce = s.get_nonce();
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceEnabled, nonce));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, nonce));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(s.close());
|
||||
@@ -1065,7 +1064,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithRepeatNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
wvoec::kControlNonceEnabled,
|
||||
nonce)); // same old nonce.
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -1091,8 +1090,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNonceReopenSession) {
|
||||
// and might not clear out the nonce table correctly.
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0, wvoec::kControlNonceEnabled,
|
||||
nonce)); // same old nonce
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -1117,8 +1115,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNonceWrongSession) {
|
||||
Session s2;
|
||||
ASSERT_NO_FATAL_FAILURE(s2.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s2));
|
||||
ASSERT_NO_FATAL_FAILURE(s2.FillSimpleMessage(0,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
ASSERT_NO_FATAL_FAILURE(s2.FillSimpleMessage(0, wvoec::kControlNonceEnabled,
|
||||
nonce)); // nonce from session s1
|
||||
ASSERT_NO_FATAL_FAILURE(s2.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -1245,7 +1242,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNoKeyWithNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
int kNoKeys = 0;
|
||||
ASSERT_NE(
|
||||
@@ -1261,7 +1258,7 @@ TEST_F(OEMCryptoSessionTests, QueryKeyControl) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
// Note: successful cases are tested in VerifyTestKeys.
|
||||
@@ -1288,7 +1285,7 @@ TEST_F(OEMCryptoSessionTests, AntiRollbackHardwareRequired) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlRequireAntiRollbackHardware, 0));
|
||||
0, wvoec::kControlRequireAntiRollbackHardware, 0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
s.session_id(), s.message_ptr(), s.message_size(), &s.signature()[0],
|
||||
@@ -1310,7 +1307,7 @@ TEST_F(OEMCryptoSessionTests, CheckMinimumPatchLevel) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, patch_level << wvoec_mock::kControlSecurityPatchLevelShift, 0));
|
||||
0, patch_level << wvoec::kControlSecurityPatchLevelShift, 0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_EQ(
|
||||
OEMCrypto_SUCCESS,
|
||||
@@ -1326,7 +1323,7 @@ TEST_F(OEMCryptoSessionTests, CheckMinimumPatchLevel) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, (patch_level + 1) << wvoec_mock::kControlSecurityPatchLevelShift,
|
||||
0, (patch_level + 1) << wvoec::kControlSecurityPatchLevelShift,
|
||||
0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_EQ(
|
||||
@@ -1343,7 +1340,7 @@ TEST_F(OEMCryptoSessionTests, CheckMinimumPatchLevel) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, (patch_level - 1) << wvoec_mock::kControlSecurityPatchLevelShift,
|
||||
0, (patch_level - 1) << wvoec::kControlSecurityPatchLevelShift,
|
||||
0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_EQ(
|
||||
@@ -1385,8 +1382,8 @@ class SessionTestDecryptWithHDCP : public OEMCryptoSessionTests,
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0,
|
||||
(version << wvoec_mock::kControlHDCPVersionShift) |
|
||||
wvoec_mock::kControlObserveHDCP | wvoec_mock::kControlHDCPRequired,
|
||||
(version << wvoec::kControlHDCPVersionShift) |
|
||||
wvoec::kControlObserveHDCP | wvoec::kControlHDCPRequired,
|
||||
0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
@@ -1430,14 +1427,14 @@ TEST_P(SessionTestRefreshKeyTest, RefreshWithNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
kDuration, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", new_mac_keys_));
|
||||
s.GenerateNonce();
|
||||
// License renewal message is signed by client and verified by the server.
|
||||
ASSERT_NO_FATAL_FAILURE(s.VerifyClientSignature());
|
||||
ASSERT_NO_FATAL_FAILURE(s.RefreshTestKeys(num_keys_,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
wvoec::kControlNonceEnabled,
|
||||
s.get_nonce(), OEMCrypto_SUCCESS));
|
||||
}
|
||||
|
||||
@@ -1460,14 +1457,14 @@ TEST_P(SessionTestRefreshKeyTest, RefreshOldNonceAPI11) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
uint32_t nonce = s.get_nonce();
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(kDuration, wvoec_mock::kControlNonceEnabled, nonce));
|
||||
s.FillSimpleMessage(kDuration, wvoec::kControlNonceEnabled, nonce));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", new_mac_keys_));
|
||||
// License renewal message is signed by client and verified by the server.
|
||||
ASSERT_NO_FATAL_FAILURE(s.VerifyClientSignature());
|
||||
// Tryinng to reuse the same nonce.
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
s.RefreshTestKeys(num_keys_, wvoec::kControlNonceEnabled, nonce,
|
||||
OEMCrypto_ERROR_INVALID_NONCE));
|
||||
}
|
||||
|
||||
@@ -1476,7 +1473,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshBadNonceAPI11) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
kDuration, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", new_mac_keys_));
|
||||
s.GenerateNonce();
|
||||
@@ -1484,7 +1481,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshBadNonceAPI11) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.VerifyClientSignature());
|
||||
uint32_t nonce = s.get_nonce() ^ 42;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
s.RefreshTestKeys(num_keys_, wvoec::kControlNonceEnabled, nonce,
|
||||
OEMCrypto_ERROR_INVALID_NONCE));
|
||||
}
|
||||
|
||||
@@ -1494,7 +1491,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshLargeBuffer) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
kDuration, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", new_mac_keys_));
|
||||
s.GenerateNonce();
|
||||
@@ -1502,7 +1499,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshLargeBuffer) {
|
||||
// This uses a large buffer for the renewal message.
|
||||
ASSERT_NO_FATAL_FAILURE(s.VerifyClientSignature(kMaxMessageSize));
|
||||
ASSERT_NO_FATAL_FAILURE(s.RefreshTestKeys(num_keys_,
|
||||
wvoec_mock::kControlNonceEnabled,
|
||||
wvoec::kControlNonceEnabled,
|
||||
s.get_nonce(), OEMCrypto_SUCCESS));
|
||||
}
|
||||
|
||||
@@ -1514,7 +1511,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshWithNoSelectKey) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
kDuration, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", new_mac_keys_));
|
||||
// Call select key before the refresh. No calls below to TestDecryptCTR with
|
||||
@@ -1528,7 +1525,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshWithNoSelectKey) {
|
||||
// message is not actually encrypted. It is, however, signed.
|
||||
// FillRefreshMessage fills the message with a duration of kLongDuration.
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillRefreshMessage(
|
||||
num_keys_, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
num_keys_, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
s.ServerSignBuffer(reinterpret_cast<const uint8_t*>(&s.encrypted_license()),
|
||||
s.message_size(), &s.signature());
|
||||
OEMCrypto_KeyRefreshObject key_array[num_keys_];
|
||||
@@ -2136,7 +2133,7 @@ TEST_F(OEMCryptoSessionTests, DecryptSecureToClear) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration,
|
||||
wvoec_mock::kControlObserveDataPath | wvoec_mock::kControlDataPathSecure,
|
||||
wvoec::kControlObserveDataPath | wvoec::kControlDataPathSecure,
|
||||
0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
@@ -2149,7 +2146,7 @@ TEST_F(OEMCryptoSessionTests, DecryptNoAnalogToClearAPI13) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlDisableAnalogOutput, 0));
|
||||
kDuration, wvoec::kControlDisableAnalogOutput, 0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
@@ -2161,7 +2158,7 @@ TEST_F(OEMCryptoSessionTests, KeyDuration) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce()));
|
||||
kDuration, wvoec::kControlNonceEnabled, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR(true, OEMCrypto_SUCCESS));
|
||||
@@ -3823,22 +3820,22 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
session_.FillSimpleMessage(duration, control, nonce, pst));
|
||||
session_.license().keys[0].control.control_bits |=
|
||||
htonl(wvoec_mock::kControlAllowEncrypt);
|
||||
htonl(wvoec::kControlAllowEncrypt);
|
||||
session_.license().keys[1].control.control_bits |=
|
||||
htonl(wvoec_mock::kControlAllowDecrypt);
|
||||
htonl(wvoec::kControlAllowDecrypt);
|
||||
session_.license().keys[2].control.control_bits |=
|
||||
htonl(wvoec_mock::kControlAllowSign);
|
||||
htonl(wvoec::kControlAllowSign);
|
||||
session_.license().keys[3].control.control_bits |=
|
||||
htonl(wvoec_mock::kControlAllowVerify);
|
||||
htonl(wvoec::kControlAllowVerify);
|
||||
|
||||
session_.license().keys[2].key_data_length = wvcdm::MAC_KEY_SIZE;
|
||||
session_.license().keys[3].key_data_length = wvcdm::MAC_KEY_SIZE;
|
||||
session_.license().keys[2].key_data_length = wvoec::MAC_KEY_SIZE;
|
||||
session_.license().keys[3].key_data_length = wvoec::MAC_KEY_SIZE;
|
||||
|
||||
clear_buffer_.assign(buffer_size_, 0);
|
||||
for (size_t i = 0; i < clear_buffer_.size(); i++) {
|
||||
clear_buffer_[i] = 1 + i % 250;
|
||||
}
|
||||
for (size_t i = 0; i < wvcdm::KEY_IV_SIZE; i++) {
|
||||
for (size_t i = 0; i < wvoec::KEY_IV_SIZE; i++) {
|
||||
iv_[i] = i;
|
||||
}
|
||||
}
|
||||
@@ -3854,8 +3851,8 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
|
||||
ASSERT_EQ(0,
|
||||
AES_set_encrypt_key(session_.license().keys[key_index].key_data,
|
||||
AES_BLOCK_SIZE * 8, &aes_key));
|
||||
uint8_t iv_buffer[wvcdm::KEY_IV_SIZE];
|
||||
memcpy(iv_buffer, iv_, wvcdm::KEY_IV_SIZE);
|
||||
uint8_t iv_buffer[wvoec::KEY_IV_SIZE];
|
||||
memcpy(iv_buffer, iv_, wvoec::KEY_IV_SIZE);
|
||||
out_buffer->resize(in_buffer.size());
|
||||
ASSERT_GT(in_buffer.size(), 0u);
|
||||
ASSERT_EQ(0u, in_buffer.size() % AES_BLOCK_SIZE);
|
||||
@@ -3869,7 +3866,7 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
|
||||
unsigned int md_len = SHA256_DIGEST_LENGTH;
|
||||
signature->resize(SHA256_DIGEST_LENGTH);
|
||||
HMAC(EVP_sha256(), session_.license().keys[key_index].key_data,
|
||||
wvcdm::MAC_KEY_SIZE, &in_buffer[0], in_buffer.size(),
|
||||
wvoec::MAC_KEY_SIZE, &in_buffer[0], in_buffer.size(),
|
||||
signature->data(), &md_len);
|
||||
}
|
||||
|
||||
@@ -3953,7 +3950,7 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
|
||||
size_t buffer_size_;
|
||||
vector<uint8_t> clear_buffer_;
|
||||
vector<uint8_t> encrypted_buffer_;
|
||||
uint8_t iv_[wvcdm::KEY_IV_SIZE];
|
||||
uint8_t iv_[wvoec::KEY_IV_SIZE];
|
||||
Session session_;
|
||||
};
|
||||
|
||||
@@ -4048,7 +4045,7 @@ TEST_F(GenericCryptoTest, GenericKeyDecryptSameBufferAPI12) {
|
||||
|
||||
TEST_F(GenericCryptoTest, GenericSecureToClear) {
|
||||
session_.license().keys[1].control.control_bits |= htonl(
|
||||
wvoec_mock::kControlObserveDataPath | wvoec_mock::kControlDataPathSecure);
|
||||
wvoec::kControlObserveDataPath | wvoec::kControlDataPathSecure);
|
||||
EncryptAndLoadKeys();
|
||||
unsigned int key_index = 1;
|
||||
vector<uint8_t> encrypted;
|
||||
@@ -4370,7 +4367,7 @@ class GenericCryptoKeyIdLengthTest : public GenericCryptoTest {
|
||||
const uint32_t kNoNonce = 0;
|
||||
session_.set_num_keys(5);
|
||||
ASSERT_NO_FATAL_FAILURE(session_.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlAllowDecrypt, kNoNonce));
|
||||
kDuration, wvoec::kControlAllowDecrypt, kNoNonce));
|
||||
SetUniformKeyIdLength(16); // Start with all key ids being 16 bytes.
|
||||
// But, we are testing that the key ids do not have to have the same length.
|
||||
session_.SetKeyId(0, "123456789012"); // 12 bytes (common key id length).
|
||||
@@ -4461,7 +4458,7 @@ class UsageTableTest : public GenericCryptoTest {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys(pst, new_mac_keys_));
|
||||
@@ -4508,7 +4505,7 @@ TEST_P(UsageTableTestWithMAC, OnlineLicense) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4538,7 +4535,7 @@ TEST_P(UsageTableTestWithMAC, OnlineLicenseUnused) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4562,7 +4559,7 @@ TEST_P(UsageTableTestWithMAC, ForbidReportWithNoUpdate) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4592,7 +4589,7 @@ TEST_P(UsageTableTestWithMAC, OnlineLicenseWithRefresh) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4605,7 +4602,7 @@ TEST_P(UsageTableTestWithMAC, OnlineLicenseWithRefresh) {
|
||||
size_t kAllKeys = 1;
|
||||
ASSERT_NO_FATAL_FAILURE(s.RefreshTestKeys(
|
||||
kAllKeys,
|
||||
wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), OEMCrypto_SUCCESS));
|
||||
ASSERT_NO_FATAL_FAILURE(s.UpdateUsageEntry(&encrypted_usage_header_));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
@@ -4621,7 +4618,7 @@ TEST_F(UsageTableTest, RepeatOnlineLicense) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4652,7 +4649,7 @@ TEST_F(UsageTableTest, OnlineEmptyPST) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4672,7 +4669,7 @@ TEST_F(UsageTableTest, OnlineMissingEntry) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
// ENTRY NOT CREATED: ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -4689,7 +4686,7 @@ TEST_P(UsageTableTestWithMAC, GenericCryptoEncrypt) {
|
||||
std::string pst = "A PST";
|
||||
uint32_t nonce = session_.get_nonce();
|
||||
MakeFourKeys(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
nonce, pst);
|
||||
ASSERT_NO_FATAL_FAILURE(session_.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(session_.CreateNewUsageEntry());
|
||||
@@ -4726,7 +4723,7 @@ TEST_P(UsageTableTestWithMAC, GenericCryptoDecrypt) {
|
||||
std::string pst = "my_pst";
|
||||
uint32_t nonce = session_.get_nonce();
|
||||
MakeFourKeys(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
nonce, pst);
|
||||
ASSERT_NO_FATAL_FAILURE(session_.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(session_.CreateNewUsageEntry());
|
||||
@@ -4763,7 +4760,7 @@ TEST_P(UsageTableTestWithMAC, GenericCryptoSign) {
|
||||
std::string pst = "my_pst";
|
||||
uint32_t nonce = session_.get_nonce();
|
||||
MakeFourKeys(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
nonce, pst);
|
||||
ASSERT_NO_FATAL_FAILURE(session_.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(session_.CreateNewUsageEntry());
|
||||
@@ -4811,7 +4808,7 @@ TEST_P(UsageTableTestWithMAC, GenericCryptoVerify) {
|
||||
std::string pst = "my_pst";
|
||||
uint32_t nonce = session_.get_nonce();
|
||||
MakeFourKeys(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
nonce, pst);
|
||||
ASSERT_NO_FATAL_FAILURE(session_.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(session_.CreateNewUsageEntry());
|
||||
@@ -4854,7 +4851,7 @@ TEST_P(UsageTableTestWithMAC, OfflineLicenseRefresh) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys(pst, new_mac_keys_));
|
||||
@@ -4865,7 +4862,7 @@ TEST_P(UsageTableTestWithMAC, OfflineLicenseRefresh) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.VerifyClientSignature());
|
||||
size_t kAllKeys = 1;
|
||||
ASSERT_NO_FATAL_FAILURE(s.RefreshTestKeys(
|
||||
kAllKeys, wvoec_mock::kControlNonceOrEntry, 0, OEMCrypto_SUCCESS));
|
||||
kAllKeys, wvoec::kControlNonceOrEntry, 0, OEMCrypto_SUCCESS));
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR());
|
||||
ASSERT_NO_FATAL_FAILURE(s.UpdateUsageEntry(&encrypted_usage_header_));
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
@@ -4918,7 +4915,7 @@ TEST_P(UsageTableTestWithMAC, ReloadOfflineLicenseWithRefresh) {
|
||||
decrypt_time)); // last decrypt
|
||||
size_t kAllKeys = 1;
|
||||
ASSERT_NO_FATAL_FAILURE(s.RefreshTestKeys(
|
||||
kAllKeys, wvoec_mock::kControlNonceOrEntry, 0, OEMCrypto_SUCCESS));
|
||||
kAllKeys, wvoec::kControlNonceOrEntry, 0, OEMCrypto_SUCCESS));
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR());
|
||||
ASSERT_NO_FATAL_FAILURE(s.UpdateUsageEntry(&encrypted_usage_header_));
|
||||
ASSERT_NO_FATAL_FAILURE(s.GenerateVerifyReport(pst, kActive,
|
||||
@@ -4963,7 +4960,7 @@ TEST_P(UsageTableTestWithMAC, BadReloadOfflineLicense) {
|
||||
ASSERT_NO_FATAL_FAILURE(s2.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s2));
|
||||
ASSERT_NO_FATAL_FAILURE(s2.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s2.get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s2.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s2.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s2.LoadUsageEntry(s));
|
||||
uint8_t* pst_ptr = s2.encrypted_license().pst;
|
||||
@@ -4997,7 +4994,7 @@ TEST_P(UsageTableTestWithMAC, OfflineBadNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceOrEntry, 42, pst));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceOrEntry, 42, pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
uint8_t* pst_ptr = s.encrypted_license().pst;
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
@@ -5016,7 +5013,7 @@ TEST_P(UsageTableTestWithMAC, OfflineEmptyPST) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.FillSimpleMessage(0, wvoec_mock::kControlNonceOrEntry, s.get_nonce()));
|
||||
s.FillSimpleMessage(0, wvoec::kControlNonceOrEntry, s.get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
s.session_id(), s.message_ptr(), s.message_size(), &s.signature()[0],
|
||||
@@ -5141,7 +5138,7 @@ TEST_P(UsageTableTestWithMAC, BadRange) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(session_.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
uint8_t* pst_ptr = s.license().pst; // Bad: not in encrypted_license.
|
||||
ASSERT_NE(
|
||||
@@ -5160,7 +5157,7 @@ TEST_F(UsageTableTest, UpdateFailsWithNullPtr) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -5190,7 +5187,7 @@ class UsageTableDefragTest : public UsageTableTest {
|
||||
char c2 = 'A' + (index % 26);
|
||||
pst = pst + c1 + c2;
|
||||
ASSERT_NO_FATAL_FAILURE(s->FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s->get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s->get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s->EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s->CreateNewUsageEntry());
|
||||
ASSERT_EQ(s->usage_entry_number(), index);
|
||||
@@ -5380,7 +5377,7 @@ TEST_F(UsageTableDefragTest, TwoHundredEntries) {
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&sessions[i]));
|
||||
std::string pst = MakePST(i);
|
||||
ASSERT_NO_FATAL_FAILURE(sessions[i].FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, sessions[i].get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, sessions[i].get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(sessions[i].EncryptAndSign());
|
||||
// We attempt to create a new usage table entry for this session.
|
||||
OEMCryptoResult status;
|
||||
@@ -5587,7 +5584,7 @@ TEST_F(UsageTableTest, GenerateReportWrongPST) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
0, wvoec::kControlNonceOrEntry, s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys(pst, new_mac_keys_));
|
||||
@@ -5684,7 +5681,7 @@ TEST_F(UsageTableTest, VerifyUsageTimes) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
0, wvoec_mock::kControlNonceEnabled | wvoec_mock::kControlNonceRequired,
|
||||
0, wvoec::kControlNonceEnabled | wvoec::kControlNonceRequired,
|
||||
s.get_nonce(), pst));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.CreateNewUsageEntry());
|
||||
@@ -5874,7 +5871,7 @@ TEST_F(UsageTableTest, LoadSharedLicense) {
|
||||
s.license().keys[i].key_id_length);
|
||||
s.license().keys[i].control.nonce = 0;
|
||||
s.license().keys[i].control.control_bits =
|
||||
htonl(wvoec_mock::kSharedLicense);
|
||||
htonl(wvoec::kSharedLicense);
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys(pst, false));
|
||||
@@ -5903,7 +5900,7 @@ TEST_F(UsageTableTest, LoadSharedLicenseWithNoMaster) {
|
||||
s.license().keys[i].key_id_length);
|
||||
s.license().keys[i].control.nonce = 0;
|
||||
s.license().keys[i].control.control_bits =
|
||||
htonl(wvoec_mock::kSharedLicense);
|
||||
htonl(wvoec::kSharedLicense);
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
uint8_t* pst_ptr = s.encrypted_license().pst;
|
||||
|
||||
@@ -142,7 +142,6 @@ TEST_F(OEMCryptoAndroidOCTest, MinVersionNumber13) {
|
||||
ASSERT_GE(version, 13u);
|
||||
}
|
||||
|
||||
#if 0 // TODO(b/64001862)
|
||||
// These tests are required for Pi MR1 Android devices.
|
||||
class OEMCryptoAndroidPiMR1Test : public OEMCryptoAndroidOCTest {};
|
||||
|
||||
@@ -150,6 +149,5 @@ TEST_F(OEMCryptoAndroidPiMR1Test, MinVersionNumber14) {
|
||||
uint32_t version = OEMCrypto_APIVersion();
|
||||
ASSERT_GE(version, 14u);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace wvoec
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "log.h"
|
||||
#include "oec_device_features.h"
|
||||
#ifdef CDM_TESTS
|
||||
#include "properties.h"
|
||||
#endif
|
||||
|
||||
static void acknowledge_cast() {
|
||||
std::cout
|
||||
@@ -15,7 +17,9 @@ static void acknowledge_cast() {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
#ifdef CDM_TESTS
|
||||
wvcdm::Properties::Init();
|
||||
#endif
|
||||
wvcdm::g_cutoff = wvcdm::LOG_INFO;
|
||||
bool is_cast_receiver = false;
|
||||
bool force_load_test_keybox = false;
|
||||
|
||||
Reference in New Issue
Block a user