Replace lexical Rust fragments with real modules
This commit is contained in:
parent
f8849cdb5f
commit
247819250b
1 changed files with 3302 additions and 2671 deletions
|
|
@ -1,3 +1,20 @@
|
|||
use super::{
|
||||
AcceptedControlConnection, Arc, AsFd, AsRawFd, CONTROL_ALPN, CONTROL_SOCKET_NAME,
|
||||
CertificateDigest, CertificateParams, ClientConfig, ClientConnection, ClientEnrollmentResponse,
|
||||
ClientId, ConfinedPathPlan, ControlClient, ControlError, ControlPaths, ControlRequest,
|
||||
ControlResponse, ControlSessionAdmission, Digest, DistinguishedName, DnType, Duration,
|
||||
ExecutionUnavailable, ExtendedKeyUsagePurpose, File, FileExt, FileIdentity, FileTypeExt,
|
||||
GenerationIdentity, HostCoordinatorDomainStore, InteractiveSessionBatch,
|
||||
InteractiveSessionEvent, InteractiveSessionExecutor, InteractiveSessionMessage, IsCa,
|
||||
KeyUsagePurpose, MAX_CONTROL_BYTES, MAX_ENROLLMENT_BYTES, MetadataExt, Mode,
|
||||
NonInteractiveSessionExecutor, NonInteractiveSessionMessage, OFlags, OffsetDateTime,
|
||||
PUBLICATION_IDENTITY_NAME, Path, PathBuf, PrivateKeyDer, ProtocolPublicationIdentity,
|
||||
ProtocolVersion, PublicationOwnership, PublishedControlFace, Read, ServerConnection,
|
||||
SessionBinding, SessionId, SessionPhase, SessionRegistrationResponse, SessionRegistry, Sha256,
|
||||
SigningKey, StagedControlFace, TlsCredential, TrustAnchor, Write, decode, encode, fmt, io,
|
||||
issue_session_capability, openat, publication_recovery_ownership, socket_peercred,
|
||||
};
|
||||
|
||||
impl PublishedControlFace {
|
||||
pub(crate) fn recovery_ownership(&self) -> Result<PublicationOwnership, ControlError> {
|
||||
publication_recovery_ownership(&self.paths)
|
||||
|
|
@ -511,9 +528,7 @@ impl PublishedControlFace {
|
|||
/// # Errors
|
||||
/// Returns framing, size, decoding, or TLS I/O failures.
|
||||
pub fn receive<
|
||||
Response: lazaret_core::records::SchemaType
|
||||
+ serde::de::DeserializeOwned
|
||||
+ serde::Serialize,
|
||||
Response: lazaret_core::records::SchemaType + serde::de::DeserializeOwned + serde::Serialize,
|
||||
>(
|
||||
stream: &mut impl Read,
|
||||
) -> Result<Response, ControlError> {
|
||||
|
|
@ -552,7 +567,7 @@ fn remove_exact_if_identity_matches(
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_if_identity_matches(path: &Path, expected: FileIdentity) {
|
||||
pub(super) fn remove_if_identity_matches(path: &Path, expected: FileIdentity) {
|
||||
if std::fs::symlink_metadata(path)
|
||||
.ok()
|
||||
.is_some_and(|metadata| FileIdentity::from_metadata(&metadata) == expected)
|
||||
|
|
@ -632,7 +647,7 @@ fn require_interactive_batch(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn leaf_parameters(
|
||||
pub(super) fn leaf_parameters(
|
||||
common_name: &str,
|
||||
usage: ExtendedKeyUsagePurpose,
|
||||
now: OffsetDateTime,
|
||||
|
|
@ -650,13 +665,13 @@ fn leaf_parameters(
|
|||
Ok(params)
|
||||
}
|
||||
|
||||
fn random_signing_key() -> Result<SigningKey, ControlError> {
|
||||
pub(super) fn random_signing_key() -> Result<SigningKey, ControlError> {
|
||||
let mut bytes = [0_u8; 32];
|
||||
getrandom::fill(&mut bytes).map_err(|_| ControlError::InvalidCertificateProfile)?;
|
||||
Ok(SigningKey::from_bytes(&bytes))
|
||||
}
|
||||
|
||||
fn enrollment_binding(
|
||||
pub(super) fn enrollment_binding(
|
||||
generation_identity: &GenerationIdentity,
|
||||
cli_id: ClientId,
|
||||
) -> Result<String, ControlError> {
|
||||
|
|
@ -664,15 +679,15 @@ fn enrollment_binding(
|
|||
.map_err(ControlError::from)
|
||||
}
|
||||
|
||||
fn certificate_digest(certificate: impl AsRef<[u8]>) -> CertificateDigest {
|
||||
pub(super) fn certificate_digest(certificate: impl AsRef<[u8]>) -> CertificateDigest {
|
||||
CertificateDigest::new(sha256(certificate.as_ref()))
|
||||
}
|
||||
|
||||
fn sha256(bytes: &[u8]) -> [u8; 32] {
|
||||
pub(super) fn sha256(bytes: &[u8]) -> [u8; 32] {
|
||||
Sha256::digest(bytes).into()
|
||||
}
|
||||
|
||||
fn short_identity(bytes: &[u8; 32]) -> String {
|
||||
pub(super) fn short_identity(bytes: &[u8; 32]) -> String {
|
||||
hex(&bytes[..8])
|
||||
}
|
||||
|
||||
|
|
@ -685,7 +700,7 @@ fn hex(bytes: &[u8]) -> String {
|
|||
encoded
|
||||
}
|
||||
|
||||
fn require_peer_uid(actual: u32, expected: u32) -> Result<(), ControlError> {
|
||||
pub(super) fn require_peer_uid(actual: u32, expected: u32) -> Result<(), ControlError> {
|
||||
if actual == expected {
|
||||
Ok(())
|
||||
} else {
|
||||
|
|
@ -693,7 +708,7 @@ fn require_peer_uid(actual: u32, expected: u32) -> Result<(), ControlError> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_live_session(phase: SessionPhase) -> bool {
|
||||
pub(super) fn is_live_session(phase: SessionPhase) -> bool {
|
||||
matches!(
|
||||
phase,
|
||||
SessionPhase::Registering
|
||||
|
|
@ -704,9 +719,7 @@ fn is_live_session(phase: SessionPhase) -> bool {
|
|||
}
|
||||
|
||||
fn read_frame<
|
||||
Record: lazaret_core::records::SchemaType
|
||||
+ serde::de::DeserializeOwned
|
||||
+ serde::Serialize,
|
||||
Record: lazaret_core::records::SchemaType + serde::de::DeserializeOwned + serde::Serialize,
|
||||
>(
|
||||
reader: &mut impl Read,
|
||||
maximum: usize,
|
||||
|
|
|
|||
Loading…
Reference in a new issue