|
3 | 3 | use super::{Domain, ExpandMsg, Expander}; |
4 | 4 | use crate::{Error, Result}; |
5 | 5 | use core::{fmt, num::NonZero, ops::Mul}; |
6 | | -use digest::{ExtendableOutput, HashMarker, Update, XofReader}; |
| 6 | +use digest::{ |
| 7 | + CollisionResistance, ExtendableOutput, HashMarker, Update, XofReader, typenum::IsGreaterOrEqual, |
| 8 | +}; |
7 | 9 | use hybrid_array::{ |
8 | 10 | ArraySize, |
9 | 11 | typenum::{IsLess, Prod, True, U2, U256}, |
|
40 | 42 | // If DST is larger than 255 bytes, the length of the computed DST is calculated by `K * 2`. |
41 | 43 | // https://www.rfc-editor.org/rfc/rfc9380.html#section-5.3.1-2.1 |
42 | 44 | K: Mul<U2, Output: ArraySize + IsLess<U256, Output = True>>, |
| 45 | + // The collision resistance of `HashT` MUST be at least `K` bits. |
| 46 | + // https://www.rfc-editor.org/rfc/rfc9380.html#section-5.3.2-2.1 |
| 47 | + HashT: CollisionResistance<CollisionResistance: IsGreaterOrEqual<K, Output = True>>, |
43 | 48 | { |
44 | 49 | type Expander<'dst> = Self; |
45 | 50 |
|
@@ -114,7 +119,11 @@ mod test { |
114 | 119 | #[allow(clippy::panic_in_result_fn)] |
115 | 120 | fn assert<HashT, L>(&self, dst: &'static [u8], domain: &Domain<'_, U32>) -> Result<()> |
116 | 121 | where |
117 | | - HashT: Default + ExtendableOutput + Update + HashMarker, |
| 122 | + HashT: Default |
| 123 | + + ExtendableOutput |
| 124 | + + Update |
| 125 | + + HashMarker |
| 126 | + + CollisionResistance<CollisionResistance: IsGreaterOrEqual<U16, Output = True>>, |
118 | 127 | L: ArraySize, |
119 | 128 | { |
120 | 129 | assert_message(self.msg, domain, L::to_u16(), self.msg_prime); |
|
0 commit comments