Skip to content

Commit 89733c6

Browse files
committed
Add logging
1 parent 43cedd9 commit 89733c6

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

src/attestation/azure/ak_certificate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ pub fn verify_ak_cert_with_azure_roots(ak_cert_der: &[u8], now_secs: u64) -> Res
152152
None,
153153
None,
154154
)?;
155+
tracing::debug!("Successfully verified AK certificate from vTPM");
155156

156157
Ok(())
157158
}
158159

159160
/// Retrieve an AK certificate from the vTPM
160161
pub fn read_ak_certificate_from_tpm() -> Result<Vec<u8>, tss_esapi::Error> {
162+
tracing::debug!("Reading AK certificate from vTPM");
161163
let mut context = nv_index::get_session_context()?;
162164
nv_index::read_nv_index(&mut context, TPM_AK_CERT_IDX)
163165
}

src/attestation/azure/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct AttestationDocument {
2929
struct TpmAttest {
3030
/// Attestation Key certificate from vTPM
3131
ak_certificate_pem: String,
32-
/// vTPM quotes over the selected PCR bank(s).
32+
/// vTPM quote
3333
quote: vtpm::Quote,
3434
/// Raw TCG event log bytes (UEFI + IMA) [currently not used]
3535
///
@@ -68,6 +68,7 @@ pub async fn create_azure_attestation(input_data: [u8; 64]) -> Result<Vec<u8>, M
6868
tpm_attestation,
6969
};
7070

71+
tracing::info!("Successfully generated azure attestation: {attestation_document:?}");
7172
Ok(serde_json::to_vec(&attestation_document)?)
7273
}
7374

@@ -94,6 +95,7 @@ async fn verify_azure_attestation_with_given_timestamp(
9495
now: u64,
9596
) -> Result<super::measurements::Measurements, MaaError> {
9697
let attestation_document: AttestationDocument = serde_json::from_slice(&input)?;
98+
tracing::info!("Attempting to verifiy azure attestation: {attestation_document:?}");
9799

98100
let hcl_report_bytes = BASE64_URL_SAFE.decode(attestation_document.hcl_report_base64)?;
99101

src/attestation/azure/nv_index.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub fn get_session_context() -> Result<Context, tss_esapi::Error> {
1414
}
1515

1616
pub fn read_nv_index(ctx: &mut Context, index: u32) -> Result<Vec<u8>, tss_esapi::Error> {
17+
tracing::debug!("Reading from TPM, nv index: {index}");
1718
let nv_tpm_handle = NvIndexTpmHandle::new(index)?;
1819
let buf = tss_esapi::abstraction::nv::read_full(ctx, NvAuth::Owner, nv_tpm_handle)?;
1920
Ok(buf.to_vec())

src/attestation/dcap.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ pub const PCS_URL: &str = "https://api.trustedservices.intel.com";
1616

1717
/// Quote generation using configfs_tsm
1818
pub async fn create_dcap_attestation(input_data: [u8; 64]) -> Result<Vec<u8>, AttestationError> {
19-
Ok(generate_quote(input_data)?)
19+
let quote = generate_quote(input_data)?;
20+
tracing::info!("Generated TDX quote of {} bytes", quote.len());
21+
Ok(quote)
2022
}
2123

2224
/// Verify a DCAP TDX quote, and return the measurement values
@@ -30,6 +32,7 @@ pub async fn verify_dcap_attestation(
3032
.duration_since(std::time::UNIX_EPOCH)?
3133
.as_secs();
3234
let quote = Quote::parse(&input)?;
35+
tracing::info!("Verifying DCAP attestation: {quote:?}");
3336

3437
let ca = quote.ca()?;
3538
let fmspc = hex::encode_upper(quote.fmspc()?);
@@ -99,27 +102,13 @@ pub fn get_quote_input_data(report: Report) -> [u8; 64] {
99102
}
100103
}
101104

102-
/// An error when generating or verifying an attestation
105+
/// An error when verifying a DCAP attestation
103106
#[derive(Error, Debug)]
104107
pub enum DcapVerificationError {
105-
// #[error("Certificate chain is empty")]
106-
// NoCertificate,
107-
// #[error("X509 parse: {0}")]
108-
// X509Parse(#[from] x509_parser::asn1_rs::Err<x509_parser::error::X509Error>),
109-
// #[error("X509: {0}")]
110-
// X509(#[from] x509_parser::error::X509Error),
111108
#[error("Quote input is not as expected")]
112109
InputMismatch,
113-
// #[error("Configuration mismatch - expected no remote attestation")]
114-
// AttestationGivenWhenNoneExpected,
115-
// #[error("Configfs-tsm quote generation: {0}")]
116-
// QuoteGeneration(#[from] configfs_tsm::QuoteGenerationError),
117110
#[error("SGX quote given when TDX quote expected")]
118111
SgxNotSupported,
119-
// #[error("Platform measurements do not match any accepted values")]
120-
// UnacceptablePlatformMeasurements,
121-
// #[error("OS image measurements do not match any accepted values")]
122-
// UnacceptableOsImageMeasurements,
123112
#[error("System Time: {0}")]
124113
SystemTime(#[from] std::time::SystemTimeError),
125114
#[error("DCAP quote verification: {0}")]

src/attestation/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ impl AttestationGenerator {
172172
}
173173
#[cfg(not(feature = "azure"))]
174174
{
175+
tracing::error!("Attempted to generate an azure attestation but the `azure` feature not enabled");
175176
Err(AttestationError::AttestationTypeNotSupported)
176177
}
177178
}

0 commit comments

Comments
 (0)