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

remove legacy start/finish enroll/cert cryptohome APIs

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

BUG=b:158955123
TEST=build ok.

Change-Id: I2575821084d0ec431b92a2bc6d10f3ddcf640a18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517212
Commit-Queue: Leo Lai <cylai@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824283}
parent 2c026b73
......@@ -32,56 +32,6 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller,
CryptohomeClient::Get()->RemoveObserver(this);
}
void AsyncTpmAttestationCreateEnrollRequest(
chromeos::attestation::PrivacyCAType pca_type,
DataCallback callback) override {
CryptohomeClient::Get()->AsyncTpmAttestationCreateEnrollRequest(
pca_type,
base::BindOnce(&AsyncMethodCallerImpl::RegisterAsyncDataCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
"Couldn't initiate async attestation enroll request."));
}
void AsyncTpmAttestationEnroll(chromeos::attestation::PrivacyCAType pca_type,
const std::string& pca_response,
Callback callback) override {
CryptohomeClient::Get()->AsyncTpmAttestationEnroll(
pca_type, pca_response,
base::BindOnce(&AsyncMethodCallerImpl::RegisterAsyncCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
"Couldn't initiate async attestation enroll."));
}
void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
chromeos::attestation::AttestationCertificateProfile certificate_profile,
const Identification& cryptohome_id,
const std::string& request_origin,
DataCallback callback) override {
CryptohomeClient::Get()->AsyncTpmAttestationCreateCertRequest(
pca_type, certificate_profile,
CreateAccountIdentifierFromIdentification(cryptohome_id),
request_origin,
base::BindOnce(&AsyncMethodCallerImpl::RegisterAsyncDataCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
"Couldn't initiate async attestation cert request."));
}
void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
chromeos::attestation::AttestationKeyType key_type,
const Identification& cryptohome_id,
const std::string& key_name,
DataCallback callback) override {
CryptohomeClient::Get()->AsyncTpmAttestationFinishCertRequest(
pca_response, key_type,
CreateAccountIdentifierFromIdentification(cryptohome_id), key_name,
base::BindOnce(
&AsyncMethodCallerImpl::RegisterAsyncDataCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
"Couldn't initiate async attestation finish cert request."));
}
private:
struct CallbackElement {
CallbackElement() = default;
......
......@@ -15,8 +15,6 @@
namespace cryptohome {
class Identification;
// Note: This file is placed in ::cryptohome instead of ::chromeos::cryptohome
// since there is already a namespace ::cryptohome which holds the error code
// enum (MountError) and referencing ::chromeos::cryptohome and ::cryptohome
......@@ -34,50 +32,6 @@ class COMPONENT_EXPORT(CHROMEOS_CRYPTOHOME) AsyncMethodCaller {
virtual ~AsyncMethodCaller() {}
// Asks cryptohomed to asynchronously create an attestation enrollment
// request. On success the data sent to |callback| is a request to be sent
// to the Privacy CA of type |pca_type|.
virtual void AsyncTpmAttestationCreateEnrollRequest(
chromeos::attestation::PrivacyCAType pca_type,
DataCallback callback) = 0;
// Asks cryptohomed to asynchronously finish an attestation enrollment.
// |pca_response| is the response to the enrollment request emitted by the
// Privacy CA of type |pca_type|.
virtual void AsyncTpmAttestationEnroll(
chromeos::attestation::PrivacyCAType pca_type,
const std::string& pca_response,
Callback callback) = 0;
// Asks cryptohomed to asynchronously create an attestation certificate
// request according to |certificate_profile|. Some profiles require that the
// |user_id| of the currently active user and an identifier of the
// |request_origin| be provided. On success the data sent to |callback| is a
// request to be sent to the Privacy CA of type |pca_type|. The
// |request_origin| may be sent to the Privacy CA but the |user_id| will never
// be sent.
virtual void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
chromeos::attestation::AttestationCertificateProfile certificate_profile,
const Identification& user_id,
const std::string& request_origin,
DataCallback callback) = 0;
// Asks cryptohomed to asynchronously finish an attestation certificate
// request. On success the data sent to |callback| is a certificate chain
// in PEM format. |pca_response| is the response to the certificate request
// emitted by the Privacy CA. |key_type| determines whether the certified key
// is to be associated with the current user. |key_name| is a name for the
// key. If |key_type| is KEY_USER, a |user_id| must be provided. Otherwise
// |user_id| is ignored. For normal GAIA users the |user_id| is
// an AccountId-derived string (see AccountId::GetAccountIdKey).
virtual void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
chromeos::attestation::AttestationKeyType key_type,
const Identification& user_id,
const std::string& key_name,
DataCallback callback) = 0;
// Creates the global AsyncMethodCaller instance.
static void Initialize();
......
......@@ -10,9 +10,6 @@ using ::testing::_;
namespace cryptohome {
const char MockAsyncMethodCaller::kFakeAttestationEnrollRequest[] = "enrollreq";
const char MockAsyncMethodCaller::kFakeAttestationCertRequest[] = "certreq";
const char MockAsyncMethodCaller::kFakeAttestationCert[] = "cert";
const char MockAsyncMethodCaller::kFakeSanitizedUsername[] = "01234567890ABC";
const char MockAsyncMethodCaller::kFakeChallengeResponse[] =
"challenge_response";
......@@ -26,37 +23,6 @@ MockAsyncMethodCaller::~MockAsyncMethodCaller() = default;
void MockAsyncMethodCaller::SetUp(bool success, MountError return_code) {
success_ = success;
return_code_ = return_code;
ON_CALL(*this, AsyncTpmAttestationCreateEnrollRequest(_, _))
.WillByDefault(
WithArgs<1>(Invoke(this,
&MockAsyncMethodCaller::FakeCreateEnrollRequest)));
ON_CALL(*this, AsyncTpmAttestationEnroll(_, _, _))
.WillByDefault(
WithArgs<2>(Invoke(this, &MockAsyncMethodCaller::DoCallback)));
ON_CALL(*this, AsyncTpmAttestationCreateCertRequest(_, _, _, _, _))
.WillByDefault(
WithArgs<4>(Invoke(this,
&MockAsyncMethodCaller::FakeCreateCertRequest)));
ON_CALL(*this, AsyncTpmAttestationFinishCertRequest(_, _, _, _, _))
.WillByDefault(
WithArgs<4>(Invoke(this,
&MockAsyncMethodCaller::FakeFinishCertRequest)));
}
void MockAsyncMethodCaller::DoCallback(Callback callback) {
std::move(callback).Run(success_, return_code_);
}
void MockAsyncMethodCaller::FakeCreateEnrollRequest(DataCallback callback) {
std::move(callback).Run(success_, kFakeAttestationEnrollRequest);
}
void MockAsyncMethodCaller::FakeCreateCertRequest(DataCallback callback) {
std::move(callback).Run(success_, kFakeAttestationCertRequest);
}
void MockAsyncMethodCaller::FakeFinishCertRequest(DataCallback callback) {
std::move(callback).Run(success_, kFakeAttestationCert);
}
void MockAsyncMethodCaller::FakeGetSanitizedUsername(DataCallback callback) {
......
......@@ -53,11 +53,6 @@ class MockAsyncMethodCaller : public AsyncMethodCaller {
bool success_;
MountError return_code_;
void DoCallback(Callback callback);
// Default fakes for attestation calls.
void FakeCreateEnrollRequest(DataCallback callback);
void FakeCreateCertRequest(DataCallback callback);
void FakeFinishCertRequest(DataCallback callback);
void FakeGetSanitizedUsername(DataCallback callback);
void FakeEnterpriseChallenge(DataCallback callback);
......
......@@ -461,84 +461,6 @@ class CryptohomeClientImpl : public CryptohomeClient {
return CallBoolMethodAndBlock(&method_call, is_first_install);
}
// CryptohomeClient override.
void AsyncTpmAttestationCreateEnrollRequest(
attestation::PrivacyCAType pca_type,
AsyncMethodCallback callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncTpmAttestationCreateEnrollRequest);
dbus::MessageWriter writer(&method_call);
writer.AppendInt32(pca_type);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void AsyncTpmAttestationEnroll(attestation::PrivacyCAType pca_type,
const std::string& pca_response,
AsyncMethodCallback callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncTpmAttestationEnroll);
dbus::MessageWriter writer(&method_call);
writer.AppendInt32(pca_type);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(pca_response.data()),
pca_response.size());
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void AsyncTpmAttestationCreateCertRequest(
attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
const cryptohome::AccountIdentifier& id,
const std::string& request_origin,
AsyncMethodCallback callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncTpmAttestationCreateCertRequest);
dbus::MessageWriter writer(&method_call);
writer.AppendInt32(pca_type);
writer.AppendInt32(certificate_profile);
writer.AppendString(id.account_id());
writer.AppendString(request_origin);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
AsyncMethodCallback callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncTpmAttestationFinishCertRequest);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(pca_response.data()),
pca_response.size());
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::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
// CryptohomeClient override.
void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) override {
dbus::MethodCall method_call(
......
......@@ -316,57 +316,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient {
// succeeds. This method blocks until the call returns.
virtual bool InstallAttributesIsFirstInstall(bool* is_first_install) = 0;
// Asynchronously creates an attestation enrollment request. The callback
// will be called when the dbus call completes. When the operation completes,
// the AsyncCallStatusWithDataHandler signal handler is called. The data that
// is sent with the signal is an enrollment request to be sent to the Privacy
// CA of type |pca_type|. The enrollment is completed by calling
// AsyncTpmAttestationEnroll.
virtual void AsyncTpmAttestationCreateEnrollRequest(
chromeos::attestation::PrivacyCAType pca_type,
AsyncMethodCallback callback) = 0;
// Asynchronously finishes an attestation enrollment operation. The callback
// will be called when the dbus call completes. When the operation completes,
// the AsyncCallStatusHandler signal handler is called. |pca_response| is the
// response to the enrollment request emitted by the Privacy CA of type
// |pca_type|.
virtual void AsyncTpmAttestationEnroll(
chromeos::attestation::PrivacyCAType pca_type,
const std::string& pca_response,
AsyncMethodCallback callback) = 0;
// Asynchronously creates an attestation certificate request according to
// |certificate_profile|. Some profiles require that the |id| of
// the currently active user and an identifier of the |request_origin| be
// provided. |callback| will be called when the dbus call completes. When
// the operation completes, the AsyncCallStatusWithDataHandler signal handler
// is called. The data that is sent with the signal is a certificate request
// to be sent to the Privacy CA of type |pca_type|. The certificate request
// is completed by calling AsyncTpmAttestationFinishCertRequest. The
// |id| will not be included in the certificate request for the Privacy CA.
virtual void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
const cryptohome::AccountIdentifier& id,
const std::string& request_origin,
AsyncMethodCallback callback) = 0;
// Asynchronously finishes a certificate request operation. The callback will
// be called when the dbus call completes. When the operation completes, the
// AsyncCallStatusWithDataHandler signal handler is called. The data that is
// sent with the signal is a certificate chain in PEM format. |pca_response|
// is the response to the certificate request emitted by the Privacy CA.
// |key_type| determines whether the certified key is to be associated with
// the current user. |key_name| is a name for the key. If |key_type| is
// KEY_USER, a |id| must be provided. Otherwise |id| is ignored.
virtual void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& id,
const std::string& key_name,
AsyncMethodCallback callback) = 0;
// Asynchronously gets the underlying TPM version information and passes it to
// the given callback.
virtual void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) = 0;
......
......@@ -325,37 +325,6 @@ bool FakeCryptohomeClient::InstallAttributesIsFirstInstall(
return true;
}
void FakeCryptohomeClient::AsyncTpmAttestationCreateEnrollRequest(
chromeos::attestation::PrivacyCAType pca_type,
AsyncMethodCallback callback) {
ReturnAsyncMethodData(std::move(callback), std::string());
}
void FakeCryptohomeClient::AsyncTpmAttestationEnroll(
chromeos::attestation::PrivacyCAType pca_type,
const std::string& pca_response,
AsyncMethodCallback callback) {
ReturnAsyncMethodResult(std::move(callback));
}
void FakeCryptohomeClient::AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& request_origin,
AsyncMethodCallback callback) {
ReturnAsyncMethodData(std::move(callback), std::string());
}
void FakeCryptohomeClient::AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
AsyncMethodCallback callback) {
ReturnAsyncMethodData(std::move(callback), std::string());
}
void FakeCryptohomeClient::TpmGetVersion(
DBusMethodCallback<TpmVersionInfo> callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
......
......@@ -100,24 +100,6 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
void InstallAttributesIsReady(DBusMethodCallback<bool> callback) override;
bool InstallAttributesIsInvalid(bool* is_invalid) override;
bool InstallAttributesIsFirstInstall(bool* is_first_install) override;
void AsyncTpmAttestationCreateEnrollRequest(
chromeos::attestation::PrivacyCAType pca_type,
AsyncMethodCallback callback) override;
void AsyncTpmAttestationEnroll(chromeos::attestation::PrivacyCAType pca_type,
const std::string& pca_response,
AsyncMethodCallback callback) override;
void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& request_origin,
AsyncMethodCallback callback) override;
void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
const cryptohome::AccountIdentifier& cryptohome_id,
const std::string& key_name,
AsyncMethodCallback callback) override;
void TpmGetVersion(DBusMethodCallback<TpmVersionInfo> callback) override;
void GetKeyDataEx(
const cryptohome::AccountIdentifier& cryptohome_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