From 3474b60aa010d3261d53a22260316830c16f0dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szaknis?= Date: Wed, 9 Oct 2024 17:43:44 +0200 Subject: [PATCH] Fix clippy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MichaƂ Szaknis --- rmm/src/rmi/metadata.rs | 12 ++++++++---- rmm/src/rsi/sealing.rs | 10 +++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rmm/src/rmi/metadata.rs b/rmm/src/rmi/metadata.rs index 7dcbc0f853e4..597587b8f45d 100644 --- a/rmm/src/rmi/metadata.rs +++ b/rmm/src/rmi/metadata.rs @@ -15,13 +15,17 @@ const FMT_VERSION: usize = 1; pub const REALM_ID_SIZE: usize = 128; pub const P384_PUBLIC_KEY_SIZE: usize = 96; const P384_SIGNATURE_SIZE: usize = P384_PUBLIC_KEY_SIZE; + +#[allow(dead_code)] const P385_SIGNATURE_POINT_SIZE: usize = P384_SIGNATURE_SIZE / 2; +#[allow(dead_code)] const SHA_384_HASH_SIZE: usize = 48; const METADATA_HASH_SHA_256: usize = 0x01; const METADATA_HASH_SHA_512: usize = 0x02; const REALM_METADATA_HEADER_SIZE: usize = 0x150; +#[allow(dead_code)] const REALM_METADATA_SIGNED_SIZE: usize = 0x1B0; const REALM_METADATA_UNUSED_SIZE: usize = 0xE50; @@ -59,7 +63,7 @@ impl IsletRealmMetadata { let g_realm_metadata = get_granule_if!(metadata_addr, GranuleState::Undelegated)?; let realm_metadata = g_realm_metadata.content::()?; - Ok(realm_metadata.clone()) + Ok(*realm_metadata) } fn realm_id_as_str(&self) -> Option<&str> { @@ -90,11 +94,11 @@ impl IsletRealmMetadata { fn verifying_key(&self) -> core::result::Result { let point = EncodedPoint::from_untagged_bytes(GenericArray::from_slice(&self.public_key)); - Ok(VerifyingKey::from_encoded_point(&point).or(Err(Error::RmiErrorInput))?) + VerifyingKey::from_encoded_point(&point).or(Err(Error::RmiErrorInput)) } fn signature(&self) -> core::result::Result { - Ok(Signature::from_slice(&self.signature).or(Err(Error::RmiErrorInput))?) + Signature::from_slice(&self.signature).or(Err(Error::RmiErrorInput)) } fn header_as_u8_slice(&self) -> &[u8] { @@ -152,7 +156,7 @@ impl IsletRealmMetadata { } pub fn equal_rd_rim(&self, rim: &Measurement) -> bool { - rim.as_slice() == &self.rim + rim.as_slice() == self.rim } pub fn equal_rd_hash_algo(&self, hash_algo: u8) -> bool { diff --git a/rmm/src/rsi/sealing.rs b/rmm/src/rsi/sealing.rs index 530b5a654d8e..8feb15d0a92b 100644 --- a/rmm/src/rsi/sealing.rs +++ b/rmm/src/rsi/sealing.rs @@ -96,7 +96,7 @@ impl KdfInfo { let info = self.as_u8_slice(); let hkdf = hkdf::Hkdf::::new(Some(&SALT), &ikm); - hkdf.expand(&info, okm).or(Err(Error::RmiErrorInput))?; + hkdf.expand(info, okm).or(Err(Error::RmiErrorInput))?; Ok(()) } @@ -124,10 +124,10 @@ pub fn realm_sealing_key( Err(Error::RmiErrorInput)? } - info.public_key = metadata.public_key().clone(); + info.public_key = *metadata.public_key(); if flags & RSI_ISLET_SLK_REALM_ID != 0 { - info.realm_id = metadata.realm_id().clone(); + info.realm_id = *metadata.realm_id(); } if flags & RSI_ISLET_SLK_SVN != 0 { @@ -140,7 +140,7 @@ pub fn realm_sealing_key( // is always used as the key material. if flags & RSI_ISLET_SLK_RIM != 0 || rd.metadata().is_none() { let mut rim = Measurement::empty(); - crate::rsi::measurement::read(&rd, MEASUREMENTS_SLOT_RIM, &mut rim)?; + crate::rsi::measurement::read(rd, MEASUREMENTS_SLOT_RIM, &mut rim)?; info.rim.copy_from_slice(rim.as_slice()); } @@ -153,7 +153,7 @@ pub fn realm_sealing_key( "VHUK_A" } ); - info.derive_sealing_key(flags & RSI_ISLET_USE_VHUK_M != 0, buf); + info.derive_sealing_key(flags & RSI_ISLET_USE_VHUK_M != 0, buf)?; // Clear the input key material info.zeroize();