#include "components/unexportable_keys/unexportable_key_service_impl.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/types/expected.h"
#include "components/unexportable_keys/service_error.h"
#include "components/unexportable_keys/unexportable_key_id.h"
#include "components/unexportable_keys/unexportable_key_task_manager.h"
#include "crypto/unexportable_key.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace unexportable_keys {
namespace {
class MaybePendingUnexportableKeyId { … };
MaybePendingUnexportableKeyId::MaybePendingUnexportableKeyId() = default;
MaybePendingUnexportableKeyId::MaybePendingUnexportableKeyId(
UnexportableKeyId key_id)
: … { … }
MaybePendingUnexportableKeyId::~MaybePendingUnexportableKeyId() = default;
bool MaybePendingUnexportableKeyId::HasKeyId() { … }
UnexportableKeyId MaybePendingUnexportableKeyId::GetKeyId() { … }
void MaybePendingUnexportableKeyId::AddCallback(CallbackType callback) { … }
void MaybePendingUnexportableKeyId::SetKeyIdAndRunCallbacks(
UnexportableKeyId key_id) { … }
void MaybePendingUnexportableKeyId::RunCallbacksWithFailure(
ServiceError error) { … }
std::vector<MaybePendingUnexportableKeyId::CallbackType>&
MaybePendingUnexportableKeyId::GetCallbacks() { … }
}
UnexportableKeyServiceImpl::UnexportableKeyServiceImpl(
UnexportableKeyTaskManager& task_manager)
: … { … }
UnexportableKeyServiceImpl::~UnexportableKeyServiceImpl() = default;
bool UnexportableKeyServiceImpl::IsUnexportableKeyProviderSupported(
crypto::UnexportableKeyProvider::Config config) { … }
void UnexportableKeyServiceImpl::GenerateSigningKeySlowlyAsync(
base::span<const crypto::SignatureVerifier::SignatureAlgorithm>
acceptable_algorithms,
BackgroundTaskPriority priority,
base::OnceCallback<void(ServiceErrorOr<UnexportableKeyId>)> callback) { … }
void UnexportableKeyServiceImpl::FromWrappedSigningKeySlowlyAsync(
base::span<const uint8_t> wrapped_key,
BackgroundTaskPriority priority,
base::OnceCallback<void(ServiceErrorOr<UnexportableKeyId>)> callback) { … }
void UnexportableKeyServiceImpl::SignSlowlyAsync(
const UnexportableKeyId& key_id,
base::span<const uint8_t> data,
BackgroundTaskPriority priority,
base::OnceCallback<void(ServiceErrorOr<std::vector<uint8_t>>)> callback) { … }
ServiceErrorOr<std::vector<uint8_t>>
UnexportableKeyServiceImpl::GetSubjectPublicKeyInfo(
UnexportableKeyId key_id) const { … }
ServiceErrorOr<std::vector<uint8_t>> UnexportableKeyServiceImpl::GetWrappedKey(
UnexportableKeyId key_id) const { … }
ServiceErrorOr<crypto::SignatureVerifier::SignatureAlgorithm>
UnexportableKeyServiceImpl::GetAlgorithm(UnexportableKeyId key_id) const { … }
void UnexportableKeyServiceImpl::OnKeyGenerated(
base::OnceCallback<void(ServiceErrorOr<UnexportableKeyId>)> client_callback,
ServiceErrorOr<scoped_refptr<RefCountedUnexportableSigningKey>>
key_or_error) { … }
void UnexportableKeyServiceImpl::OnKeyCreatedFromWrappedKey(
WrappedKeyMap::iterator pending_entry_it,
ServiceErrorOr<scoped_refptr<RefCountedUnexportableSigningKey>>
key_or_error) { … }
}