Merge "OEMCrypto Unit Tests"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3ff106f86a
@@ -9,8 +9,8 @@ namespace wvcdm {
|
||||
|
||||
enum SecurityLevel { kLevelDefault, kLevel3 };
|
||||
|
||||
/* This attempts to open a session at the desired security level.
|
||||
If one level is not available, the other will be used instead. */
|
||||
// This attempts to open a session at the desired security level.
|
||||
// If one level is not available, the other will be used instead.
|
||||
OEMCryptoResult OEMCrypto_OpenSession(OEMCrypto_SESSION* session,
|
||||
SecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_CopyBuffer(
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
@@ -240,14 +241,18 @@ class Adapter {
|
||||
OEMCryptoResult Initialize() {
|
||||
LoadLevel3();
|
||||
OEMCryptoResult result = Level3_Initialize();
|
||||
if (force_level3()) {
|
||||
LOGW("Test code. User requested falling back to L3");
|
||||
return result;
|
||||
}
|
||||
std::string library_name;
|
||||
if (!wvcdm::Properties::GetOEMCryptoPath(&library_name)) {
|
||||
LOGW("L1 library not specified. Falling Back to L3");
|
||||
LOGW("L1 library not specified. Falling back to L3");
|
||||
return result;
|
||||
}
|
||||
level1_library_ = dlopen(library_name.c_str(), RTLD_NOW);
|
||||
if (level1_library_ == NULL) {
|
||||
LOGW("Could not load %s. Falling Back to L3. %s", library_name.c_str(),
|
||||
LOGW("Could not load %s. Falling back to L3. %s", library_name.c_str(),
|
||||
dlerror());
|
||||
return result;
|
||||
}
|
||||
@@ -496,6 +501,14 @@ class Adapter {
|
||||
// If we add this to the level 3 session id, then the external session
|
||||
// id will match the internal session id in the last two digits.
|
||||
static const OEMCrypto_SESSION kLevel3Offset = 25600;
|
||||
|
||||
// For running the unit tests using the level 3 oemcrypto. If the user sets
|
||||
// the environment FORCE_LEVEL3_OEMCRYPTO, we ignore the level 1 library.
|
||||
bool force_level3() {
|
||||
const char* var = getenv("FORCE_LEVEL3_OEMCRYPTO");
|
||||
if (!var) return false;
|
||||
return !strcmp(var, "yes");
|
||||
}
|
||||
};
|
||||
|
||||
static Adapter* kAdapter = 0;
|
||||
|
||||
Reference in New Issue
Block a user