#include "chrome/browser/ui/webui/connectors_internals/device_trust_utils.h"
#include "build/build_config.h"
#include "components/enterprise/buildflags/buildflags.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#include "base/base64url.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h"
#include "components/enterprise/browser/device_trust/device_trust_key_manager.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "crypto/sha2.h"
#include "crypto/signature_verifier.h"
BPKUR;
#endif
#if BUILDFLAG(IS_MAC)
#include "chrome/common/channel_info.h"
#include "components/version_info/channel.h"
#endif
#if BUILDFLAG(ENTERPRISE_CLIENT_CERTIFICATES)
#include "base/i18n/time_formatting.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/enterprise/client_certificates/core/private_key.h"
#include "components/enterprise/client_certificates/core/private_key_types.h"
#include "net/cert/x509_certificate.h"
#endif
namespace enterprise_connectors::utils {
namespace {
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
connectors_internals::mojom::KeyTrustLevel ParseTrustLevel(
BPKUR::KeyTrustLevel trust_level) { … }
connectors_internals::mojom::KeyType AlgorithmToType(
crypto::SignatureVerifier::SignatureAlgorithm algorithm) { … }
connectors_internals::mojom::KeyManagerPermanentFailure ConvertPermanentFailure(
std::optional<DeviceTrustKeyManager::PermanentFailure> permanent_failure) { … }
std::string HashAndEncodeString(const std::string& spki_bytes) { … }
connectors_internals::mojom::Int32ValuePtr ToMojomValue(
std::optional<int> integer_value) { … }
#endif
#if BUILDFLAG(ENTERPRISE_CLIENT_CERTIFICATES)
std::string BufferToString(base::span<const uint8_t> buffer) { … }
connectors_internals::mojom::KeyTrustLevel ConvertPrivateKeySource(
client_certificates::PrivateKeySource source) { … }
connectors_internals::mojom::LoadedKeyInfoPtr ConvertPrivateKey(
scoped_refptr<client_certificates::PrivateKey> private_key,
const std::optional<client_certificates::HttpCodeOrClientError>&
key_upload_code) { … }
connectors_internals::mojom::CertificateMetadataPtr ConvertCertificate(
scoped_refptr<net::X509Certificate> certificate) { … }
#endif
}
connectors_internals::mojom::KeyInfoPtr GetKeyInfo() { … }
bool CanDeleteDeviceTrustKey() { … }
#if BUILDFLAG(ENTERPRISE_CLIENT_CERTIFICATES)
connectors_internals::mojom::ClientIdentityPtr ConvertIdentity(
const client_certificates::ClientIdentity& identity,
const std::optional<client_certificates::HttpCodeOrClientError>&
key_upload_code) { … }
#endif
}