Commit e20b1fc0 authored by Michael Ershov's avatar Michael Ershov Committed by Commit Bot

Improve TpmAttestationGetPublicKey function in FakeCryptohomeClient

This change fixes a bug that prevented FakeCryptohomeClient from
answering on TpmAttestationGetPublicKey request and adds a helper
function to configure its result.

Bug: 1045895
Change-Id: I4f7a72c2768f78df97c43756932ca7700a62b999
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050277Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Michael Ershov <miersh@google.com>
Cr-Commit-Position: refs/heads/master@{#740599}
parent 9126b2a1
......@@ -60,6 +60,9 @@ FakeCryptohomeClient::FakeCryptohomeClient() {
base::PathExists(cache_path);
if (locked_)
LoadInstallAttributes();
set_tpm_attestation_public_key(
TpmAttestationDataResult{true, "fake_public_key_for_test"});
}
FakeCryptohomeClient::~FakeCryptohomeClient() {
......@@ -453,7 +456,7 @@ void FakeCryptohomeClient::TpmAttestationGetPublicKey(
DBusMethodCallback<TpmAttestationDataResult> callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback), TpmAttestationDataResult{}));
base::BindOnce(std::move(callback), tpm_attestation_public_key_));
}
void FakeCryptohomeClient::TpmAttestationRegisterKey(
......@@ -461,7 +464,7 @@ void FakeCryptohomeClient::TpmAttestationRegisterKey(
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
AsyncMethodCallback callback) {
ReturnAsyncMethodData(std::move(callback), std::string());
ReturnAsyncMethodResult(std::move(callback));
}
void FakeCryptohomeClient::TpmAttestationSignEnterpriseChallenge(
......
......@@ -321,6 +321,11 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
tpm_attestation_does_key_exist_should_succeed_ = should_succeed;
}
void set_tpm_attestation_public_key(
base::Optional<TpmAttestationDataResult> value) {
tpm_attestation_public_key_ = value;
}
void set_supports_low_entropy_credentials(bool supports) {
supports_low_entropy_credentials_ = supports;
}
......@@ -486,6 +491,7 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
bool enable_auth_check_ = false;
bool tpm_is_ready_ = true;
bool tpm_is_enabled_ = true;
base::Optional<TpmAttestationDataResult> tpm_attestation_public_key_;
// Reply to GetRsuDeviceId().
std::string rsu_device_id_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment