1+ //! CVM attestation generation and verification
2+
13#[ cfg( feature = "azure" ) ]
24pub mod azure;
35pub mod dcap;
@@ -122,23 +124,7 @@ pub struct AttestationGenerator {
122124}
123125
124126impl 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 ] ,
0 commit comments