Commit f9696dfb authored by Leo Lai's avatar Leo Lai Committed by Commit Bot

remove TpmAttestation[GS]KeyPayload APIs

Now we are using AttestationClient directly instead of passing through
CryptohomeClient.

BUG=b:158955123
TEST=build ok.

Change-Id: Id0b3ad20b68682ba1abea184ebf2ba7e79ce8459
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2497904
Commit-Queue: Leo Lai <cylai@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821574}
parent a11eaddb
......@@ -700,45 +700,6 @@ class CryptohomeClientImpl : public CryptohomeClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
DBusMethodCallback<TpmAttestationDataResult> callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeTpmAttestationGetKeyPayload);
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
writer.AppendString(id.account_id());
writer.AppendString(key_name);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnTpmAttestationDataMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void TpmAttestationSetKeyPayload(attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
const std::string& payload,
DBusMethodCallback<bool> callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeTpmAttestationSetKeyPayload);
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
writer.AppendString(id.account_id());
writer.AppendString(key_name);
writer.AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(payload.data()),
payload.size());
CallBoolMethod(&method_call, std::move(callback));
}
// CryptohomeClient override.
void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) override {
dbus::MethodCall method_call(
......
......@@ -450,30 +450,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient {
const std::string& challenge,
AsyncMethodCallback callback) = 0;
// Gets the payload associated with the key specified by |key_type| and
// |key_name|. The |callback| will be called when the operation completes.
// If the key does not exist the callback |result| parameter will be false.
// If no payload has been set for the key the callback |result| parameter will
// be true and the |data| parameter will be empty. If |key_type| is
// KEY_USER, a |id| must be provided. Otherwise |id| is ignored.
virtual void TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
DBusMethodCallback<TpmAttestationDataResult> callback) = 0;
// Sets the |payload| associated with the key specified by |key_type| and
// |key_name|. The |callback| will be called when the operation completes.
// If the operation succeeds, the callback |result| parameter will be true.
// If |key_type| is KEY_USER, a |id| must be provided. Otherwise |id| is
// ignored.
virtual void TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
const std::string& payload,
DBusMethodCallback<bool> callback) = 0;
// Asynchronously gets the underlying TPM version information and passes it to
// the given callback.
virtual void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) = 0;
......
......@@ -471,41 +471,6 @@ void FakeCryptohomeClient::TpmAttestationSignSimpleChallenge(
ReturnAsyncMethodData(std::move(callback), signed_data.SerializeAsString());
}
void FakeCryptohomeClient::TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
DBusMethodCallback<TpmAttestationDataResult> callback) {
TpmAttestationDataResult result;
if (key_type == attestation::KEY_DEVICE) {
const auto it = device_key_payload_map_.find(key_name);
if (it != device_key_payload_map_.end()) {
result.success = true;
result.data = it->second;
}
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), std::move(result)));
}
void FakeCryptohomeClient::TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
const std::string& payload,
DBusMethodCallback<bool> callback) {
bool result = false;
// Currently only KEY_DEVICE case is supported just because there's no user
// for KEY_USER.
if (key_type == attestation::KEY_DEVICE) {
device_key_payload_map_[key_name] = payload;
result = true;
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), result));
}
void FakeCryptohomeClient::TpmGetVersion(
DBusMethodCallback<TpmVersionInfo> callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
......@@ -797,20 +762,6 @@ void FakeCryptohomeClient::SetTpmAttestationDeviceCertificate(
device_certificate_map_[key_name] = certificate;
}
void FakeCryptohomeClient::SetTpmAttestationDeviceKeyPayload(
const std::string& key_name,
const std::string& payload) {
device_key_payload_map_[key_name] = payload;
}
base::Optional<std::string>
FakeCryptohomeClient::GetTpmAttestationDeviceKeyPayload(
const std::string& key_name) const {
const auto it = device_key_payload_map_.find(key_name);
return it == device_key_payload_map_.end() ? base::nullopt
: base::make_optional(it->second);
}
void FakeCryptohomeClient::NotifyLowDiskSpace(uint64_t disk_free_bytes) {
for (auto& observer : observer_list_)
observer.LowDiskSpace(disk_free_bytes);
......
......@@ -154,17 +154,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
const std::string& key_name,
const std::string& challenge,
AsyncMethodCallback callback) override;
void TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
DBusMethodCallback<TpmAttestationDataResult> callback) override;
void TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
const std::string& payload,
DBusMethodCallback<bool> callback) override;
void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) override;
void GetKeyDataEx(
const cryptohome::AccountIdentifier& cryptohome_id,
......@@ -333,12 +322,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
void SetTpmAttestationDeviceCertificate(const std::string& key_name,
const std::string& certificate);
base::Optional<std::string> GetTpmAttestationDeviceKeyPayload(
const std::string& key_name) const;
void SetTpmAttestationDeviceKeyPayload(const std::string& key_name,
const std::string& payload);
// Calls TpmInitStatusUpdated() on Observer instances.
void NotifyTpmInitStatusUpdated(bool ready,
bool owned,
......@@ -462,9 +445,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
// Device attestation certificate mapped by key_name.
std::map<std::string, std::string> device_certificate_map_;
// Device key payload data mapped by key_name.
std::map<std::string, std::string> device_key_payload_map_;
base::RepeatingTimer dircrypto_migration_progress_timer_;
uint64_t dircrypto_migration_progress_ = 0;
......
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