|
1 | 1 | use core::{fmt, hash::Hash}; |
2 | 2 |
|
3 | 3 | use hex::FromHexError; |
4 | | -use sha2::{digest::FixedOutputReset, digest::Output, Digest, Sha256, Sha512}; |
| 4 | +use sha2::{digest::FixedOutputReset, digest::Output, Digest, Sha512}; |
5 | 5 | use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned}; |
6 | 6 |
|
7 | 7 | pub trait FsVerityHashValue |
@@ -74,35 +74,12 @@ where |
74 | 74 | } |
75 | 75 | } |
76 | 76 |
|
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 | | - |
83 | 77 | impl fmt::Debug for Sha512HashValue { |
84 | 78 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
85 | 79 | write!(f, "sha512:{}", self.to_hex()) |
86 | 80 | } |
87 | 81 | } |
88 | 82 |
|
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 | | - |
106 | 83 | #[derive(Clone, Eq, FromBytes, Hash, Immutable, IntoBytes, KnownLayout, PartialEq, Unaligned)] |
107 | 84 | #[repr(C)] |
108 | 85 | pub struct Sha512HashValue([u8; 64]); |
|
0 commit comments