Skip to content

Commit 3cca29f

Browse files
authored
Merge pull request #85 from flashbots/peg/doccomments
Improve doccomments for publishing as library
2 parents 8113256 + f095dd6 commit 3cca29f

File tree

11 files changed

+43
-22
lines changed

11 files changed

+43
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ members = [".", "dummy-attestation-server"]
33

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

1013
[dependencies]
1114
tokio = { version = "1.48.0", features = ["full"] }

dummy-attestation-server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
edition = "2024"
55
license = "MIT"
66
publish = false
7+
repository = "https://github.com/flashbots/attested-tls-proxy"
78

89
[dependencies]
910
attested-tls-proxy = { path = ".." }

src/attestation/azure/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Microsoft Azure Attestation (MAA) evidence generation and verification
1+
//! Microsoft Azure vTPM attestation evidence generation and verification
22
mod ak_certificate;
33
mod nv_index;
44
use ak_certificate::{read_ak_certificate_from_tpm, verify_ak_cert_with_azure_roots};
@@ -245,6 +245,7 @@ impl RsaPubKey {
245245
}
246246
}
247247

248+
/// An error when generating or verifying a Microsoft Azure vTPM attestation
248249
#[derive(Error, Debug)]
249250
pub enum MaaError {
250251
#[error("Report: {0}")]

src/attestation/mod.rs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! CVM attestation generation and verification
2+
13
#[cfg(feature = "azure")]
24
pub mod azure;
35
pub mod dcap;
@@ -122,23 +124,7 @@ pub struct AttestationGenerator {
122124
}
123125

124126
impl AttestationGenerator {
125-
/// Create an [AttestationGenerator] detecting the attestation type if it is specified as 'auto'
126-
pub async fn new_with_detection(
127-
attestation_type_string: Option<String>,
128-
dummy_dcap_url: Option<String>,
129-
) -> Result<Self, AttestationError> {
130-
let attestation_type_string = attestation_type_string.unwrap_or_else(|| "auto".to_string());
131-
let attestaton_type = if attestation_type_string == "auto" {
132-
tracing::info!("Doing attestation type detection...");
133-
AttestationType::detect().await?
134-
} else {
135-
serde_json::from_value(serde_json::Value::String(attestation_type_string))?
136-
};
137-
tracing::info!("Local platform: {attestaton_type}");
138-
139-
Self::new(attestaton_type, dummy_dcap_url)
140-
}
141-
127+
/// Create an attesation generator with given attestation type
142128
pub fn new(
143129
attestation_type: AttestationType,
144130
dummy_dcap_url: Option<String>,
@@ -149,13 +135,37 @@ impl AttestationGenerator {
149135
}
150136
}
151137

138+
/// Detect what confidential compute platform is present and create the approprate attestation
139+
/// generator
140+
pub async fn detect() -> Result<Self, AttestationError> {
141+
Self::new_with_detection(None, None).await
142+
}
143+
144+
/// Do not generate attestations
152145
pub fn with_no_attestation() -> Self {
153146
Self {
154147
attestation_type: AttestationType::None,
155148
dummy_dcap_url: None,
156149
}
157150
}
158151

152+
/// Create an [AttestationGenerator] detecting the attestation type if it is not given
153+
pub async fn new_with_detection(
154+
attestation_type_string: Option<String>,
155+
dummy_dcap_url: Option<String>,
156+
) -> Result<Self, AttestationError> {
157+
let attestation_type_string = attestation_type_string.unwrap_or_else(|| "auto".to_string());
158+
let attestaton_type = if attestation_type_string == "auto" {
159+
tracing::info!("Doing attestation type detection...");
160+
AttestationType::detect().await?
161+
} else {
162+
serde_json::from_value(serde_json::Value::String(attestation_type_string))?
163+
};
164+
tracing::info!("Local platform: {attestaton_type}");
165+
166+
Self::new(attestaton_type, dummy_dcap_url)
167+
}
168+
159169
/// Create an [AttestationGenerator] without a given dummy DCAP url - meaning Dummy attestation
160170
/// type will not be possible
161171
pub fn new_not_dummy(attestation_type: AttestationType) -> Result<Self, AttestationError> {
@@ -190,7 +200,7 @@ impl AttestationGenerator {
190200
}
191201
}
192202

193-
/// Generate an attestation exchange message
203+
/// Generate an attestation exchange message with given input data
194204
pub async fn generate_attestation(
195205
&self,
196206
input_data: [u8; 64],
@@ -201,7 +211,7 @@ impl AttestationGenerator {
201211
})
202212
}
203213

204-
/// Generate attestation evidence bytes based on attestation type
214+
/// Generate attestation evidence bytes based on attestation type, with given input data
205215
async fn generate_attestation_bytes(
206216
&self,
207217
input_data: [u8; 64],

src/attested_get.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! A one-shot attested TLS proxy client which sends a single GET request and returns the response
12
use crate::{AttestationGenerator, AttestationVerifier, ProxyClient, ProxyError};
23
use tokio_rustls::rustls::pki_types::CertificateDer;
34

src/attested_tls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Attested TLS protocol server and client
12
use crate::{
23
attestation::{
34
measurements::MultiMeasurements, AttestationError, AttestationExchangeMessage,

src/file_server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Static HTTP file server provided by an attested TLS proxy server
12
use crate::{AttestationGenerator, AttestationVerifier, ProxyError, ProxyServer, TlsCertAndKey};
23
use std::{net::SocketAddr, path::PathBuf};
34
use tokio::net::ToSocketAddrs;

src/health_check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Provides health / version details for an attested proxy server or client
12
use axum::{routing::get, Json, Router};
23
use serde::{Deserialize, Serialize};
34
use std::net::SocketAddr;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! An attested TLS protocol and HTTPS proxy
12
pub mod attestation;
23
pub mod attested_get;
34
pub mod attested_tls;

0 commit comments

Comments
 (0)