From 1e451340ba37e4b53448efe7377a9795416821a0 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 26 Apr 2017 20:01:20 -0700 Subject: [PATCH] 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 --- ...oemcrypto_engine_device_properties_mod.cpp | 6 +++++- .../oemcrypto/mock/src/oemcrypto_session.cpp | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_mod.cpp b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_mod.cpp index fe2be840..9f7551cf 100644 --- a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_mod.cpp +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_mod.cpp @@ -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; } } diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_session.cpp b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_session.cpp index 80a304fb..93e66832 100644 --- a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_session.cpp +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_session.cpp @@ -410,17 +410,18 @@ OEMCryptoResult SessionContext::LoadKeys( uint32_t minimum_version = htonl(*reinterpret_cast(srm_requirement + 8)); uint16_t current_version = 0; - if (OEMCrypto_SUCCESS == ce_->current_srm_version(¤t_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(¤t_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; } }