Fix SRM Version in mock

Merge from Widevine repo of http://go/wvgerrit/26522

The modifiable OEMCrypto mock did not use the correct initial SRM
version as specified in the options file.  This CL fixes that.

b/37713658

Change-Id: I5ab5f5549dd7815edd4a3d69b804440faedeb657
This commit is contained in:
Fred Gylys-Colwell
2017-04-26 20:01:20 -07:00
parent ad94e69d03
commit 1e451340ba
2 changed files with 15 additions and 10 deletions

View File

@@ -346,14 +346,18 @@ class AndroidModifiableCryptoEngine : public CryptoEngine {
OEMCryptoResult current_srm_version(uint16_t *version) {
if (srm_loaded_) {
LOGV("SRM loaded. version used is %d.", srm_version_);
*version = srm_version_;
return OEMCrypto_SUCCESS;
}
int value = GetOption("srm_initial_version", -1);
if (value > 0) {
*version = srm_version_;
LOGV("SRM version from get option: %d.", value);
srm_version_ = value;
*version = value;
return OEMCrypto_SUCCESS;
} else {
LOGI("SRM initial version is %d -- reporting not implemented.", value);
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
}

View File

@@ -410,17 +410,18 @@ OEMCryptoResult SessionContext::LoadKeys(
uint32_t minimum_version =
htonl(*reinterpret_cast<const uint32_t*>(srm_requirement + 8));
uint16_t current_version = 0;
if (OEMCrypto_SUCCESS == ce_->current_srm_version(&current_version) &&
current_version >= minimum_version) {
srm_requirements_status_ = ValidSRMVersion;
if (ce_->srm_blacklisted_device_attached()) {
LOGW("[LoadKeys: SRM blacklisted device attached]");
srm_requirements_status_ = InvalidSRMVersion;
}
} else {
LOGW("[LoadKeys: SRM Version too small %d, required: %d",
if (OEMCrypto_SUCCESS != ce_->current_srm_version(&current_version)) {
LOGW("[LoadKeys: SRM Version not available.");
srm_requirements_status_ = InvalidSRMVersion;
} else if (current_version < minimum_version) {
LOGW("[LoadKeys: SRM Version is too small %d, required: %d",
current_version, minimum_version);
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;
}
}