Merge changes I10721146,I5ab5f554,Ie92379dc
* changes: OEMCrypto Mock should not downgrade SRM Fix SRM Version in mock OEMCrypto Logging
This commit is contained in:
committed by
Android (Google) Code Review
commit
b37ab7eead
@@ -346,14 +346,18 @@ class AndroidModifiableCryptoEngine : public CryptoEngine {
|
|||||||
|
|
||||||
OEMCryptoResult current_srm_version(uint16_t *version) {
|
OEMCryptoResult current_srm_version(uint16_t *version) {
|
||||||
if (srm_loaded_) {
|
if (srm_loaded_) {
|
||||||
|
LOGV("SRM loaded. version used is %d.", srm_version_);
|
||||||
*version = srm_version_;
|
*version = srm_version_;
|
||||||
return OEMCrypto_SUCCESS;
|
return OEMCrypto_SUCCESS;
|
||||||
}
|
}
|
||||||
int value = GetOption("srm_initial_version", -1);
|
int value = GetOption("srm_initial_version", -1);
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
*version = srm_version_;
|
LOGV("SRM version from get option: %d.", value);
|
||||||
|
srm_version_ = value;
|
||||||
|
*version = value;
|
||||||
return OEMCrypto_SUCCESS;
|
return OEMCrypto_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
|
LOGI("SRM initial version is %d -- reporting not implemented.", value);
|
||||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,6 +374,11 @@ class AndroidModifiableCryptoEngine : public CryptoEngine {
|
|||||||
}
|
}
|
||||||
int new_version = GetOption("srm_load_version", -1);
|
int new_version = GetOption("srm_load_version", -1);
|
||||||
if (new_version >= 0) {
|
if (new_version >= 0) {
|
||||||
|
if (new_version < srm_version_) {
|
||||||
|
LOGE("New SRM version is lower than existing SRM version: %d < %d",
|
||||||
|
new_version, srm_version_);
|
||||||
|
return OEMCrypto_ERROR_INVALID_CONTEXT;
|
||||||
|
}
|
||||||
srm_version_ = new_version;
|
srm_version_ = new_version;
|
||||||
LOGI("OEMCrypto mock told to change SRM version to %d.", srm_version_);
|
LOGI("OEMCrypto mock told to change SRM version to %d.", srm_version_);
|
||||||
srm_loaded_ = true;
|
srm_loaded_ = true;
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ extern "C" OEMCryptoResult OEMCrypto_QueryKeyControl(
|
|||||||
extern "C" OEMCryptoResult OEMCrypto_SelectKey(const OEMCrypto_SESSION session,
|
extern "C" OEMCryptoResult OEMCrypto_SelectKey(const OEMCrypto_SESSION session,
|
||||||
const uint8_t* key_id,
|
const uint8_t* key_id,
|
||||||
size_t key_id_length) {
|
size_t key_id_length) {
|
||||||
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
|
if (LogCategoryEnabled(kLoggingTraceDecryptCalls)) {
|
||||||
LOGI("-- OEMCryptoResult OEMCrypto_SelectKey(%d, id=%s)", session,
|
LOGI("-- OEMCryptoResult OEMCrypto_SelectKey(%d, id=%s)", session,
|
||||||
wvcdm::HexEncode(key_id, key_id_length).c_str());
|
wvcdm::HexEncode(key_id, key_id_length).c_str());
|
||||||
}
|
}
|
||||||
@@ -1630,6 +1630,9 @@ extern "C" OEMCryptoResult OEMCrypto_DeleteOldUsageTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" bool OEMCrypto_IsSRMUpdateSupported() {
|
extern "C" bool OEMCrypto_IsSRMUpdateSupported() {
|
||||||
|
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
|
||||||
|
LOGI("-- OEMCryptoResult OEMCrypto_IsSRMUpdateSupported()\n");
|
||||||
|
}
|
||||||
if (!crypto_engine) {
|
if (!crypto_engine) {
|
||||||
LOGE("OEMCrypto_IsSRMUpdateSupported: OEMCrypto Not Initialized.");
|
LOGE("OEMCrypto_IsSRMUpdateSupported: OEMCrypto Not Initialized.");
|
||||||
return false;
|
return false;
|
||||||
@@ -1638,6 +1641,9 @@ extern "C" bool OEMCrypto_IsSRMUpdateSupported() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" OEMCryptoResult OEMCrypto_GetCurrentSRMVersion(uint16_t* version) {
|
extern "C" OEMCryptoResult OEMCrypto_GetCurrentSRMVersion(uint16_t* version) {
|
||||||
|
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
|
||||||
|
LOGI("-- OEMCryptoResult OEMCrypto_GetCurrentSRMVersion()\n");
|
||||||
|
}
|
||||||
if (!crypto_engine) {
|
if (!crypto_engine) {
|
||||||
LOGE("OEMCrypto_GetCurrentSRMVersion: OEMCrypto Not Initialized.");
|
LOGE("OEMCrypto_GetCurrentSRMVersion: OEMCrypto Not Initialized.");
|
||||||
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1650,6 +1656,9 @@ extern "C" OEMCryptoResult OEMCrypto_GetCurrentSRMVersion(uint16_t* version) {
|
|||||||
|
|
||||||
extern "C" OEMCryptoResult OEMCrypto_LoadSRM(const uint8_t* buffer,
|
extern "C" OEMCryptoResult OEMCrypto_LoadSRM(const uint8_t* buffer,
|
||||||
size_t buffer_length) {
|
size_t buffer_length) {
|
||||||
|
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
|
||||||
|
LOGI("-- OEMCryptoResult OEMCrypto_LoadSRM(length=%d)\n", buffer_length);
|
||||||
|
}
|
||||||
if (!crypto_engine) {
|
if (!crypto_engine) {
|
||||||
LOGE("OEMCrypto_LoadSRM: OEMCrypto Not Initialized.");
|
LOGE("OEMCrypto_LoadSRM: OEMCrypto Not Initialized.");
|
||||||
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1658,6 +1667,9 @@ extern "C" OEMCryptoResult OEMCrypto_LoadSRM(const uint8_t* buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" OEMCryptoResult OEMCrypto_RemoveSRM() {
|
extern "C" OEMCryptoResult OEMCrypto_RemoveSRM() {
|
||||||
|
if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) {
|
||||||
|
LOGI("-- OEMCryptoResult OEMCrypto_RemoveSRM()\n");
|
||||||
|
}
|
||||||
if (!crypto_engine) {
|
if (!crypto_engine) {
|
||||||
LOGE("OEMCrypto_RemoveSRM: OEMCrypto Not Initialized.");
|
LOGE("OEMCrypto_RemoveSRM: OEMCrypto Not Initialized.");
|
||||||
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
|
|||||||
@@ -410,17 +410,18 @@ OEMCryptoResult SessionContext::LoadKeys(
|
|||||||
uint32_t minimum_version =
|
uint32_t minimum_version =
|
||||||
htonl(*reinterpret_cast<const uint32_t*>(srm_requirement + 8));
|
htonl(*reinterpret_cast<const uint32_t*>(srm_requirement + 8));
|
||||||
uint16_t current_version = 0;
|
uint16_t current_version = 0;
|
||||||
if (OEMCrypto_SUCCESS == ce_->current_srm_version(¤t_version) &&
|
if (OEMCrypto_SUCCESS != ce_->current_srm_version(¤t_version)) {
|
||||||
current_version >= minimum_version) {
|
LOGW("[LoadKeys: SRM Version not available.");
|
||||||
srm_requirements_status_ = ValidSRMVersion;
|
srm_requirements_status_ = InvalidSRMVersion;
|
||||||
if (ce_->srm_blacklisted_device_attached()) {
|
} else if (current_version < minimum_version) {
|
||||||
LOGW("[LoadKeys: SRM blacklisted device attached]");
|
LOGW("[LoadKeys: SRM Version is too small %d, required: %d",
|
||||||
srm_requirements_status_ = InvalidSRMVersion;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGW("[LoadKeys: SRM Version too small %d, required: %d",
|
|
||||||
current_version, minimum_version);
|
current_version, minimum_version);
|
||||||
srm_requirements_status_ = InvalidSRMVersion;
|
srm_requirements_status_ = InvalidSRMVersion;
|
||||||
|
} else if (ce_->srm_blacklisted_device_attached()) {
|
||||||
|
LOGW("[LoadKeys: SRM blacklisted device attached]");
|
||||||
|
srm_requirements_status_ = InvalidSRMVersion;
|
||||||
|
} else {
|
||||||
|
srm_requirements_status_ = ValidSRMVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user