Add Call to Install Keybox to Widevine CDM

This merges the following changes from the Widevine CDM repository:

1a72a7e  Combine utility code into single library on Android
  Combines several previously-separate files into a static library,
  libcdm_utils, so that it can easily be used by both CDM and
  OEMCrypto.

8c4d04d  Install Keybox
  If the keybox has not been installed, install it from
  /factory/wv.keys.

Bug: 9972451
Change-Id: I8688ecd0adcf321e0c7d0faf55dd10f3910c12ec
This commit is contained in:
John "Juce" Bruce
2013-08-08 14:52:31 -07:00
parent ddf957faa5
commit b0d85ac1af
14 changed files with 68 additions and 28 deletions

View File

@@ -4,18 +4,32 @@
LOCAL_PATH := $(call my-dir)
# -----------------------------------------------------------------------------
# Builds libmodp_b64.a
# Builds libcdm_utils.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := libmodp_b64
LOCAL_MODULE := libcdm_utils
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_C_INCLUDES := \
bionic \
external/stlport/stlport
external/stlport/stlport \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
vendor/widevine/libwvdrmengine/third_party/stringencoders/src
LOCAL_SRC_FILES := third_party/stringencoders/src/modp_b64w.cpp
SRC_DIR := cdm/src
CORE_SRC_DIR := cdm/core/src
LOCAL_SRC_FILES := third_party/stringencoders/src/modp_b64w.cpp \
$(CORE_SRC_DIR)/properties.cpp \
$(CORE_SRC_DIR)/string_conversions.cpp \
$(SRC_DIR)/clock.cpp \
$(SRC_DIR)/file_store.cpp \
$(SRC_DIR)/lock.cpp \
$(SRC_DIR)/log.cpp \
$(SRC_DIR)/properties_android.cpp \
$(SRC_DIR)/timer.cpp \
include $(BUILD_STATIC_LIBRARY)
@@ -77,6 +91,7 @@ LOCAL_C_INCLUDES := \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_utils \
libwvwrapper \
libwvlevel3 \
libprotobuf-cpp-2.3.0-lite \

View File

@@ -31,17 +31,8 @@ LOCAL_SRC_FILES := \
$(CORE_SRC_DIR)/device_files.cpp \
$(CORE_SRC_DIR)/license.cpp \
$(CORE_SRC_DIR)/policy_engine.cpp \
$(CORE_SRC_DIR)/properties.cpp \
$(CORE_SRC_DIR)/string_conversions.cpp \
$(SRC_DIR)/clock.cpp \
$(SRC_DIR)/file_store.cpp \
$(SRC_DIR)/lock.cpp \
$(SRC_DIR)/log.cpp \
$(SRC_DIR)/properties_android.cpp \
$(SRC_DIR)/timer.cpp \
$(SRC_DIR)/wv_content_decryption_module.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := libmodp_b64
LOCAL_MODULE := libcdm
LOCAL_MODULE_TAGS := optional

View File

