mirror of
https://github.com/kristoferssolo/tls-pq-bench.git
synced 2026-03-21 16:26:22 +00:00
refactor(common): add prelude module
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
//! Self-signed certificate generation for local testing.
|
||||
//!
|
||||
//! Generates a CA certificate and server certificate for TLS benchmarking.
|
||||
//! These certificates are NOT suitable for production use.
|
||||
|
||||
use rcgen::{BasicConstraints, CertificateParams, DnType, IsCa, Issuer, KeyPair, SanType};
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
pub mod cert;
|
||||
pub mod error;
|
||||
pub mod prelude;
|
||||
pub mod protocol;
|
||||
|
||||
pub use error::Error;
|
||||
|
||||
4
common/src/prelude.rs
Normal file
4
common/src/prelude.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
pub use crate::{
|
||||
BenchRecord, KeyExchangeMode,
|
||||
protocol::{read_payload, read_request, write_payload, write_request},
|
||||
};
|
||||
@@ -1,11 +1,3 @@
|
||||
//! Benchmark protocol implementation.
|
||||
//!
|
||||
//! Protocol specification:
|
||||
//! 1. Client sends 8-byte little-endian u64: requested payload size N
|
||||
//! 2. Server responds with exactly N bytes (deterministic pattern)
|
||||
//!
|
||||
//! The deterministic pattern is a repeating sequence of bytes 0x00..0xFF.
|
||||
|
||||
// Casts are intentional: MAX_PAYLOAD_SIZE (16 MiB) fits in usize on 64-bit,
|
||||
// and byte patterns are explicitly masked to 0xFF before casting.
|
||||
#![allow(clippy::cast_possible_truncation)]
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
use common::{
|
||||
BenchRecord, KeyExchangeMode,
|
||||
protocol::{read_payload, write_request},
|
||||
};
|
||||
use common::prelude::*;
|
||||
use futures::{StreamExt, stream::FuturesUnordered};
|
||||
use miette::{Context, IntoDiagnostic};
|
||||
use rustls::pki_types::ServerName;
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
config::utils::validate_config,
|
||||
error::{self, ConfigError},
|
||||
};
|
||||
use common::{self, KeyExchangeMode};
|
||||
use common::prelude::*;
|
||||
use miette::{NamedSource, SourceSpan};
|
||||
use serde::Deserialize;
|
||||
use std::{fs::read_to_string, net::SocketAddr, path::Path};
|
||||
|
||||
@@ -12,6 +12,12 @@ mod config;
|
||||
mod error;
|
||||
mod tls;
|
||||
|
||||
use crate::{
|
||||
args::Args,
|
||||
bench::run_benchmark,
|
||||
config::{load_from_cli, load_from_file},
|
||||
tls::build_tls_config,
|
||||
};
|
||||
use clap::Parser;
|
||||
use miette::{Context, IntoDiagnostic};
|
||||
use rustls::pki_types::ServerName;
|
||||
@@ -21,13 +27,6 @@ use tracing::info;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
args::Args,
|
||||
bench::run_benchmark,
|
||||
config::{load_from_cli, load_from_file},
|
||||
tls::build_tls_config,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> miette::Result<()> {
|
||||
let run_id = Uuid::new_v4();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use common::KeyExchangeMode;
|
||||
use common::prelude::*;
|
||||
use miette::{Context, IntoDiagnostic};
|
||||
use rustls::{
|
||||
ClientConfig, DigitallySignedStruct, SignatureScheme,
|
||||
|
||||
@@ -11,7 +11,7 @@ mod tls;
|
||||
use crate::{server::run_server, tls::build_tls_config};
|
||||
use base64::prelude::*;
|
||||
use clap::Parser;
|
||||
use common::{KeyExchangeMode, cert::CaCertificate};
|
||||
use common::{cert::CaCertificate, prelude::*};
|
||||
use std::{env, net::SocketAddr};
|
||||
use tracing::{error, info};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
@@ -72,7 +72,6 @@ async fn main() -> miette::Result<()> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use claims::assert_ok;
|
||||
use common::cert::CaCertificate;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{Args, error};
|
||||
use common::protocol::{read_request, write_payload};
|
||||
use common::prelude::*;
|
||||
use rustls::{ServerConfig, server::Acceptor};
|
||||
use std::{io::ErrorKind, net::SocketAddr, sync::Arc};
|
||||
use tokio::{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::error;
|
||||
use common::{KeyExchangeMode, cert::ServerCertificate};
|
||||
use common::{cert::ServerCertificate, prelude::*};
|
||||
use rustls::{
|
||||
ServerConfig,
|
||||
crypto::aws_lc_rs::{
|
||||
|
||||
Reference in New Issue
Block a user