File tree Expand file tree Collapse file tree 5 files changed +11
-9
lines changed
remote_attestation/server Expand file tree Collapse file tree 5 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 11use crate :: SevFirmwareFactory ;
22use crate :: server:: ConnInfo ;
33use attestation:: attestation_package:: generate_attestation_package;
4- use attestation:: custom_data:: DerEncodedCustomData ;
54use attestation:: verification:: { SevRootCertificateVerification , verify_attestation_package} ;
65use config_types:: TrustedExecutionEnvironmentConfig ;
76use der:: asn1:: OctetStringRef ;
@@ -111,12 +110,12 @@ impl DiskEncryptionKeyExchangeServiceImpl {
111110
112111 let client_public_key = Self :: client_public_key_from_request ( & request) ?;
113112
114- let custom_data = DerEncodedCustomData ( GetDiskEncryptionKeyTokenCustomData {
113+ let custom_data = GetDiskEncryptionKeyTokenCustomData {
115114 client_tls_public_key : OctetStringRef :: new ( & client_public_key)
116115 . expect ( "Could not encode client public key" ) ,
117116 server_tls_public_key : OctetStringRef :: new ( & self . my_public_key )
118117 . expect ( "Could not encode server public key" ) ,
119- } ) ;
118+ } ;
120119
121120 let my_attestation_package = generate_attestation_package (
122121 sev_firmware. as_mut ( ) ,
Original file line number Diff line number Diff line change @@ -34,8 +34,10 @@ mod tests {
3434 server_tls_public_key,
3535 } ;
3636
37+ #[ allow( deprecated) ]
38+ let result = custom_data. encode_for_sev_legacy ( ) . unwrap ( ) ;
3739 assert_eq ! (
38- & custom_data . encode_for_sev_legacy ( ) . unwrap ( ) . as_slice ( ) ,
40+ & result ,
3941 // The numbers below don't have any special meaning, but they should stay stable.
4042 // If the encoding below has to be changed, the attestation report verification will
4143 // probably fail because the old GuestOS version will still derive the previous
Original file line number Diff line number Diff line change @@ -22,4 +22,4 @@ rust_binary(
2222rust_test (
2323 name = "server_test" ,
2424 crate = ":server" ,
25- )
25+ )
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ impl RemoteAttestationServiceImpl {
3636 }
3737 }
3838
39+ #[ allow( clippy:: result_large_err) ]
3940 fn sev_custom_data_from_request ( & self , req : & AttestRequest ) -> Result < SevCustomData , Status > {
4041 let custom_data: [ u8 ; 64 ] = match & req. custom_data {
4142 Some ( bytes) => bytes
Original file line number Diff line number Diff line change @@ -49,12 +49,12 @@ impl SevCustomData {
4949 namespace : SevCustomDataNamespace ,
5050 data : [ u8 ; 64 ] ,
5151 ) -> Result < Self , InvalidNamespace > {
52- if data[ 0 .. 4 ] != namespace . as_bytes ( ) {
53- return Err ( InvalidNamespace ) ;
54- }
52+ let data = data
53+ . strip_prefix ( & namespace . as_bytes ( ) )
54+ . ok_or ( InvalidNamespace ) ? ;
5555 Ok ( Self {
5656 namespace,
57- data : data[ 4 .. ] . try_into ( ) . unwrap ( ) ,
57+ data : data. try_into ( ) . unwrap ( ) ,
5858 } )
5959 }
6060
You can’t perform that action at this time.
0 commit comments