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 ResourceLimitExceeded,
81}
82
83impl core::fmt::Display for KdfFailureKind {
84 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
85 let detail = match self {
86 KdfFailureKind::InvalidSecretLength => "invalid secret length",
87 KdfFailureKind::InvalidSaltLength => "invalid salt length",
88 KdfFailureKind::InvalidOutputLength => "invalid output length",
89 KdfFailureKind::InvalidIterationCount => "invalid iteration count",
90 KdfFailureKind::InvalidParams => "invalid parameters",
91 KdfFailureKind::ResourceLimitExceeded => "resource limit exceeded",
92 KdfFailureKind::DerivationFailed => "derivation failed",
93 };
94 write!(f, "{detail}")
95 }
96}
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq)]
100#[non_exhaustive]
101pub enum HkdfHash {
102 Sha2_256,
104 Sha2_384,
106 Sha3_256,
108}
109
110impl core::fmt::Display for HkdfHash {
111 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
112 let detail = match self {
113 HkdfHash::Sha2_256 => "SHA2-256",
114 HkdfHash::Sha2_384 => "SHA2-384",
115 HkdfHash::Sha3_256 => "SHA3-256",
116 };
117 write!(f, "{detail}")
118 }
119}
120
121#[derive(Debug, Clone, Copy, PartialEq, Eq)]
123#[non_exhaustive]
124pub enum HkdfFailureKind {
125 InvalidIkmLength,
127 InvalidDomainTagLength,
129 InvalidDomainTagByte,
131 LengthOverflow,
133 InvalidOutputLength,
135 ExpandFailed,
137}
138
139impl core::fmt::Display for HkdfFailureKind {
140 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
141 let detail = match self {
142 HkdfFailureKind::InvalidIkmLength => "invalid input key material length",
143 HkdfFailureKind::InvalidDomainTagLength => "invalid domain tag length",
144 HkdfFailureKind::InvalidDomainTagByte => "invalid domain tag byte",
145 HkdfFailureKind::LengthOverflow => "length overflow",
146 HkdfFailureKind::InvalidOutputLength => "invalid output length",
147 HkdfFailureKind::ExpandFailed => "expand failed",
148 };
149 write!(f, "{detail}")
150 }
151}