@@ -3,6 +3,7 @@ use crate::{
33 opts:: { EnclaveOpts , Opts } ,
44} ;
55use anyhow:: { anyhow, Result } ;
6+ use attestation_report:: RAQuote ;
67use clap:: Parser ;
78use crypto:: Address ;
89use ecall_commands:: GenerateEnclaveKeyInput ;
@@ -87,10 +88,13 @@ fn run_generate_key<E: EnclaveCommandAPI<S>, S: CommitStore>(
8788) -> Result < ( ) > {
8889 let ( target_info, _) = remote_attestation:: init_quote ( input. target_qe3 ) ?;
8990 let res = enclave
90- . generate_enclave_key ( GenerateEnclaveKeyInput {
91- target_info,
92- operator : input. get_operator ( ) ?,
93- } )
91+ . generate_enclave_key (
92+ GenerateEnclaveKeyInput {
93+ target_info,
94+ operator : input. get_operator ( ) ?,
95+ } ,
96+ input. target_qe3 ,
97+ )
9498 . map_err ( |e| anyhow ! ( "failed to generate an enclave key: {:?}" , e) ) ?;
9599 println ! ( "{}" , res. pub_key. as_address( ) ) ;
96100 Ok ( ( ) )
@@ -121,37 +125,37 @@ fn run_list_keys<E: EnclaveCommandAPI<S>, S: CommitStore>(
121125 } ;
122126 let mut list_json = Vec :: new ( ) ;
123127 for eki in list {
124- let ias_attested = eki. ias_report . is_some ( ) ;
125- let dcap_attested = eki . dcap_quote . is_some ( ) ;
126-
127- if ias_attested {
128- let avr = eki . ias_report . as_ref ( ) . unwrap ( ) . get_avr ( ) ? ;
129- let report_data = avr . parse_quote ( ) ? . report_data ( ) ;
130- list_json . push ( json ! { {
131- "type ": "ias" ,
132- "address ": eki . address . to_hex_string ( ) ,
133- "attested ": true ,
134- "report_data ": report_data . to_string ( ) ,
135- "isv_enclave_quote_status ": avr. isv_enclave_quote_status ,
136- "advisory_ids" : avr . advisory_ids ,
137- "attested_at" : avr . timestamp
138- } } ) ;
139- } else if dcap_attested {
140- let dcap_quote = eki . dcap_quote . as_ref ( ) . unwrap ( ) ;
141- list_json . push ( json ! { {
142- "type ": "dcap" ,
143- "address ": eki . address . to_hex_string ( ) ,
144- "attested ": true ,
145- "report_data ": dcap_quote . report_data ( ) ? . to_string ( ) ,
146- "isv_enclave_quote_status ": dcap_quote . tcb_status ,
147- "advisory_ids" : dcap_quote . advisory_ids ,
148- "attested_at" : dcap_quote . attested_at . to_string ( ) ,
149- } } ) ;
150- } else {
151- list_json . push ( json ! { {
152- "address ": eki . address . to_hex_string ( ) ,
153- "attested" : false ,
154- } } ) ;
128+ match eki. ra_quote {
129+ Some ( RAQuote :: IAS ( report ) ) => {
130+ let avr = report . get_avr ( ) ? ;
131+ let report_data = avr . parse_quote ( ) ? . report_data ( ) ;
132+ list_json . push ( json ! { {
133+ "type" : "ias" ,
134+ "address" : eki . address . to_hex_string ( ) ,
135+ "attested ": true ,
136+ "report_data ": report_data . to_string ( ) ,
137+ "isv_enclave_quote_status ": avr . isv_enclave_quote_status ,
138+ "advisory_ids ": avr . advisory_ids ,
139+ "attested_at ": avr. timestamp
140+ } } ) ;
141+ }
142+ Some ( RAQuote :: DCAP ( quote ) ) => {
143+ list_json . push ( json ! { {
144+ "type" : "dcap" ,
145+ "address" : eki . address . to_hex_string ( ) ,
146+ "attested ": true ,
147+ "report_data ": quote . report_data ( ) ? . to_string ( ) ,
148+ "isv_enclave_quote_status ": quote . tcb_status ,
149+ "advisory_ids ": quote . advisory_ids ,
150+ "attested_at ": quote . attested_at . to_string ( ) ,
151+ } } ) ;
152+ }
153+ None => {
154+ list_json . push ( json ! { {
155+ "address" : eki . address . to_hex_string ( ) ,
156+ "attested ": false ,
157+ } } ) ;
158+ }
155159 }
156160 }
157161 println ! ( "{}" , serde_json:: to_string( & list_json) . unwrap( ) ) ;
0 commit comments