Commit 501c2a63 authored by Yicheng Li's avatar Yicheng Li Committed by Commit Bot

chromeos: Enable fingerprint auth sessions for ExtendedAuthenticator

Cryptohome already supports starting/ending fingerprint auth session
(i.e. preparing biometrics daemon for upcoming fingerprint scan / back
to normal mode).

This change enables ExtendedAuthenticator to start fingerprint auth
session so that ExtendedAuthenticator can be used to do fingerprint
auth.

The reason why fingerprint auth needs starting/ending auth session is
because it is expensive to switch mode of the fingerprint MCU. The
client should only end fingerprint auth session when no more fingerprint
retries are expected.

The reason why we are doing this by calling cryptohome, instead of
calling biometrics daemon, is that we want cryptohome to control all
authentication mechanisms, and there's a generalized "auth session"
project in cryptohome.

Bug: b:156258540, b:144861739
Change-Id: I767b2aff9791c838674d8ace8ab8d4494f69e603
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364894
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800758}
parent e53a2144
...@@ -945,6 +945,38 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -945,6 +945,38 @@ class CryptohomeClientImpl : public CryptohomeClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void StartFingerprintAuthSession(
const cryptohome::AccountIdentifier& id,
const cryptohome::StartFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeStartFingerprintAuthSession);
dbus::MessageWriter writer(&method_call);
writer.AppendProtoAsArrayOfBytes(id);
writer.AppendProtoAsArrayOfBytes(request);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnBaseReplyMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void EndFingerprintAuthSession(
const cryptohome::EndFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeEndFingerprintAuthSession);
dbus::MessageWriter writer(&method_call);
writer.AppendProtoAsArrayOfBytes(request);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnBaseReplyMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void GetBootAttribute( void GetBootAttribute(
const cryptohome::GetBootAttributeRequest& request, const cryptohome::GetBootAttributeRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override { DBusMethodCallback<cryptohome::BaseReply> callback) override {
......
...@@ -25,6 +25,7 @@ class AuthorizationRequest; ...@@ -25,6 +25,7 @@ class AuthorizationRequest;
class BaseReply; class BaseReply;
class CheckHealthRequest; class CheckHealthRequest;
class CheckKeyRequest; class CheckKeyRequest;
class EndFingerprintAuthSessionRequest;
class FlushAndSignBootAttributesRequest; class FlushAndSignBootAttributesRequest;
class GetBootAttributeRequest; class GetBootAttributeRequest;
class GetKeyDataRequest; class GetKeyDataRequest;
...@@ -40,6 +41,7 @@ class RemoveFirmwareManagementParametersRequest; ...@@ -40,6 +41,7 @@ class RemoveFirmwareManagementParametersRequest;
class RemoveKeyRequest; class RemoveKeyRequest;
class SetBootAttributeRequest; class SetBootAttributeRequest;
class SetFirmwareManagementParametersRequest; class SetFirmwareManagementParametersRequest;
class StartFingerprintAuthSessionRequest;
class UnmountRequest; class UnmountRequest;
class UpdateKeyRequest; class UpdateKeyRequest;
...@@ -595,6 +597,23 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient { ...@@ -595,6 +597,23 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient {
const cryptohome::MassRemoveKeysRequest& request, const cryptohome::MassRemoveKeysRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) = 0; DBusMethodCallback<cryptohome::BaseReply> callback) = 0;
// Asynchronously calls StartFingerprintAuthSession method. |callback| is
// called after method call, and with reply protobuf.
// StartFingerprintAuthSession prepares biometrics daemon for upcoming
// fingerprint authentication.
virtual void StartFingerprintAuthSession(
const cryptohome::AccountIdentifier& id,
const cryptohome::StartFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) = 0;
// Asynchronously calls EndFingerprintAuthSession method. |callback| is
// called after method call, and with reply protobuf.
// EndFingerprintAuthSession sets biometrics daemon back to normal mode.
// If there is a reply, it is always an empty reply with no errors.
virtual void EndFingerprintAuthSession(
const cryptohome::EndFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) = 0;
// Asynchronously calls GetBootAttribute method. |callback| is called after // Asynchronously calls GetBootAttribute method. |callback| is called after
// method call, and with reply protobuf. // method call, and with reply protobuf.
// GetBootAttribute gets the value of the specified boot attribute. // GetBootAttribute gets the value of the specified boot attribute.
......
...@@ -790,6 +790,19 @@ void FakeCryptohomeClient::CheckHealth( ...@@ -790,6 +790,19 @@ void FakeCryptohomeClient::CheckHealth(
ReturnProtobufMethodCallback(reply, std::move(callback)); ReturnProtobufMethodCallback(reply, std::move(callback));
} }
void FakeCryptohomeClient::StartFingerprintAuthSession(
const cryptohome::AccountIdentifier& id,
const cryptohome::StartFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) {
ReturnProtobufMethodCallback(cryptohome::BaseReply(), std::move(callback));
}
void FakeCryptohomeClient::EndFingerprintAuthSession(
const cryptohome::EndFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) {
ReturnProtobufMethodCallback(cryptohome::BaseReply(), std::move(callback));
}
void FakeCryptohomeClient::SetServiceIsAvailable(bool is_available) { void FakeCryptohomeClient::SetServiceIsAvailable(bool is_available) {
service_is_available_ = is_available; service_is_available_ = is_available;
if (!is_available) if (!is_available)
......
...@@ -251,6 +251,13 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient ...@@ -251,6 +251,13 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
DBusMethodCallback<int64_t> callback) override; DBusMethodCallback<int64_t> callback) override;
void CheckHealth(const cryptohome::CheckHealthRequest& request, void CheckHealth(const cryptohome::CheckHealthRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override; DBusMethodCallback<cryptohome::BaseReply> callback) override;
void StartFingerprintAuthSession(
const cryptohome::AccountIdentifier& id,
const cryptohome::StartFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override;
void EndFingerprintAuthSession(
const cryptohome::EndFingerprintAuthSessionRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override;
/////////// Test helpers //////////// /////////// Test helpers ////////////
......
...@@ -68,6 +68,18 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticator ...@@ -68,6 +68,18 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticator
virtual void AuthenticateToCheck(const UserContext& context, virtual void AuthenticateToCheck(const UserContext& context,
base::OnceClosure success_callback) = 0; base::OnceClosure success_callback) = 0;
// Attempts to start fingerprint auth session (prepare biometrics daemon for
// upcoming fingerprint scan) for the user with |account_id|. |callback| will
// be invoked with whether the fingerprint auth session is successfully
// started.
virtual void StartFingerprintAuthSession(
const AccountId& account_id,
base::OnceCallback<void(bool)> callback) = 0;
// Attempts to end the current fingerprint auth session. Logs an error if no
// response.
virtual void EndFingerprintAuthSession() = 0;
// Attempts to add a new |key| for the user identified/authorized by // Attempts to add a new |key| for the user identified/authorized by
// |context|. If a key with the same label already exists, the behavior // |context|. If a key with the same label already exists, the behavior
// depends on the |replace_existing| flag. If the flag is set, the old key is // depends on the |replace_existing| flag. If the flag is set, the old key is
......
...@@ -94,6 +94,34 @@ void ExtendedAuthenticatorImpl::AuthenticateToCheck( ...@@ -94,6 +94,34 @@ void ExtendedAuthenticatorImpl::AuthenticateToCheck(
this, std::move(success_callback))); this, std::move(success_callback)));
} }
void ExtendedAuthenticatorImpl::StartFingerprintAuthSession(
const AccountId& account_id,
base::OnceCallback<void(bool)> callback) {
CryptohomeClient::Get()->StartFingerprintAuthSession(
cryptohome::CreateAccountIdentifierFromAccountId(account_id),
cryptohome::StartFingerprintAuthSessionRequest(),
base::BindOnce(
&ExtendedAuthenticatorImpl::OnStartFingerprintAuthSessionComplete,
this, std::move(callback)));
}
void ExtendedAuthenticatorImpl::OnStartFingerprintAuthSessionComplete(
base::OnceCallback<void(bool)> callback,
base::Optional<cryptohome::BaseReply> reply) {
std::move(callback).Run(reply && !reply->has_error());
}
void ExtendedAuthenticatorImpl::EndFingerprintAuthSession() {
CryptohomeClient::Get()->EndFingerprintAuthSession(
cryptohome::EndFingerprintAuthSessionRequest(),
base::BindOnce([](base::Optional<cryptohome::BaseReply> reply) {
// Only check for existence of the reply, because if there is a reply,
// it's always a BaseReply without errors.
if (!reply)
LOG(ERROR) << "EndFingerprintAuthSession call had no reply.";
}));
}
void ExtendedAuthenticatorImpl::AddKey(const UserContext& context, void ExtendedAuthenticatorImpl::AddKey(const UserContext& context,
const cryptohome::KeyDefinition& key, const cryptohome::KeyDefinition& key,
bool clobber_if_exists, bool clobber_if_exists,
......
...@@ -37,6 +37,10 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl ...@@ -37,6 +37,10 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl
ResultCallback success_callback) override; ResultCallback success_callback) override;
void AuthenticateToCheck(const UserContext& context, void AuthenticateToCheck(const UserContext& context,
base::OnceClosure success_callback) override; base::OnceClosure success_callback) override;
void StartFingerprintAuthSession(
const AccountId& account_id,
base::OnceCallback<void(bool)> callback) override;
void EndFingerprintAuthSession() override;
void AddKey(const UserContext& context, void AddKey(const UserContext& context,
const cryptohome::KeyDefinition& key, const cryptohome::KeyDefinition& key,
bool clobber_if_exists, bool clobber_if_exists,
...@@ -86,6 +90,9 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl ...@@ -86,6 +90,9 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl
base::OnceClosure success_callback, base::OnceClosure success_callback,
bool success, bool success,
cryptohome::MountError return_code); cryptohome::MountError return_code);
void OnStartFingerprintAuthSessionComplete(
base::OnceCallback<void(bool)> callback,
base::Optional<cryptohome::BaseReply> reply);
bool salt_obtained_; bool salt_obtained_;
std::string system_salt_; std::string system_salt_;
......
...@@ -64,6 +64,14 @@ void FakeExtendedAuthenticator::AuthenticateToCheck( ...@@ -64,6 +64,14 @@ void FakeExtendedAuthenticator::AuthenticateToCheck(
AuthFailure(AuthFailure::UNLOCK_FAILED)); AuthFailure(AuthFailure::UNLOCK_FAILED));
} }
void FakeExtendedAuthenticator::StartFingerprintAuthSession(
const AccountId& account_id,
base::OnceCallback<void(bool)> callback) {
std::move(callback).Run(expected_user_context_.GetAccountId() == account_id);
}
void FakeExtendedAuthenticator::EndFingerprintAuthSession() {}
void FakeExtendedAuthenticator::AddKey(const UserContext& context, void FakeExtendedAuthenticator::AddKey(const UserContext& context,
const cryptohome::KeyDefinition& key, const cryptohome::KeyDefinition& key,
bool replace_existing, bool replace_existing,
......
...@@ -28,6 +28,10 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) FakeExtendedAuthenticator ...@@ -28,6 +28,10 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) FakeExtendedAuthenticator
ResultCallback success_callback) override; ResultCallback success_callback) override;
void AuthenticateToCheck(const UserContext& context, void AuthenticateToCheck(const UserContext& context,
base::OnceClosure success_callback) override; base::OnceClosure success_callback) override;
void StartFingerprintAuthSession(
const AccountId& account_id,
base::OnceCallback<void(bool)> callback) override;
void EndFingerprintAuthSession() override;
void AddKey(const UserContext& context, void AddKey(const UserContext& context,
const cryptohome::KeyDefinition& key, const cryptohome::KeyDefinition& key,
bool replace_existing, bool replace_existing,
......
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