#include "components/enterprise/client_certificates/core/key_upload_client.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "components/enterprise/client_certificates/core/cloud_management_delegate.h"
#include "components/enterprise/client_certificates/core/private_key.h"
#include "components/enterprise/client_certificates/core/private_key_types.h"
#include "components/policy/core/common/cloud/dmserver_job_configurations.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "crypto/signature_verifier.h"
#include "net/cert/x509_certificate.h"
BPKUR;
namespace client_certificates {
namespace {
BPKUR::KeyTrustLevel SourceToTrustLevel(PrivateKeySource source) { … }
BPKUR::KeyType AlgorithmToType(
crypto::SignatureVerifier::SignatureAlgorithm algorithm) { … }
UploadClientErrorOr<enterprise_management::DeviceManagementRequest>
CreateRequest(scoped_refptr<PrivateKey> private_key, bool create_certificate) { … }
}
class KeyUploadClientImpl : public KeyUploadClient { … };
std::unique_ptr<KeyUploadClient> KeyUploadClient::Create(
std::unique_ptr<enterprise_attestation::CloudManagementDelegate>
management_delegate) { … }
KeyUploadClientImpl::KeyUploadClientImpl(
std::unique_ptr<enterprise_attestation::CloudManagementDelegate>
management_delegate)
: … { … }
KeyUploadClientImpl::~KeyUploadClientImpl() = default;
void KeyUploadClientImpl::CreateCertificate(
scoped_refptr<PrivateKey> private_key,
CreateCertificateCallback callback) { … }
void KeyUploadClientImpl::SyncKey(scoped_refptr<PrivateKey> private_key,
SyncKeyCallback callback) { … }
void KeyUploadClientImpl::GetRequest(
scoped_refptr<PrivateKey> private_key,
bool create_certificate,
base::OnceCallback<void(
UploadClientErrorOr<enterprise_management::DeviceManagementRequest>)>
callback) { … }
void KeyUploadClientImpl::OnCertificateRequestCreated(
CreateCertificateCallback callback,
UploadClientErrorOr<enterprise_management::DeviceManagementRequest>
request) { … }
void KeyUploadClientImpl::OnCertificateResponseReceived(
CreateCertificateCallback callback,
policy::DMServerJobResult result) { … }
void KeyUploadClientImpl::OnSyncRequestCreated(
SyncKeyCallback callback,
UploadClientErrorOr<enterprise_management::DeviceManagementRequest>
request) { … }
void KeyUploadClientImpl::OnSyncResponseReceived(
SyncKeyCallback callback,
policy::DMServerJobResult result) { … }
}