mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust: Apply suggested fixes from clippy
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
+5
-6
@@ -48,7 +48,7 @@ impl TryFrom<Vec<u8>> for BootHdrTags {
|
||||
|
||||
/// Struct representing the Secure Execution boot image metadata
|
||||
#[allow(unused)]
|
||||
#[repr(packed)]
|
||||
#[repr(C, packed)]
|
||||
#[derive(Debug, Clone, FromBytes, IntoBytes, PartialEq, Eq, Immutable, KnownLayout)]
|
||||
pub struct SeImgMetaData {
|
||||
/// Magic value
|
||||
@@ -140,15 +140,14 @@ pub fn seek_se_hdr_start<R>(img: &mut R) -> Result<bool>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
let max_iter: usize;
|
||||
const BUF_SIZE: i64 = 8;
|
||||
static_assert!(BootHdrMagic::MAGIC.len() == BUF_SIZE as usize);
|
||||
|
||||
let old_position = img.stream_position()?;
|
||||
if !SeImgMetaData::seek_start(img)? {
|
||||
let max_iter: usize = if !SeImgMetaData::seek_start(img)? {
|
||||
// Search from the previous position.
|
||||
img.seek(std::io::SeekFrom::Start(old_position))?;
|
||||
max_iter = 0x15;
|
||||
0x15
|
||||
} else {
|
||||
let mut img_metadata_bytes = vec![0u8; size_of::<SeImgMetaData>()];
|
||||
// read in the header
|
||||
@@ -161,8 +160,8 @@ where
|
||||
}
|
||||
|
||||
img.seek(std::io::SeekFrom::Start(img_metadata.hdr_off.into()))?;
|
||||
max_iter = 1;
|
||||
}
|
||||
1
|
||||
};
|
||||
|
||||
let mut buf = [0; BUF_SIZE as usize];
|
||||
for _ in 0..max_iter {
|
||||
|
||||
@@ -142,7 +142,7 @@ impl AttestationRequest {
|
||||
}
|
||||
|
||||
/// Checks for magic and returns [`BinReqValues`]
|
||||
fn bin_values(arcb: &[u8]) -> Result<BinReqValues> {
|
||||
fn bin_values(arcb: &[u8]) -> Result<BinReqValues<'_>> {
|
||||
if !AttestationMagic::starts_with_magic(arcb) {
|
||||
return Err(Error::NoArcb);
|
||||
}
|
||||
|
||||
@@ -167,8 +167,7 @@ impl CertVerifier {
|
||||
/// * `cert_paths` - Paths to certificates for the chain of trust
|
||||
/// * `crl_paths` - Paths to certificate revocation lists for the chain of trust
|
||||
/// * `root_ca_path` - Path to the root of trust
|
||||
/// * `offline` - if set to true the verification process will not try to download CRLs from the
|
||||
/// internet.
|
||||
/// * `offline` - if set to true the verification process will not try to download CRLs from the internet.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
||||
@@ -443,17 +443,17 @@ mod test {
|
||||
let ibm_wrong_subj = load_gen_cert("ibm_wrong_subject.crt");
|
||||
let no_sign_crt = load_gen_cert("inter_ca.crt");
|
||||
|
||||
assert!(super::get_ibm_z_sign_key(&[ibm_crt.clone()]).is_ok());
|
||||
assert!(super::get_ibm_z_sign_key(std::slice::from_ref(&ibm_crt)).is_ok());
|
||||
assert!(matches!(
|
||||
super::get_ibm_z_sign_key(&[ibm_crt.clone(), ibm_crt.clone()]),
|
||||
Err(Error::HkdVerify(ManyIbmSignKeys))
|
||||
));
|
||||
assert!(matches!(
|
||||
super::get_ibm_z_sign_key(&[ibm_wrong_subj]),
|
||||
super::get_ibm_z_sign_key(std::slice::from_ref(&ibm_wrong_subj)),
|
||||
Err(Error::HkdVerify(NoIbmSignKey))
|
||||
));
|
||||
assert!(matches!(
|
||||
super::get_ibm_z_sign_key(&[no_sign_crt.clone()]),
|
||||
super::get_ibm_z_sign_key(std::slice::from_ref(&no_sign_crt)),
|
||||
Err(Error::HkdVerify(NoIbmSignKey))
|
||||
));
|
||||
assert!(super::get_ibm_z_sign_key(&[ibm_crt, no_sign_crt]).is_ok(),);
|
||||
|
||||
Reference in New Issue
Block a user