Skip to main content

hkdf/
errors.rs

1use core::fmt;
2
3/// Error that is returned when supplied pseudorandom key (PRK) is not long enough.
4#[derive(Copy, Clone, Debug)]
5pub struct InvalidPrkLength;
6
7impl fmt::Display for InvalidPrkLength {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
9        f.write_str("invalid pseudorandom key length, too short")
10    }
11}
12
13impl core::error::Error for InvalidPrkLength {}
14
15/// Structure for `InvalidLength`, used for output error handling.
16#[derive(Copy, Clone, Debug)]
17pub struct InvalidLength;
18
19impl fmt::Display for InvalidLength {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
21        f.write_str("invalid number of blocks, too large output")
22    }
23}
24
25impl core::error::Error for InvalidLength {}