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

@@ -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 \