Merges to android Pi release (part 12)
These are a set of CLs merged from the wv cdm repo to the android repo. * Correct error logging Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/40000 ] In tests, we set the cipher list to avoid using insecure ciphers when connecting to the provisioning/license service. The result of setting the cipher list was being incorrectly validated. Bug: 64847919 * Move mips cache headers to clear_cache_function.h Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39700 ] Since the clear_cache function has been moved away from the dynamic adapter, we need these conditional includes to be migrated as well for MIPS. * Comment out Level 3 debug call until merge Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39761 ] This call was introduced in go/wvgerrit/34260/. Since the haystack tool in google3 still needs this merge, this should be commented out so the tool can still build until the merge has finished. * Add logging for MAC keys to mock Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39740 ] Bug: 70637842 * Move external interfaces into level3.h + refactor Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39673 ] As part of b/70523618, this CL moves interfaces that partners are responsible for in Level 3 to level3.h so they can be visible as part of the CDM release process. It also cleans up some of the names of the files and adds documentation. * Corrected close session logging level Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/39676 ] Bug: 69460963 * Remove Security Level Path Backward Compatibility Support Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/39505 ] From the android K release onwards certificates were stored in security level specific directories. If upgrading from previous releases persistent information needed to be moved to those directories. Since no device is likely to upgrade from J to Pi, comptibility support can be removed. Bug: 70160032 * Rename privacy_crypto_openssl To privacy_crypto_boringssl Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/37122 ] Now that we no longer support OpenSSL in the Shared Source CDM, the name of this file can be updated. Bug: 67907873 Test: build.py x86-64 Test: wv_ce_cdm_unittest Test: jenkins/linux_unit_tests * Remove Conditional Compilation from OpenSSL/BoringSSL Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/39460 ] This change removes the usages of conditional compilation to support both BoringSSL and OpenSSL, as well as to support multiple versions of the OpenSSL API. All code is now compiled against one of the two versions of BoringSSL in third_party/. Note that in some cases, the kit/ and legacy_kit/ versions of BoringSSL had different APIs, so when removing the OpenSSL version compatibility conditional compilation, sometimes the older branch was kept and sometimes the newer branch was kept. Bug: 67907873 Test: build.py x86-64 Test: wv_ce_cdm_unittest Test: jenkins/linux_unit_tests * Build CE & Jenkins CDMs With BoringSSL from third_party/ Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/37120 ] Up until now, integrators have been responsible for providing a compatible crypto library for use by the CE CDM. (either OpenSSL or BoringSSL) After this change, this decision will no longer be in their hands. The CE CDM build will always use the copy of BoringSSL in third_party/, which will be statically linked with our library with hidden visibility. This allows us to better control what crypto library we use and will prevent continuing problems with trying to support both OpenSSL and BoringSSL. Unfortunately, BoringSSL began using C++11 in mid-2017, and we can't support C++11 right now. Until we can, we need to use a C++11-free version of BoringSSL for libssl. The CDM itself will continue to use a recent BoringSSL, as it only needs libcrypto. But the unit tests that need libssl have to use the legacy version. Bug: 67907873 Test: build.py x86-64 Test: wv_ce_cdm_unittest Test: jenkins/linux_unit_tests * Modified RNG for Level3 to use more entropy Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39220 ] Bug: 65165076 Modified seed generation to use an xor of clock_gettime and client-implemented code to supply random seeds to the RNG. Modified the RNG as well to use xoroshiro128+ instead of xorshift, since it uses more than one seed/state (which are 64-bit) and has higher "statistical quality". The default implementations for the seed generation use /dev/urandom. * Configure base path for Level3FileSystem Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/39506 ] This is in response to b/70354006. This change makes the Android Level3FileSystem use the existing properties method GetDevicesFilesBasePath for binderization. The same is done for the Linux implementation. * Add legacy_kit/ to BoringSSL Directory Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/38861 ] This adds a second copy of BoringSSL to the third_party/boringssl/ directory. This second copy is pinned to the last revision of BoringSSL not to require C++11 and is not updated by the UPDATE_BORINGSSL.sh script. This second copy will be used to provide libssl to the tests on devices that do not support C++11. Once we support C++11 in the CDM again, this weight should be removed and all targets should use the copy of BoringSSL in the kit/ directory. Bug: 67907873 * Use Shared Libraries for Unit Tests Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/38860 ] Some unit tests were using a statically-linked CDM instead of a dynamically-linked one. (Or, in one case, trying to link both ways into the same binary.) For now, we need to only link dynamically, so that the unit tests and the CDM can use different versions of BoringSSL. Long-term, we would like to test both kinds of linkage. (See b/69548115 for that.) Some unit tests were also using a dynamicaly-linked CDM that was named such that it appeared to be statically-linked. This patch renames some targets to make the linkage clearer. Bug: 67907873 * Change CDM_Backwards_Compatiblity_Tests to dedicated brances Author: Fred Gylys-Colwell <fredgc@google.com> [ Merge of http://go/wvgerrit/39003 ] The build scripts used by CDM_Backwards_Compatiblity_Tests now pull old versions of oemcrypto from the dedicated branches oemcrypto-v*, which [will eventually] contain old oemcrypto versions, that build with the current build system with a current boringssl version. bug: 67907873 * Fix spacing on level3 header Author: Srujan Gaddam <srujzs@google.com> [ Merge of http://go/wvgerrit/38760 ] * Correct Query status calls Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/38640 ] Bug: 70160032 * Refactoring to allow encryption of client ID Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/37460 ] The code has been restructured to allow encryption of client identification in provisioning requests. This will be enabled when server side changes have been made (b/69427217). * Additional information is included in the Client Identification portion of the provisioning request. * Client identification will be encrypted with a service certificate provided by the app/client. Platform changes to enable passing this to core are needed. If a service certificate is not provided, a default one associated with the production Keysmith will be used. * Switched APIs in CdmEngine to take a service certificate for provisioning rather than licensing. Service certificates for licensing are session based and passed as properties from platform code. Bug: 30737060 * Allow some CDM errors to be reported from multiple locations Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/38360 ] This creates some CdmResponseType errors which may be reused PARAMETER_NULL, NOT_INITIALIZED_ERROR, REINIT_ERROR. I have made changes to a few classes to report these errors. Will work on additional classes in a separate CL. Bug: 69864404 BUG: 71650075 Test: WV Unit/integration tests Change-Id: Icc048770d424ac537d11ff327cda2cb142da802d
This commit is contained in:
12
libwvdrmengine/level3/README.md
Normal file
12
libwvdrmengine/level3/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
The libwvlevel3.a static libraries under the different platforms were made with
|
||||
the following SYSTEM_IDs:
|
||||
|
||||
arm: 4445
|
||||
arm64: 7283
|
||||
mips: 4465
|
||||
mips64: 7285
|
||||
x86: 4464
|
||||
x86_64: 7284
|
||||
|
||||
Please refer to oemcrypto/level3/android_keybox.cpp for the corresponding
|
||||
product.
|
||||
@@ -10,6 +10,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
|
||||
103624
libwvdrmengine/level3/arm/libl3oemcrypto.cpp
Normal file
103624
libwvdrmengine/level3/arm/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -10,6 +10,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
|
||||
103725
libwvdrmengine/level3/arm64/libl3oemcrypto.cpp
Normal file
103725
libwvdrmengine/level3/arm64/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
63
libwvdrmengine/level3/include/clear_cache_function.h
Normal file
63
libwvdrmengine/level3/include/clear_cache_function.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if __mips__
|
||||
#include <sys/syscall.h>
|
||||
#include <asm/cachectl.h>
|
||||
#endif
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
// The Cache Flush function is very processor dependent, and is used by the
|
||||
// Level3 code using platform-specific flags.
|
||||
// Linked in separately from the rest of the build, since this code isn't
|
||||
// obfuscated and relies on system flags to function properly.
|
||||
void clear_cache_function(void *page, size_t len) {
|
||||
// Note on cross platform support. If __has_builtin is not defined as a
|
||||
// preprocessor function, we cannot use
|
||||
// "#if defined(__has_builtin) && __has_builtin(..)".
|
||||
// So, instead, we will define USED_BUILTIN_CLEAR_CACHE if both conditions
|
||||
// are true, and use "#ifndef USED_BUILTIN_CLEAR_CACHE" instead of #else.
|
||||
#ifdef __has_builtin
|
||||
#if __has_builtin(__builtin___clear_cache)
|
||||
#pragma message "(info): clear_cache_function is using __builtin___clear_cache."
|
||||
#define USED_BUILTIN_CLEAR_CACHE
|
||||
char *begin = static_cast<char *>(page);
|
||||
char *end = begin + len;
|
||||
__builtin___clear_cache(begin, end);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef USED_BUILTIN_CLEAR_CACHE
|
||||
#if __arm__
|
||||
#pragma message "(info): clear_cache_function is using arm asm."
|
||||
// ARM Cache Flush System Call:
|
||||
char *begin = static_cast<char *>(page);
|
||||
char *end = begin + len;
|
||||
const int syscall = 0xf0002;
|
||||
__asm __volatile(
|
||||
"push {r0, r1, r2, r7}\n"
|
||||
"mov r0, %0\n"
|
||||
"mov r1, %1\n"
|
||||
"mov r7, %2\n"
|
||||
"mov r2, #0x0\n"
|
||||
"svc 0x00000000\n"
|
||||
"pop {r0, r1, r2, r7}\n"
|
||||
:
|
||||
: "r"(begin), "r"(end), "r"(syscall)
|
||||
: "r0", "r1", "r7");
|
||||
#elif __mips__
|
||||
#pragma message "(info): clear_cache_function is using mips asm."
|
||||
int result = syscall(__NR_cacheflush, page, len, ICACHE);
|
||||
if (result) {
|
||||
fprintf(stderr, "cacheflush failed!: errno=%d %s\n", errno,
|
||||
strerror(errno));
|
||||
exit(-1); // TODO(fredgc): figure out more graceful error handling.
|
||||
}
|
||||
#else
|
||||
#pragma message "(info): clear_cache_function is not doing anything."
|
||||
// TODO(fredgc): silence warning about unused variables.
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace wvoec3
|
||||
35
libwvdrmengine/level3/include/level3_file_system_android.h
Normal file
35
libwvdrmengine/level3/include/level3_file_system_android.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved
|
||||
|
||||
/*********************************************************************
|
||||
* level3_file_system_android.h
|
||||
*
|
||||
* File system for Android for OEMCrypto Level3 File Operations.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef LEVEL3_FILE_SYSTEM_ANDROID_H_
|
||||
#define LEVEL3_FILE_SYSTEM_ANDROID_H_
|
||||
|
||||
#include "level3_file_system.h"
|
||||
|
||||
#include "file_store.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
class OEMCrypto_Level3AndroidFileSystem : public OEMCrypto_Level3FileSystem {
|
||||
public:
|
||||
OEMCrypto_Level3AndroidFileSystem();
|
||||
~OEMCrypto_Level3AndroidFileSystem();
|
||||
ssize_t Read(const char *filename, void *buffer, size_t size);
|
||||
ssize_t Write(const char *filename, const void *buffer, size_t size);
|
||||
bool Exists(const char *filename);
|
||||
ssize_t FileSize(const char *filename);
|
||||
bool Remove(const char *filename);
|
||||
|
||||
private:
|
||||
std::string base_path_;
|
||||
wvcdm::FileSystem *file_system_;
|
||||
};
|
||||
|
||||
} // namespace wvoec3
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
|
||||
@@ -1,396 +0,0 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Stubs for OEMCrypto Level 3 Fallback APIs. (use when level 3 doesn't compile)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "level3.h"
|
||||
|
||||
// This error string shows up when we run "strings libwvleel3.a"
|
||||
const char* error_string = "Level3 Library is stubbed out.";
|
||||
|
||||
namespace wvoec3 {
|
||||
bool Level3_IsInApp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Initialize(void (*/*ClearCache*/)(void *, size_t),
|
||||
const char* /*base_path*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Terminate(void) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_OpenSession(OEMCrypto_SESSION* /*session*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CloseSession(OEMCrypto_SESSION /*session*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateDerivedKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*mac_key_context*/,
|
||||
uint32_t /*mac_key_context_length*/,
|
||||
const uint8_t* /*enc_key_context*/,
|
||||
uint32_t /*enc_key_context_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateNonce(OEMCrypto_SESSION /*session*/,
|
||||
uint32_t* /*nonce*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateSignature(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
const uint8_t* /*enc_mac_key_iv*/,
|
||||
const uint8_t* /*enc_mac_key*/,
|
||||
size_t /*num_keys*/,
|
||||
const OEMCrypto_KeyObject* /*key_array*/,
|
||||
const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/,
|
||||
const uint8_t* /*srm_requirement*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RefreshKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
size_t /*num_keys*/,
|
||||
const OEMCrypto_KeyRefreshObject* /*key_array*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_QueryKeyControl(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*key_id*/,
|
||||
size_t /*key_id_length*/,
|
||||
uint8_t* /*key_control_block*/,
|
||||
size_t* /*key_control_block_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_SelectKey(const OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*key_id*/,
|
||||
size_t /*key_id_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DecryptCENC(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*data_addr*/, size_t /*data_length*/,
|
||||
bool /*is_encrypted*/, const uint8_t* /*iv*/,
|
||||
size_t /*block_offset*/,
|
||||
const OEMCrypto_DestBufferDesc* /*out_buffer*/,
|
||||
const OEMCrypto_CENCEncryptPatternDesc* /*pattern*/,
|
||||
uint8_t /*subsample_flags*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CopyBuffer(const uint8_t */*data_addr*/,
|
||||
size_t /*data_length*/,
|
||||
OEMCrypto_DestBufferDesc* /*out_buffer*/,
|
||||
uint8_t /*subsample_flags*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_WrapKeybox(const uint8_t* /*keybox*/,
|
||||
size_t /*keyBoxLength*/,
|
||||
uint8_t* /*wrappedKeybox*/,
|
||||
size_t* /*wrappedKeyBoxLength*/,
|
||||
const uint8_t* /*transportKey*/,
|
||||
size_t /*transportKeyLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_InstallKeybox(const uint8_t* /*keybox*/,
|
||||
size_t /*keyBoxLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadTestKeybox() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_IsKeyboxValid(void) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetDeviceID(uint8_t* /*deviceID*/, size_t* /*idLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetKeyData(uint8_t* /*keyData*/,
|
||||
size_t* /*keyDataLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetRandom(uint8_t* /*randomData*/, size_t /*dataLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RewrapDeviceRSAKey30(OEMCrypto_SESSION /*session*/,
|
||||
const uint32_t */*nonce*/,
|
||||
const uint8_t* /*encrypted_message_key*/,
|
||||
size_t /*encrypted_message_key_length*/,
|
||||
const uint8_t* /*enc_rsa_key*/,
|
||||
size_t /*enc_rsa_key_length*/,
|
||||
const uint8_t* /*enc_rsa_key_iv*/,
|
||||
uint8_t* /*wrapped_rsa_key*/,
|
||||
size_t* /*wrapped_rsa_key_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RewrapDeviceRSAKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
const uint32_t* /*nonce*/,
|
||||
const uint8_t* /*enc_rsa_key*/,
|
||||
size_t /*enc_rsa_key_length*/,
|
||||
const uint8_t* /*enc_rsa_key_iv*/,
|
||||
uint8_t* /*wrapped_rsa_key*/,
|
||||
size_t* /*wrapped_rsa_key_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadDeviceRSAKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*wrapped_rsa_key*/,
|
||||
size_t /*wrapped_rsa_key_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadTestRSAKey() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateRSASignature(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/,
|
||||
RSA_Padding_Scheme /*padding_scheme*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeriveKeysFromSessionKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*enc_session_key*/,
|
||||
size_t /*enc_session_key_length*/,
|
||||
const uint8_t* /*mac_key_context*/,
|
||||
size_t /*mac_key_context_length*/,
|
||||
const uint8_t* /*enc_key_context*/,
|
||||
size_t /*enc_key_context_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t Level3_APIVersion() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint8_t Level3_SecurityPatchLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OEMCrypto_ProvisioningMethod Level3_GetProvisioningMethod() {
|
||||
return OEMCrypto_ProvisioningError;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetOEMPublicCertificate(OEMCrypto_SESSION /*session*/,
|
||||
uint8_t */*public_cert*/,
|
||||
size_t */*public_cert_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
const char* Level3_SecurityLevel() {
|
||||
return "L3";
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetHDCPCapability(OEMCrypto_HDCP_Capability */*current*/,
|
||||
OEMCrypto_HDCP_Capability */*maximum*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
bool Level3_SupportsUsageTable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Level3_IsAntiRollbackHwPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetNumberOfOpenSessions(size_t* /*count*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetMaxNumberOfSessions(size_t* /*maximum*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t Level3_SupportedCertificates() { return 0; }
|
||||
|
||||
OEMCryptoResult Level3_Generic_Encrypt(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
const uint8_t* /*iv*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*out_buffer*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Decrypt(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
const uint8_t* /*iv*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*out_buffer*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Sign(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Verify(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeactivateUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t */*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_UpdateUsageTable() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_ReportUsage(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t */*pst*/,
|
||||
size_t /*pst_length*/,
|
||||
uint8_t */*buffer*/,
|
||||
size_t */*buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeleteUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/,
|
||||
const uint8_t */*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t */*signature*/,
|
||||
size_t /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_ForceDeleteUsageEntry(const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeleteOldUsageTable() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
bool Level3_IsSRMUpdateSupported() {
|
||||
return false;
|
||||
}
|
||||
OEMCryptoResult Level3_GetCurrentSRMVersion(uint16_t* /*version*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadSRM(const uint8_t* /*buffer*/,
|
||||
size_t /*buffer_length*/){
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RemoveSRM() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CreateUsageTableHeader(uint8_t* /*header_buffer*/,
|
||||
size_t* /*header_buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadUsageTableHeader(const uint8_t* /*buffer*/,
|
||||
size_t /*buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CreateNewUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
uint32_t */*usage_entry_number*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
uint32_t /*index*/,
|
||||
const uint8_t */*buffer*/,
|
||||
size_t /*buffer_size*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_UpdateUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
uint8_t* /*header_buffer*/,
|
||||
size_t* /*header_buffer_length*/,
|
||||
uint8_t* /*entry_buffer*/,
|
||||
size_t* /*entry_buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_ShrinkUsageTableHeader(uint32_t /*new_table_size*/,
|
||||
uint8_t* /*header_buffer*/,
|
||||
size_t* /*header_buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_MoveEntry(OEMCrypto_SESSION /*session*/,
|
||||
uint32_t /*new_index*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CopyOldUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t*/*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CreateOldUsageEntry(uint64_t /*time_since_license_received*/,
|
||||
uint64_t /*time_since_first_decrypt*/,
|
||||
uint64_t /*time_since_last_decrypt*/,
|
||||
OEMCrypto_Usage_Entry_Status /*status*/,
|
||||
uint8_t */*server_mac_key*/,
|
||||
uint8_t */*client_mac_key*/,
|
||||
const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
} // namespace wvoec3
|
||||
107062
libwvdrmengine/level3/mips/libl3oemcrypto.cpp
Normal file
107062
libwvdrmengine/level3/mips/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
21
libwvdrmengine/level3/mips64/Android.mk
Normal file
21
libwvdrmengine/level3/mips64/Android.mk
Normal file
@@ -0,0 +1,21 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_CFLAGS := \
|
||||
-DDYNAMIC_ADAPTER \
|
||||
-Wno-unused
|
||||
LOCAL_C_INCLUDES := \
|
||||
vendor/widevine/libwvdrmengine/cdm/core/include \
|
||||
vendor/widevine/libwvdrmengine/level3/include \
|
||||
vendor/widevine/libwvdrmengine/oemcrypto/include
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_OWNER := widevine
|
||||
LOCAL_MODULE_TARGET_ARCH := mips64
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
102963
libwvdrmengine/level3/mips64/libl3oemcrypto.cpp
Normal file
102963
libwvdrmengine/level3/mips64/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
28
libwvdrmengine/level3/src/generate_entropy_android.cpp
Normal file
28
libwvdrmengine/level3/src/generate_entropy_android.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "level3.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
uint64_t generate_entropy() {
|
||||
FILE* urandom_file = fopen("/dev/urandom", "r");
|
||||
uint64_t value = 0;
|
||||
if (urandom_file) {
|
||||
if (fread(&value, 8, 1, urandom_file) != 1) {
|
||||
LOGE("Could not read from file /dev/urandom. errno=%s", strerror(errno));
|
||||
}
|
||||
if (fclose(urandom_file) != 0) {
|
||||
LOGE("Could not close file /dev/urandom. errno=%s", strerror(errno));
|
||||
}
|
||||
} else {
|
||||
LOGE("Could not open file /dev/urandom. errno=%s", strerror(errno));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace wvoec3
|
||||
32
libwvdrmengine/level3/src/get_unique_id_android.cpp
Normal file
32
libwvdrmengine/level3/src/get_unique_id_android.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "level3.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// The function property_get is defined differently if it comes from the IN_APP
|
||||
// version or from the Android OS.
|
||||
#if defined(IN_APP_FASTBALL)
|
||||
#include "inapp/fastball/include/properties_fastball.h"
|
||||
#else
|
||||
#include <cutils/properties.h>
|
||||
#endif
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
const char *getUniqueID(size_t *len) {
|
||||
static char temp_value[PROPERTY_VALUE_MAX * 2];
|
||||
int actual_len = property_get("ro.serialno", temp_value, NULL);
|
||||
if (actual_len <= 0) {
|
||||
actual_len = property_get("net.hostname", temp_value, NULL);
|
||||
}
|
||||
if (actual_len <= 0) {
|
||||
strncpy(temp_value, "0123456789abc", PROPERTY_VALUE_MAX);
|
||||
}
|
||||
#if defined(IN_APP_FASTBALL) || defined(IN_APP_MOVIES)
|
||||
actual_len +=
|
||||
property_get("package.name", temp_value + actual_len, "com.google.inapp");
|
||||
#endif
|
||||
*len = actual_len;
|
||||
return temp_value;
|
||||
}
|
||||
|
||||
} // namespace wvoec3
|
||||
86
libwvdrmengine/level3/src/level3_file_system_android.cpp
Normal file
86
libwvdrmengine/level3/src/level3_file_system_android.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "level3_file_system_android.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "log.h"
|
||||
#include "properties.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
using wvcdm::File;
|
||||
using wvcdm::FileSystem;
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
OEMCrypto_Level3AndroidFileSystem::OEMCrypto_Level3AndroidFileSystem()
|
||||
: file_system_(new FileSystem) {
|
||||
const char kDirectoryDelimiter = '/';
|
||||
wvcdm::Properties::GetDeviceFilesBasePath(wvcdm::kSecurityLevelL3,
|
||||
&base_path_);
|
||||
size_t size = base_path_.size();
|
||||
if (size < 2) {
|
||||
// Default value is set to make sure unit tests pass, running as root.
|
||||
base_path_ = "/data/";
|
||||
size = base_path_.size();
|
||||
} else if (base_path_[size - 1] != kDirectoryDelimiter) {
|
||||
base_path_ = base_path_ + "/";
|
||||
}
|
||||
size_t pos = base_path_.find(kDirectoryDelimiter, 1);
|
||||
while (pos < size) {
|
||||
base_path_[pos] = '\0';
|
||||
if (mkdir(base_path_.c_str(), 0775) != 0 && errno != EEXIST) {
|
||||
wvcdm::Log(
|
||||
"", "", 0, wvcdm::LOG_ERROR,
|
||||
"Could not create base directories for Level3FileSystem, error: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
base_path_[pos] = kDirectoryDelimiter;
|
||||
pos = base_path_.find(kDirectoryDelimiter, pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
OEMCrypto_Level3AndroidFileSystem::~OEMCrypto_Level3AndroidFileSystem() {
|
||||
delete file_system_;
|
||||
file_system_ = NULL;
|
||||
}
|
||||
|
||||
ssize_t OEMCrypto_Level3AndroidFileSystem::Read(const char *filename,
|
||||
void *buffer, size_t size) {
|
||||
File *file = file_system_->Open(base_path_ + std::string(filename),
|
||||
FileSystem::kReadOnly);
|
||||
ssize_t bytes_read = 0;
|
||||
if (file) {
|
||||
bytes_read = file->Read(static_cast<char *>(buffer), size);
|
||||
file->Close();
|
||||
}
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
ssize_t OEMCrypto_Level3AndroidFileSystem::Write(const char *filename,
|
||||
const void *buffer,
|
||||
size_t size) {
|
||||
File *file = file_system_->Open(base_path_ + std::string(filename),
|
||||
FileSystem::kCreate | FileSystem::kTruncate);
|
||||
ssize_t bytes_written = 0;
|
||||
if (file) {
|
||||
bytes_written = file->Write(static_cast<const char *>(buffer), size);
|
||||
file->Close();
|
||||
}
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
bool OEMCrypto_Level3AndroidFileSystem::Exists(const char *filename) {
|
||||
return file_system_->Exists(base_path_ + std::string(filename));
|
||||
}
|
||||
|
||||
ssize_t OEMCrypto_Level3AndroidFileSystem::FileSize(const char *filename) {
|
||||
return file_system_->FileSize(base_path_ + std::string(filename));
|
||||
}
|
||||
|
||||
bool OEMCrypto_Level3AndroidFileSystem::Remove(const char *filename) {
|
||||
return file_system_->Remove(base_path_ + std::string(filename));
|
||||
}
|
||||
} // namespace wvoec3
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "level3.h"
|
||||
|
||||
#include "level3_file_system_android.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
|
||||
OEMCrypto_Level3FileSystem* createLevel3FileSystem() {
|
||||
return new OEMCrypto_Level3AndroidFileSystem();
|
||||
}
|
||||
|
||||
void deleteLevel3FileSystem(OEMCrypto_Level3FileSystem* file_system) {
|
||||
if (file_system) {
|
||||
delete file_system;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvoec3
|
||||
@@ -10,6 +10,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
|
||||
75119
libwvdrmengine/level3/x86/libl3oemcrypto.cpp
Normal file
75119
libwvdrmengine/level3/x86/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -10,6 +10,7 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
LOCAL_SRC_FILES := libl3oemcrypto.cpp \
|
||||
../src/generate_entropy_android.cpp \
|
||||
../src/get_unique_id_android.cpp \
|
||||
../src/level3_file_system_android.cpp \
|
||||
../src/level3_file_system_android_factory.cpp
|
||||
|
||||
88346
libwvdrmengine/level3/x86_64/libl3oemcrypto.cpp
Normal file
88346
libwvdrmengine/level3/x86_64/libl3oemcrypto.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user