Merge changes Ib82cf7a1,Ice6a8eab into oc-dev

* changes:
  Hash OEM Certificate
  Maxing Out Sessions Can Cause SPOID Failures
This commit is contained in:
John Bruce
2017-04-20 17:21:46 +00:00
committed by Android (Google) Code Review
8 changed files with 136 additions and 170 deletions

View File

@@ -43,7 +43,8 @@ class CryptoSession {
return pre_provision_token_type_;
}
virtual CdmSecurityLevel GetSecurityLevel();
virtual bool GetDeviceUniqueId(std::string* device_id);
virtual bool GetInternalDeviceUniqueId(std::string* device_id);
virtual bool GetExternalDeviceUniqueId(std::string* device_id);
virtual bool GetApiVersion(uint32_t* version);
virtual bool GetSystemId(uint32_t* system_id);
virtual bool GetProvisioningId(std::string* provisioning_id);

View File

@@ -546,7 +546,7 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
std::string deviceId;
bool got_id;
M_TIME(
got_id = crypto_session.GetDeviceUniqueId(
got_id = crypto_session.GetExternalDeviceUniqueId(
&deviceId),
&metrics_,
crypto_session_get_device_unique_id_,

View File

@@ -97,7 +97,7 @@ bool CertificateProvisioning::FillStableIdField(
} else if (origin != EMPTY_ORIGIN) {
// Legacy behavior - Concatenate Unique ID with Origin
std::string device_unique_id;
if (!crypto_session_.GetDeviceUniqueId(&device_unique_id)) {
if (!crypto_session_.GetInternalDeviceUniqueId(&device_unique_id)) {
LOGE("CryptoSession::GetStableIdField: Failure to get device unique ID");
return false;
}

View File

@@ -13,6 +13,7 @@
#include "crypto_key.h"
#include "log.h"
#include "metrics_front_end.h"
#include "openssl/sha.h"
#include "properties.h"
#include "pst_report.h"
#include "string_conversions.h"
@@ -242,13 +243,14 @@ CdmSecurityLevel CryptoSession::GetSecurityLevel() {
return kSecurityLevelUnknown;
}
bool CryptoSession::GetDeviceUniqueId(std::string* device_id) {
bool CryptoSession::GetInternalDeviceUniqueId(std::string* device_id) {
if (!device_id) {
LOGE("CryptoSession::GetDeviceUniqueId : No buffer passed to method.");
LOGE("CryptoSession::GetInternalDeviceUniqueId : No buffer passed to "
"method.");
return false;
}
LOGV("CryptoSession::GetDeviceUniqueId: Lock");
LOGV("CryptoSession::GetInternalDeviceUniqueId: Lock");
AutoLock auto_lock(crypto_lock_);
if (!initialized_) {
return false;
@@ -281,6 +283,26 @@ bool CryptoSession::GetDeviceUniqueId(std::string* device_id) {
}
}
bool CryptoSession::GetExternalDeviceUniqueId(std::string* device_id) {
std::string temp;
if (!GetInternalDeviceUniqueId(&temp)) return false;
if (pre_provision_token_type_ == kClientTokenOemCert) {
// To keep the size of the value passed back to the application down, hash
// the large OEM Public Cert to a smaller value.
uint8_t hash[SHA256_DIGEST_LENGTH];
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, temp.data(), temp.length());
SHA256_Final(hash, &ctx);
temp.assign(reinterpret_cast<char*>(hash), SHA256_DIGEST_LENGTH);
}
*device_id = temp;
return true;
}
bool CryptoSession::GetApiVersion(uint32_t* version) {
if (!version) {
LOGE("CryptoSession::GetApiVersion: No buffer passed to method.");

View File

@@ -918,7 +918,7 @@ CdmResponseType CdmLicense::PrepareClientId(
client_info->set_name(kBuildInfoKey);
client_info->set_value(value);
}
if (crypto_session_->GetDeviceUniqueId(&value)) {
if (crypto_session_->GetInternalDeviceUniqueId(&value)) {
client_info = client_id->add_client_info();
client_info->set_name(kDeviceIdKey);
client_info->set_value(value);