1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum Algorithm {
8 Ed25519,
10 X25519,
12 P256,
14 P384,
16 P521,
18 Secp256k1,
20 MlDsa44,
22 MlDsa65,
24 MlDsa87,
26 MlKem512,
28 MlKem768,
30 MlKem1024,
32 XWing768,
34 XWing1024,
36}
37
38impl Algorithm {
39 pub fn as_str(self) -> &'static str {
42 match self {
43 Algorithm::Ed25519 => "Ed25519",
44 Algorithm::X25519 => "X25519",
45 Algorithm::P256 => "P-256",
46 Algorithm::P384 => "P-384",
47 Algorithm::P521 => "P-521",
48 Algorithm::Secp256k1 => "secp256k1",
49 Algorithm::MlDsa44 => "ML-DSA-44",
50 Algorithm::MlDsa65 => "ML-DSA-65",
51 Algorithm::MlDsa87 => "ML-DSA-87",
52 Algorithm::MlKem512 => "ML-KEM-512",
53 Algorithm::MlKem768 => "ML-KEM-768",
54 Algorithm::MlKem1024 => "ML-KEM-1024",
55 Algorithm::XWing768 => "X-Wing-768",
56 Algorithm::XWing1024 => "X-Wing-1024",
57 }
58 }
59
60 pub fn is_signature(self) -> bool {
62 matches!(
63 self,
64 Algorithm::Ed25519
65 | Algorithm::P256
66 | Algorithm::P384
67 | Algorithm::P521
68 | Algorithm::Secp256k1
69 | Algorithm::MlDsa44
70 | Algorithm::MlDsa65
71 | Algorithm::MlDsa87
72 )
73 }
74
75 pub fn is_key_agreement(self) -> bool {
77 matches!(
78 self,
79 Algorithm::X25519
80 | Algorithm::P256
81 | Algorithm::MlKem512
82 | Algorithm::MlKem768
83 | Algorithm::MlKem1024
84 | Algorithm::XWing768
85 | Algorithm::XWing1024
86 )
87 }
88}
89
90impl core::fmt::Display for Algorithm {
91 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
92 write!(f, "{}", self.as_str())
93 }
94}
95
96#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
98pub enum AeadAlgorithm {
99 Aes256Gcm,
101 Aes256GcmSiv,
103 ChaCha20Poly1305,
105 XChaCha20Poly1305,
107}
108
109impl AeadAlgorithm {
110 pub fn as_str(self) -> &'static str {
112 match self {
113 AeadAlgorithm::Aes256Gcm => "AES-256-GCM",
114 AeadAlgorithm::Aes256GcmSiv => "AES-256-GCM-SIV",
115 AeadAlgorithm::ChaCha20Poly1305 => "ChaCha20-Poly1305",
116 AeadAlgorithm::XChaCha20Poly1305 => "XChaCha20-Poly1305",
117 }
118 }
119}
120
121impl core::fmt::Display for AeadAlgorithm {
122 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
123 write!(f, "{}", self.as_str())
124 }
125}
126
127#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
129pub enum HashAlgorithm {
130 Sha2_256,
132 Sha2_384,
134 Sha2_512,
136 Sha3_224,
138 Sha3_256,
140 Sha3_384,
142 Sha3_512,
144}
145
146impl HashAlgorithm {
147 pub fn as_str(self) -> &'static str {
149 match self {
150 HashAlgorithm::Sha2_256 => "SHA2-256",
151 HashAlgorithm::Sha2_384 => "SHA2-384",
152 HashAlgorithm::Sha2_512 => "SHA2-512",
153 HashAlgorithm::Sha3_224 => "SHA3-224",
154 HashAlgorithm::Sha3_256 => "SHA3-256",
155 HashAlgorithm::Sha3_384 => "SHA3-384",
156 HashAlgorithm::Sha3_512 => "SHA3-512",
157 }
158 }
159}
160
161impl core::fmt::Display for HashAlgorithm {
162 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
163 write!(f, "{}", self.as_str())
164 }
165}
166
167#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
169pub enum MacAlgorithm {
170 HmacSha256,
172 HmacSha512,
174}
175
176impl MacAlgorithm {
177 pub fn as_str(self) -> &'static str {
179 match self {
180 MacAlgorithm::HmacSha256 => "HMAC-SHA-256",
181 MacAlgorithm::HmacSha512 => "HMAC-SHA-512",
182 }
183 }
184}
185
186impl core::fmt::Display for MacAlgorithm {
187 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
188 write!(f, "{}", self.as_str())
189 }
190}