Field provisioning for L3 OEMCrypto
bug: 8621460 Merge of https://widevine-internal-review.googlesource.com/#/c/4955/ from Widevine CDM repository. Change-Id: I30cf4314283db51c8e706c026501784259c87c13
This commit is contained in:
@@ -4,8 +4,8 @@ LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
oemcrypto_test.cpp \
|
||||
oemcrypto_keybox_test.cpp
|
||||
oemcrypto_test.cpp \
|
||||
oemcrypto_keybox_test.cpp
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
@@ -13,26 +13,28 @@ LOCAL_MODULE_TAGS := tests
|
||||
LOCAL_CFLAGS += -DCAN_INSTALL_KEYBOX
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
bionic \
|
||||
external/gtest/include \
|
||||
external/openssl/include \
|
||||
external/stlport/stlport \
|
||||
$(LOCAL_PATH)/../include \
|
||||
$(LOCAL_PATH)/../mock/src \
|
||||
bionic \
|
||||
external/gtest/include \
|
||||
external/openssl/include \
|
||||
external/stlport/stlport \
|
||||
$(LOCAL_PATH)/../include \
|
||||
$(LOCAL_PATH)/../mock/src \
|
||||
|
||||
# TODO(fredgc): fix order dependencies on libwvlevel3 and libwvwrapper.
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libgtest \
|
||||
libgtest_main \
|
||||
libl3crypto \
|
||||
libgtest \
|
||||
libgtest_main \
|
||||
libwvwrapper \
|
||||
libwvlevel3 \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcrypto \
|
||||
libcutils \
|
||||
libdl \
|
||||
liblog \
|
||||
libstlport \
|
||||
libutils \
|
||||
libz \
|
||||
libcrypto \
|
||||
libcutils \
|
||||
libdl \
|
||||
liblog \
|
||||
libstlport \
|
||||
libutils \
|
||||
libz \
|
||||
|
||||
LOCAL_MODULE:=oemcrypto_test
|
||||
|
||||
|
||||
@@ -92,11 +92,11 @@ class OEMCryptoKeyboxTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize())
|
||||
<< "OEMCrypto_Initialize failed.";
|
||||
}
|
||||
|
||||
void install_keybox(wvoec_mock::WidevineKeybox& keybox) {
|
||||
void install_keybox(wvoec_mock::WidevineKeybox& keybox, bool good) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize())
|
||||
<< "OEMCrypto_Initialize failed.";
|
||||
OEMCryptoResult sts;
|
||||
uint8_t wrapped[sizeof(wvoec_mock::WidevineKeybox)];
|
||||
size_t length = sizeof(wvoec_mock::WidevineKeybox);
|
||||
@@ -107,18 +107,23 @@ class OEMCryptoKeyboxTest : public ::testing::Test {
|
||||
NULL, 0);
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
sts = OEMCrypto_InstallKeybox(wrapped, sizeof(keybox));
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
if( good ) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
} else {
|
||||
// Can return error now, or return error on IsKeyboxValid.
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Terminate())
|
||||
<< "OEMCrypto_Terminate failed.";
|
||||
OEMCrypto_Terminate();
|
||||
}
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
TEST_F(OEMCryptoKeyboxTest, DefaultKeybox) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize())
|
||||
<< "OEMCrypto_Initialize failed.";
|
||||
OEMCryptoResult sts;
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
@@ -127,12 +132,12 @@ TEST_F(OEMCryptoKeyboxTest, DefaultKeybox) {
|
||||
TEST_F(OEMCryptoKeyboxTest, GoodKeybox) {
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
OEMCryptoResult sts;
|
||||
install_keybox(keybox);
|
||||
install_keybox(keybox, true);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
|
||||
keybox = kValidKeybox03;
|
||||
install_keybox(keybox);
|
||||
install_keybox(keybox, true);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
@@ -141,7 +146,7 @@ TEST_F(OEMCryptoKeyboxTest, BadCRCKeybox) {
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.crc_[1] = 42;
|
||||
OEMCryptoResult sts;
|
||||
install_keybox(keybox);
|
||||
install_keybox(keybox, false);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_ERROR_BAD_CRC, sts);
|
||||
}
|
||||
@@ -150,7 +155,7 @@ TEST_F(OEMCryptoKeyboxTest, BadMagicKeybox) {
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.magic_[1] = 42;
|
||||
OEMCryptoResult sts;
|
||||
install_keybox(keybox);
|
||||
install_keybox(keybox, false);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_ERROR_BAD_MAGIC, sts);
|
||||
}
|
||||
@@ -160,7 +165,7 @@ TEST_F(OEMCryptoKeyboxTest, BadDataKeybox) {
|
||||
wvoec_mock::WidevineKeybox keybox = kValidKeybox02;
|
||||
keybox.data_[1] = 42;
|
||||
OEMCryptoResult sts;
|
||||
install_keybox(keybox);
|
||||
install_keybox(keybox, false);
|
||||
sts = OEMCrypto_IsKeyboxValid();
|
||||
ASSERT_EQ(OEMCrypto_ERROR_BAD_CRC, sts);
|
||||
}
|
||||
|
||||
@@ -1682,9 +1682,16 @@ TEST_F(OEMCryptoClientTest, GenerateDerivedKeys) {
|
||||
testTearDown();
|
||||
}
|
||||
|
||||
// Define CAN_INSTALL_KEYBOX if you are compiling with the reference
|
||||
// implementation of OEMCrypto, or if your version of OEMCrypto supports
|
||||
// OEMCrypto_InstallKeybox and OEwith a clear keybox.
|
||||
// The Below tests are based on a specific keybox which is installed for testing.
|
||||
#if defined(CAN_INSTALL_KEYBOX)
|
||||
|
||||
TEST_F(OEMCryptoClientTest, GenerateSignature) {
|
||||
Session& s = createSession("ONE");
|
||||
testSetUp();
|
||||
InstallKeybox(kDefaultKeybox);
|
||||
Session& s = createSession("ONE");
|
||||
s.open();
|
||||
|
||||
s.GenerateDerivedKeys();
|
||||
@@ -1715,19 +1722,12 @@ TEST_F(OEMCryptoClientTest, GenerateSignature) {
|
||||
ASSERT_EQ(0, memcmp(&expected_signature[0], signature,
|
||||
expected_signature.size()));
|
||||
|
||||
|
||||
s.close();
|
||||
ASSERT_TRUE(s.successStatus());
|
||||
ASSERT_FALSE(s.isOpen());
|
||||
testTearDown();
|
||||
}
|
||||
|
||||
// Define CAN_INSTALL_KEYBOX if you are compiling with the reference
|
||||
// implementation of OEMCrypto, or if your version of OEMCrypto supports
|
||||
// OEMCrypto_InstallKeybox and OEwith a clear keybox.
|
||||
// The Below tests are based on a specific keybox which is installed for testing.
|
||||
#if defined(CAN_INSTALL_KEYBOX)
|
||||
|
||||
TEST_F(OEMCryptoClientTest, LoadKeyNoNonce) {
|
||||
testSetUp();
|
||||
InstallKeybox(kDefaultKeybox);
|
||||
|
||||
Reference in New Issue
Block a user