mirror of
https://github.com/kristoferssolo/tls-pq-bench.git
synced 2026-03-22 00:36:21 +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 rcgen::{BasicConstraints, CertificateParams, DnType, IsCa, Issuer, KeyPair, SanType};
|
||||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
pub mod cert;
|
pub mod cert;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
pub mod prelude;
|
||||||
pub mod protocol;
|
pub mod protocol;
|
||||||
|
|
||||||
pub use error::Error;
|
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,
|
// Casts are intentional: MAX_PAYLOAD_SIZE (16 MiB) fits in usize on 64-bit,
|
||||||
// and byte patterns are explicitly masked to 0xFF before casting.
|
// and byte patterns are explicitly masked to 0xFF before casting.
|
||||||
#![allow(clippy::cast_possible_truncation)]
|
#![allow(clippy::cast_possible_truncation)]
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
use common::{
|
use common::prelude::*;
|
||||||
BenchRecord, KeyExchangeMode,
|
|
||||||
protocol::{read_payload, write_request},
|
|
||||||
};
|
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
use futures::{StreamExt, stream::FuturesUnordered};
|
||||||
use miette::{Context, IntoDiagnostic};
|
use miette::{Context, IntoDiagnostic};
|
||||||
use rustls::pki_types::ServerName;
|
use rustls::pki_types::ServerName;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
config::utils::validate_config,
|
config::utils::validate_config,
|
||||||
error::{self, ConfigError},
|
error::{self, ConfigError},
|
||||||
};
|
};
|
||||||
use common::{self, KeyExchangeMode};
|
use common::prelude::*;
|
||||||
use miette::{NamedSource, SourceSpan};
|
use miette::{NamedSource, SourceSpan};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{fs::read_to_string, net::SocketAddr, path::Path};
|
use std::{fs::read_to_string, net::SocketAddr, path::Path};
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ mod config;
|
|||||||
mod error;
|
mod error;
|
||||||
mod tls;
|
mod tls;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
args::Args,
|
||||||
|
bench::run_benchmark,
|
||||||
|
config::{load_from_cli, load_from_file},
|
||||||
|
tls::build_tls_config,
|
||||||
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use miette::{Context, IntoDiagnostic};
|
use miette::{Context, IntoDiagnostic};
|
||||||
use rustls::pki_types::ServerName;
|
use rustls::pki_types::ServerName;
|
||||||
@@ -21,13 +27,6 @@ use tracing::info;
|
|||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
args::Args,
|
|
||||||
bench::run_benchmark,
|
|
||||||
config::{load_from_cli, load_from_file},
|
|
||||||
tls::build_tls_config,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> miette::Result<()> {
|
async fn main() -> miette::Result<()> {
|
||||||
let run_id = Uuid::new_v4();
|
let run_id = Uuid::new_v4();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use common::KeyExchangeMode;
|
use common::prelude::*;
|
||||||
use miette::{Context, IntoDiagnostic};
|
use miette::{Context, IntoDiagnostic};
|
||||||
use rustls::{
|
use rustls::{
|
||||||
ClientConfig, DigitallySignedStruct, SignatureScheme,
|
ClientConfig, DigitallySignedStruct, SignatureScheme,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ mod tls;
|
|||||||
use crate::{server::run_server, tls::build_tls_config};
|
use crate::{server::run_server, tls::build_tls_config};
|
||||||
use base64::prelude::*;
|
use base64::prelude::*;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use common::{KeyExchangeMode, cert::CaCertificate};
|
use common::{cert::CaCertificate, prelude::*};
|
||||||
use std::{env, net::SocketAddr};
|
use std::{env, net::SocketAddr};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
@@ -72,7 +72,6 @@ async fn main() -> miette::Result<()> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use claims::assert_ok;
|
use claims::assert_ok;
|
||||||
use common::cert::CaCertificate;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{Args, error};
|
use crate::{Args, error};
|
||||||
use common::protocol::{read_request, write_payload};
|
use common::prelude::*;
|
||||||
use rustls::{ServerConfig, server::Acceptor};
|
use rustls::{ServerConfig, server::Acceptor};
|
||||||
use std::{io::ErrorKind, net::SocketAddr, sync::Arc};
|
use std::{io::ErrorKind, net::SocketAddr, sync::Arc};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::error;
|
use crate::error;
|
||||||
use common::{KeyExchangeMode, cert::ServerCertificate};
|
use common::{cert::ServerCertificate, prelude::*};
|
||||||
use rustls::{
|
use rustls::{
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
crypto::aws_lc_rs::{
|
crypto::aws_lc_rs::{
|
||||||
|
|||||||
Reference in New Issue
Block a user