@@ -47,6 +47,7 @@ class Properties {
static bool GetProductName(std::string* product_name);
static bool GetBuildInfo(std::string* build_info);
static bool GetDeviceFilesBasePath(std::string* base_path);
static bool GetFactoryKeyboxPath(std::string* keybox);
private:
static void set_begin_license_usage_when_received(bool flag) {

View File

@@ -92,4 +92,13 @@ bool Properties::GetDeviceFilesBasePath(std::string* base_path) {
return true;
}
bool Properties::GetFactoryKeyboxPath(std::string* keybox) {
if (!keybox) {
LOGW("Properties::GetFactoryKeyboxPath: Invalid parameter");
return false;
}
*keybox = "/factory/wv.keys";
return true;
}
} // namespace wvcdm

View File

@@ -34,15 +34,15 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(cdm_proto_gen_headers)
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libgmock \
libgtest \
libgtest_main \
libwvwrapper \
libwvlevel3 \
libcdm_utils \
libprotobuf-cpp-2.3.0-lite
LOCAL_WHOLE_STATIC_LIBRARIES := libcdm_protos
LOCAL_SHARED_LIBRARIES := \
libcrypto \
libcutils \

View File

@@ -18,6 +18,8 @@ LOCAL_C_INCLUDES := \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libgmock \
libgmock_main \
libgtest \
@@ -47,8 +49,6 @@ LOCAL_C_INCLUDES += \
LOCAL_ADDITIONAL_DEPENDENCIES += $(proto_generated_headers)
LOCAL_WHOLE_STATIC_LIBRARIES := libcdm_protos
# End protobuf section
LOCAL_MODULE := libwvdrmmediacrypto_test

View File

@@ -18,6 +18,8 @@ LOCAL_C_INCLUDES := \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libgmock \
libgmock_main \
libgtest \
@@ -46,8 +48,6 @@ LOCAL_C_INCLUDES += \
LOCAL_ADDITIONAL_DEPENDENCIES += $(proto_generated_headers)
LOCAL_WHOLE_STATIC_LIBRARIES := libcdm_protos
# End protobuf section
LOCAL_MODULE := libwvdrmdrmplugin_test

View File

@@ -1,5 +1,5 @@
/*********************************************************************
* OEMCryptoCENC.h
* level3.h
*
* (c) Copyright 2013 Google, Inc.
*

View File

@@ -2,18 +2,12 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
CDM_SRC_DIR=../../cdm/src
CORE_SRC_DIR=../../cdm/core/src
LOCAL_SRC_FILES:= \
src/oemcrypto_engine_mock.cpp \
src/oemcrypto_key_mock.cpp \
src/oemcrypto_keybox_mock.cpp \
src/oemcrypto_mock.cpp \
src/wvcrc.cpp \
$(CDM_SRC_DIR)/lock.cpp \
$(CDM_SRC_DIR)/log.cpp \
$(CORE_SRC_DIR)/string_conversions.cpp \
LOCAL_MODULE_TAGS := tests
@@ -37,7 +31,9 @@ LOCAL_SHARED_LIBRARIES := \
libutils \
libz \
LOCAL_WHOLE_STATIC_LIBRARIES := libmodp_b64
LOCAL_STATIC_LIBRARIES := \
libcdm_utils
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
LOCAL_MODULE := liboemcrypto

View File

@@ -16,6 +16,8 @@
#include "level3.h"
#include "log.h"
#include "file_store.h"
#include "properties.h"
using namespace wvoec_level3;
@@ -232,6 +234,32 @@ OEMCryptoResult OEMCrypto_Initialize(void) {
return Level3_Initialize();
}
}
if (OEMCrypto_SUCCESS != OEMCrypto_IsKeyboxValid()) {
wvcdm::File file;
std::string filename;
if (!wvcdm::Properties::GetFactoryKeyboxPath(&filename)) {
LOGW("Bad Level 1 Keybox. Falling Back to L3.");
dlclose(level1.library);
level1.library = NULL;
return Level3_Initialize();
}
ssize_t size = file.FileSize(filename);
if( size <= 0 || !file.Open(filename, file.kBinary | file.kReadOnly) ) {
LOGW("Could not open %s. Falling Back to L3.", filename.c_str());
dlclose(level1.library);
level1.library = NULL;
return Level3_Initialize();
}
uint8_t keybox[size];
ssize_t size_read = file.Read(reinterpret_cast<char *>(keybox), size);
if (level1.OEMCrypto_InstallKeybox(keybox, size) != OEMCrypto_SUCCESS) {
LOGE("Could NOT install keybox in /factory/wv.keys. Falling Back to L3.");
dlclose(level1.library);
level1.library = NULL;
return Level3_Initialize();
}
LOGI("Installed keybox from %s", filename.c_str());
}
LOGD("OEMCrypto_Initialize Level 1 success. I will use level 1.");
return OEMCrypto_SUCCESS;
}

View File

@@ -21,12 +21,12 @@ LOCAL_C_INCLUDES += \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/third_party/stringencoders/src \
# TODO(fredgc): fix order dependencies on libwvlevel3 and libwvwrapper.
LOCAL_STATIC_LIBRARIES := \
libgtest \
libgtest_main \
libwvwrapper \
libwvlevel3 \
libcdm_utils \
LOCAL_SHARED_LIBRARIES := \
libcrypto \