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::P384
82 | Algorithm::P521
83 | Algorithm::MlKem512
84 | Algorithm::MlKem768
85 | Algorithm::MlKem1024
86 | Algorithm::XWing768
87 | Algorithm::XWing1024
88 )
89 }
90}
91
92impl core::fmt::Display for Algorithm {
93 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
94 write!(f, "{}", self.as_str())
95 }
96}
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
100pub enum AeadAlgorithm {
101 Aes128Gcm,
103 Aes192Gcm,
105 Aes256Gcm,
107 Aes256GcmSiv,
109 ChaCha20Poly1305,
111 XChaCha20Poly1305,
113}
114
115impl AeadAlgorithm {
116 pub fn as_str(self) -> &'static str {
118 match self {
119 AeadAlgorithm::Aes128Gcm => "AES-128-GCM",
120 AeadAlgorithm::Aes192Gcm => "AES-192-GCM",
121 AeadAlgorithm::Aes256Gcm => "AES-256-GCM",
122 AeadAlgorithm::Aes256GcmSiv => "AES-256-GCM-SIV",
123 AeadAlgorithm::ChaCha20Poly1305 => "ChaCha20-Poly1305",
124 AeadAlgorithm::XChaCha20Poly1305 => "XChaCha20-Poly1305",
125 }
126 }
127}
128
129impl core::fmt::Display for AeadAlgorithm {
130 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
131 write!(f, "{}", self.as_str())
132 }
133}
134
135#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
137pub enum HashAlgorithm {
138 Sha2_256,
140 Sha2_384,
142 Sha2_512,
144 Sha3_224,
146 Sha3_256,
148 Sha3_384,
150 Sha3_512,
152}
153
154impl HashAlgorithm {
155 pub fn as_str(self) -> &'static str {
157 match self {
158 HashAlgorithm::Sha2_256 => "SHA2-256",
159 HashAlgorithm::Sha2_384 => "SHA2-384",
160 HashAlgorithm::Sha2_512 => "SHA2-512",
161 HashAlgorithm::Sha3_224 => "SHA3-224",
162 HashAlgorithm::Sha3_256 => "SHA3-256",
163 HashAlgorithm::Sha3_384 => "SHA3-384",
164 HashAlgorithm::Sha3_512 => "SHA3-512",
165 }
166 }
167}
168
169impl core::fmt::Display for HashAlgorithm {
170 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
171 write!(f, "{}", self.as_str())
172 }
173}
174
175#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
177pub enum MacAlgorithm {
178 HmacSha256,
180 HmacSha512,
182}
183
184impl MacAlgorithm {
185 pub fn as_str(self) -> &'static str {
187 match self {
188 MacAlgorithm::HmacSha256 => "HMAC-SHA-256",
189 MacAlgorithm::HmacSha512 => "HMAC-SHA-512",
190 }
191 }
192}
193
194impl core::fmt::Display for MacAlgorithm {
195 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
196 write!(f, "{}", self.as_str())
197 }
198}