Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Szaknis <m.szaknis@samsung.com>
  • Loading branch information
L0czek committed Oct 9, 2024
1 parent d377e1d commit 3474b60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions rmm/src/rmi/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,7 +63,7 @@ impl IsletRealmMetadata {
let g_realm_metadata = get_granule_if!(metadata_addr, GranuleState::Undelegated)?;
let realm_metadata = g_realm_metadata.content::<Self>()?;

Ok(realm_metadata.clone())
Ok(*realm_metadata)
}

fn realm_id_as_str(&self) -> Option<&str> {
Expand Down Expand Up @@ -90,11 +94,11 @@ impl IsletRealmMetadata {

fn verifying_key(&self) -> core::result::Result<VerifyingKey, Error> {
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<Signature, Error> {
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] {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions rmm/src/rsi/sealing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl KdfInfo {
let info = self.as_u8_slice();

let hkdf = hkdf::Hkdf::<sha2::Sha256>::new(Some(&SALT), &ikm);
hkdf.expand(&info, okm).or(Err(Error::RmiErrorInput))?;
hkdf.expand(info, okm).or(Err(Error::RmiErrorInput))?;

Ok(())
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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());
}

Expand All @@ -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();
Expand Down

0 comments on commit 3474b60

Please sign in to comment.