Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ members = [".", "dummy-attestation-server"]

[package]
name = "attested-tls-proxy"
version = "0.1.0"
version = "0.0.1"
edition = "2024"
license = "MIT"
description = "An HTTP attested TLS proxy server and client for secure communication with CVM services"
repository = "https://github.com/flashbots/attested-tls-proxy"
keywords = ["attested-TLS", "CVM", "TDX"]

[dependencies]
tokio = { version = "1.48.0", features = ["full"] }
Expand Down
1 change: 1 addition & 0 deletions dummy-attestation-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2024"
license = "MIT"
publish = false
repository = "https://github.com/flashbots/attested-tls-proxy"

[dependencies]
attested-tls-proxy = { path = ".." }
Expand Down
3 changes: 2 additions & 1 deletion src/attestation/azure/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Microsoft Azure Attestation (MAA) evidence generation and verification
//! Microsoft Azure vTPM attestation evidence generation and verification
mod ak_certificate;
mod nv_index;
use ak_certificate::{read_ak_certificate_from_tpm, verify_ak_cert_with_azure_roots};
Expand Down Expand Up @@ -245,6 +245,7 @@ impl RsaPubKey {
}
}

/// An error when generating or verifying a Microsoft Azure vTPM attestation
#[derive(Error, Debug)]
pub enum MaaError {
#[error("Report: {0}")]
Expand Down
48 changes: 29 additions & 19 deletions src/attestation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! CVM attestation generation and verification

#[cfg(feature = "azure")]
pub mod azure;
pub mod dcap;
Expand Down Expand Up @@ -122,23 +124,7 @@ pub struct AttestationGenerator {
}

impl AttestationGenerator {
/// Create an [AttestationGenerator] detecting the attestation type if it is specified as 'auto'
pub async fn new_with_detection(
attestation_type_string: Option<String>,
dummy_dcap_url: Option<String>,
) -> Result<Self, AttestationError> {
let attestation_type_string = attestation_type_string.unwrap_or_else(|| "auto".to_string());
let attestaton_type = if attestation_type_string == "auto" {
tracing::info!("Doing attestation type detection...");
AttestationType::detect().await?
} else {
serde_json::from_value(serde_json::Value::String(attestation_type_string))?
};
tracing::info!("Local platform: {attestaton_type}");

Self::new(attestaton_type, dummy_dcap_url)
}

/// Create an attesation generator with given attestation type
pub fn new(
attestation_type: AttestationType,
dummy_dcap_url: Option<String>,
Expand All @@ -149,13 +135,37 @@ impl AttestationGenerator {
}
}

/// Detect what confidential compute platform is present and create the approprate attestation
/// generator
pub async fn detect() -> Result<Self, AttestationError> {
Self::new_with_detection(None, None).await
}

/// Do not generate attestations
pub fn with_no_attestation() -> Self {
Self {
attestation_type: AttestationType::None,
dummy_dcap_url: None,
}
}

/// Create an [AttestationGenerator] detecting the attestation type if it is not given
pub async fn new_with_detection(
attestation_type_string: Option<String>,
dummy_dcap_url: Option<String>,
) -> Result<Self, AttestationError> {
let attestation_type_string = attestation_type_string.unwrap_or_else(|| "auto".to_string());
let attestaton_type = if attestation_type_string == "auto" {
tracing::info!("Doing attestation type detection...");
AttestationType::detect().await?
} else {
serde_json::from_value(serde_json::Value::String(attestation_type_string))?
};
tracing::info!("Local platform: {attestaton_type}");

Self::new(attestaton_type, dummy_dcap_url)
}

/// Create an [AttestationGenerator] without a given dummy DCAP url - meaning Dummy attestation
/// type will not be possible
pub fn new_not_dummy(attestation_type: AttestationType) -> Result<Self, AttestationError> {
Expand Down Expand Up @@ -190,7 +200,7 @@ impl AttestationGenerator {
}
}

/// Generate an attestation exchange message
/// Generate an attestation exchange message with given input data
pub async fn generate_attestation(
&self,
input_data: [u8; 64],
Expand All @@ -201,7 +211,7 @@ impl AttestationGenerator {
})
}

/// Generate attestation evidence bytes based on attestation type
/// Generate attestation evidence bytes based on attestation type, with given input data
async fn generate_attestation_bytes(
&self,
input_data: [u8; 64],
Expand Down
1 change: 1 addition & 0 deletions src/attested_get.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! A one-shot attested TLS proxy client which sends a single GET request and returns the response
use crate::{AttestationGenerator, AttestationVerifier, ProxyClient, ProxyError};
use tokio_rustls::rustls::pki_types::CertificateDer;

Expand Down
1 change: 1 addition & 0 deletions src/attested_tls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Attested TLS protocol server and client
use crate::{
attestation::{
measurements::MultiMeasurements, AttestationError, AttestationExchangeMessage,
Expand Down
1 change: 1 addition & 0 deletions src/file_server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Static HTTP file server provided by an attested TLS proxy server
use crate::{AttestationGenerator, AttestationVerifier, ProxyError, ProxyServer, TlsCertAndKey};
use std::{net::SocketAddr, path::PathBuf};
use tokio::net::ToSocketAddrs;
Expand Down
1 change: 1 addition & 0 deletions src/health_check.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Provides health / version details for an attested proxy server or client
use axum::{routing::get, Json, Router};
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! An attested TLS protocol and HTTPS proxy
pub mod attestation;
pub mod attested_get;
pub mod attested_tls;
Expand Down
1 change: 1 addition & 0 deletions src/test_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Helper functions used in tests
use axum::response::IntoResponse;
use std::{
collections::HashMap,
Expand Down