Skip to content

Commit 06967a8

Browse files
committed
fixes
1 parent 4f7fc70 commit 06967a8

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

rs/ic_os/guest_upgrade/server/src/service.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::SevFirmwareFactory;
22
use crate::server::ConnInfo;
33
use attestation::attestation_package::generate_attestation_package;
4-
use attestation::custom_data::DerEncodedCustomData;
54
use attestation::verification::{SevRootCertificateVerification, verify_attestation_package};
65
use config_types::TrustedExecutionEnvironmentConfig;
76
use 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(),

rs/ic_os/guest_upgrade/shared/src/attestation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

rs/ic_os/remote_attestation/server/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ rust_binary(
2222
rust_test(
2323
name = "server_test",
2424
crate = ":server",
25-
)
25+
)

rs/ic_os/remote_attestation/server/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

rs/ic_os/sev/src/guest/custom_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)