@@ -11,8 +11,12 @@ use std::fmt::Debug;
1111
1212use anyhow:: { anyhow, Result } ;
1313use const_oid:: ObjectIdentifier ;
14- use der:: { Decode , Encode } ;
14+ use der:: Decode ;
15+ #[ cfg( not( feature = "insecure" ) ) ]
16+ use der:: Encode ;
17+ #[ cfg( not( feature = "insecure" ) ) ]
1518use sgx:: parameters:: { Attributes , MiscSelect } ;
19+ #[ cfg( not( feature = "insecure" ) ) ]
1620use sha2:: { Digest , Sha256 } ;
1721use x509:: { ext:: Extension , request:: CertReqInfo , Certificate , TbsCertificate } ;
1822
@@ -42,7 +46,7 @@ impl ExtVerifier for Sgx {
4246 const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.3.6.1.4.1.58270.1.2" ) ;
4347 const ATT : bool = true ;
4448
45- fn verify ( & self , cri : & CertReqInfo < ' _ > , ext : & Extension < ' _ > , dbg : bool ) -> Result < bool > {
49+ fn verify ( & self , cri : & CertReqInfo < ' _ > , ext : & Extension < ' _ > ) -> Result < bool > {
4650 if ext. critical {
4751 return Err ( anyhow ! ( "sgx extension cannot be critical" ) ) ;
4852 }
@@ -62,7 +66,8 @@ impl ExtVerifier for Sgx {
6266
6367 // Validate the report.
6468 let pck = self . trusted ( & chain) ?;
65- let rpt = quote. verify ( pck) ?;
69+ #[ cfg( feature = "insecure" ) ]
70+ quote. verify ( pck) ?;
6671
6772 // Force certs to have the same key type as the PCK.
6873 //
@@ -82,7 +87,10 @@ impl ExtVerifier for Sgx {
8287 return Err ( anyhow ! ( "sgx pck algorithm mismatch" ) ) ;
8388 }
8489
85- if !dbg {
90+ #[ cfg( not( feature = "insecure" ) ) ]
91+ {
92+ let rpt = quote. verify ( pck) ?;
93+
8694 // TODO: Validate that the certification request came from an SGX enclave.
8795 let hash = Sha256 :: digest ( & cri. public_key . to_vec ( ) ?) ;
8896 if hash. as_slice ( ) != & rpt. reportdata [ ..hash. as_slice ( ) . len ( ) ] {
0 commit comments