1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum KdfAlgorithm {
9 Argon2id,
11 Pbkdf2,
13 ConcatKdf,
15 Kmac256,
17}
18
19impl core::fmt::Display for KdfAlgorithm {
20 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
21 let detail = match self {
22 KdfAlgorithm::Argon2id => "Argon2id",
23 KdfAlgorithm::Pbkdf2 => "PBKDF2",
24 KdfAlgorithm::ConcatKdf => "Concat KDF",
25 KdfAlgorithm::Kmac256 => "KMAC256",
26 };
27 write!(f, "{detail}")
28 }
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33#[non_exhaustive]
34pub enum KdfProfile {
35 Argon2idV1,
37 Argon2idV2,
39 Pbkdf2HmacSha256,
41 Pbkdf2HmacSha512,
43 JwaEcdhEsSha256,
45 Sp800185Kmac256,
47}
48
49impl core::fmt::Display for KdfProfile {
50 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
51 let detail = match self {
52 KdfProfile::Argon2idV1 => "Argon2id v1",
53 KdfProfile::Argon2idV2 => "Argon2id v2",
54 KdfProfile::Pbkdf2HmacSha256 => "PBKDF2-HMAC-SHA-256",
55 KdfProfile::Pbkdf2HmacSha512 => "PBKDF2-HMAC-SHA-512",
56 KdfProfile::JwaEcdhEsSha256 => "JWA ECDH-ES Concat KDF SHA-256",
57 KdfProfile::Sp800185Kmac256 => "SP 800-185 KMAC256",
58 };
59 write!(f, "{detail}")
60 }
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq)]
65#[non_exhaustive]
66pub enum KdfFailureKind {
67 InvalidSecretLength,
69 InvalidSaltLength,
71 InvalidOutputLength,
73 InvalidIterationCount,
75 InvalidParams,
77 DerivationFailed,
79}
80
81impl core::fmt::Display for KdfFailureKind {
82 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83 let detail = match self {
84 KdfFailureKind::InvalidSecretLength => "invalid secret length",
85 KdfFailureKind::InvalidSaltLength => "invalid salt length",
86 KdfFailureKind::InvalidOutputLength => "invalid output length",
87 KdfFailureKind::InvalidIterationCount => "invalid iteration count",
88 KdfFailureKind::InvalidParams => "invalid parameters",
89 KdfFailureKind::DerivationFailed => "derivation failed",
90 };
91 write!(f, "{detail}")
92 }
93}
94
95#[derive(Debug, Clone, Copy, PartialEq, Eq)]
97#[non_exhaustive]
98pub enum HkdfHash {
99 Sha2_256,
101 Sha2_384,
103 Sha3_256,
105}
106
107impl core::fmt::Display for HkdfHash {
108 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
109 let detail = match self {
110 HkdfHash::Sha2_256 => "SHA2-256",
111 HkdfHash::Sha2_384 => "SHA2-384",
112 HkdfHash::Sha3_256 => "SHA3-256",
113 };
114 write!(f, "{detail}")
115 }
116}
117
118#[derive(Debug, Clone, Copy, PartialEq, Eq)]
120#[non_exhaustive]
121pub enum HkdfFailureKind {
122 InvalidIkmLength,
124 InvalidDomainTagLength,
126 InvalidDomainTagByte,
128 LengthOverflow,
130 InvalidOutputLength,
132 ExpandFailed,
134}
135
136impl core::fmt::Display for HkdfFailureKind {
137 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
138 let detail = match self {
139 HkdfFailureKind::InvalidIkmLength => "invalid input key material length",
140 HkdfFailureKind::InvalidDomainTagLength => "invalid domain tag length",
141 HkdfFailureKind::InvalidDomainTagByte => "invalid domain tag byte",
142 HkdfFailureKind::LengthOverflow => "length overflow",
143 HkdfFailureKind::InvalidOutputLength => "invalid output length",
144 HkdfFailureKind::ExpandFailed => "expand failed",
145 };
146 write!(f, "{detail}")
147 }
148}