#include "device/fido/enclave/enclave_authenticator.h"
#include <algorithm>
#include <iterator>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "components/cbor/values.h"
#include "components/device_event_log/device_event_log.h"
#include "components/sync/protocol/webauthn_credential_specifics.pb.h"
#include "crypto/random.h"
#include "device/fido/discoverable_credential_metadata.h"
#include "device/fido/enclave/constants.h"
#include "device/fido/enclave/metrics.h"
#include "device/fido/enclave/transact.h"
#include "device/fido/enclave/types.h"
#include "device/fido/fido_parsing_utils.h"
#include "device/fido/public_key_credential_descriptor.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace device::enclave {
namespace {
AuthenticatorSupportedOptions EnclaveAuthenticatorOptions() { … }
std::array<uint8_t, 8> RandomId() { … }
enum { … };
GetAssertionStatus EnclaveErrorToGetAssertionStatus(int enclave_code) { … }
MakeCredentialStatus EnclaveErrorToMakeCredentialStatus(int enclave_code) { … }
}
EnclaveAuthenticator::PendingGetAssertionRequest::PendingGetAssertionRequest(
CtapGetAssertionRequest in_request,
CtapGetAssertionOptions in_options,
GetAssertionCallback in_callback)
: … { … }
EnclaveAuthenticator::PendingGetAssertionRequest::
~PendingGetAssertionRequest() = default;
EnclaveAuthenticator::PendingMakeCredentialRequest::
PendingMakeCredentialRequest(CtapMakeCredentialRequest in_request,
MakeCredentialOptions in_options,
MakeCredentialCallback in_callback)
: … { … }
EnclaveAuthenticator::PendingMakeCredentialRequest::
~PendingMakeCredentialRequest() = default;
EnclaveAuthenticator::EnclaveAuthenticator(
std::unique_ptr<CredentialRequest> ui_request,
NetworkContextFactory network_context_factory)
: … { … }
EnclaveAuthenticator::~EnclaveAuthenticator() = default;
void EnclaveAuthenticator::InitializeAuthenticator(base::OnceClosure callback) { … }
void EnclaveAuthenticator::MakeCredential(CtapMakeCredentialRequest request,
MakeCredentialOptions options,
MakeCredentialCallback callback) { … }
void EnclaveAuthenticator::DispatchMakeCredentialWithNewUVKey(
base::span<const uint8_t> uv_public_key) { … }
void EnclaveAuthenticator::GetAssertion(CtapGetAssertionRequest request,
CtapGetAssertionOptions options,
GetAssertionCallback callback) { … }
void EnclaveAuthenticator::DispatchGetAssertionWithNewUVKey(
base::span<const uint8_t> uv_public_key) { … }
void EnclaveAuthenticator::ProcessMakeCredentialResponse(
std::optional<cbor::Value> response) { … }
void EnclaveAuthenticator::ProcessGetAssertionResponse(
std::optional<cbor::Value> response) { … }
void EnclaveAuthenticator::CompleteRequestWithError(
absl::variant<GetAssertionStatus, MakeCredentialStatus> error) { … }
void EnclaveAuthenticator::CompleteMakeCredentialRequest(
MakeCredentialStatus status,
std::optional<AuthenticatorMakeCredentialResponse> response) { … }
void EnclaveAuthenticator::CompleteGetAssertionRequest(
GetAssertionStatus status,
std::vector<AuthenticatorGetAssertionResponse> responses) { … }
void EnclaveAuthenticator::ProcessErrorResponse(const ErrorResponse& error) { … }
void EnclaveAuthenticator::Cancel() { … }
AuthenticatorType EnclaveAuthenticator::GetType() const { … }
std::string EnclaveAuthenticator::GetId() const { … }
const AuthenticatorSupportedOptions& EnclaveAuthenticator::Options() const { … }
std::optional<FidoTransportProtocol>
EnclaveAuthenticator::AuthenticatorTransport() const { … }
base::WeakPtr<FidoAuthenticator> EnclaveAuthenticator::GetWeakPtr() { … }
}