Skip to content

Commit 7b047a3

Browse files
src/fsverity: drop support for SHA-256
Just to prove that we can. This is going to make the unit tests fail but the examples still ought to work...
1 parent b9e0387 commit 7b047a3

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/fsverity/hashvalue.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::{fmt, hash::Hash};
22

33
use hex::FromHexError;
4-
use sha2::{digest::FixedOutputReset, digest::Output, Digest, Sha256, Sha512};
4+
use sha2::{digest::FixedOutputReset, digest::Output, Digest, Sha512};
55
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned};
66

77
pub trait FsVerityHashValue
@@ -74,35 +74,12 @@ where
7474
}
7575
}
7676

77-
impl fmt::Debug for Sha256HashValue {
78-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79-
write!(f, "sha256:{}", self.to_hex())
80-
}
81-
}
82-
8377
impl fmt::Debug for Sha512HashValue {
8478
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8579
write!(f, "sha512:{}", self.to_hex())
8680
}
8781
}
8882

89-
#[derive(Clone, Eq, FromBytes, Hash, Immutable, IntoBytes, KnownLayout, PartialEq, Unaligned)]
90-
#[repr(C)]
91-
pub struct Sha256HashValue([u8; 32]);
92-
93-
impl From<Output<Sha256>> for Sha256HashValue {
94-
fn from(value: Output<Sha256>) -> Self {
95-
Self(value.into())
96-
}
97-
}
98-
99-
impl FsVerityHashValue for Sha256HashValue {
100-
type Digest = Sha256;
101-
const ALGORITHM: u8 = 1;
102-
const EMPTY: Self = Self([0; 32]);
103-
const ID: &str = "sha256";
104-
}
105-
10683
#[derive(Clone, Eq, FromBytes, Hash, Immutable, IntoBytes, KnownLayout, PartialEq, Unaligned)]
10784
#[repr(C)]
10885
pub struct Sha512HashValue([u8; 64]);

src/fsverity/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{io::Error, os::fd::AsFd};
66

77
use thiserror::Error;
88

9-
pub use hashvalue::{FsVerityHashValue, Sha256HashValue, Sha512HashValue};
9+
pub use hashvalue::{FsVerityHashValue, Sha512HashValue};
1010

1111
/// Measuring fsverity failed.
1212
#[derive(Error, Debug)] // can't derive PartialEq because of std::io::Error

0 commit comments

Comments
 (0)