#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Algorithm {
Ed25519,
X25519,
P256,
P384,
P521,
Secp256k1,
MlDsa44,
MlDsa65,
MlDsa87,
MlKem512,
MlKem768,
MlKem1024,
XWing768,
XWing1024,
}
impl Algorithm {
pub fn as_str(self) -> &'static str {
match self {
Algorithm::Ed25519 => "Ed25519",
Algorithm::X25519 => "X25519",
Algorithm::P256 => "P-256",
Algorithm::P384 => "P-384",
Algorithm::P521 => "P-521",
Algorithm::Secp256k1 => "secp256k1",
Algorithm::MlDsa44 => "ML-DSA-44",
Algorithm::MlDsa65 => "ML-DSA-65",
Algorithm::MlDsa87 => "ML-DSA-87",
Algorithm::MlKem512 => "ML-KEM-512",
Algorithm::MlKem768 => "ML-KEM-768",
Algorithm::MlKem1024 => "ML-KEM-1024",
Algorithm::XWing768 => "X-Wing-768",
Algorithm::XWing1024 => "X-Wing-1024",
}
}
pub fn is_signature(self) -> bool {
matches!(
self,
Algorithm::Ed25519
| Algorithm::P256
| Algorithm::P384
| Algorithm::P521
| Algorithm::Secp256k1
| Algorithm::MlDsa44
| Algorithm::MlDsa65
| Algorithm::MlDsa87
)
}
pub fn is_key_agreement(self) -> bool {
matches!(
self,
Algorithm::X25519
| Algorithm::P256
| Algorithm::P384
| Algorithm::P521
| Algorithm::MlKem512
| Algorithm::MlKem768
| Algorithm::MlKem1024
| Algorithm::XWing768
| Algorithm::XWing1024
)
}
}
impl core::fmt::Display for Algorithm {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AeadAlgorithm {
Aes128Gcm,
Aes192Gcm,
Aes256Gcm,
Aes256GcmSiv,
ChaCha20Poly1305,
XChaCha20Poly1305,
}
impl AeadAlgorithm {
pub fn as_str(self) -> &'static str {
match self {
AeadAlgorithm::Aes128Gcm => "AES-128-GCM",
AeadAlgorithm::Aes192Gcm => "AES-192-GCM",
AeadAlgorithm::Aes256Gcm => "AES-256-GCM",
AeadAlgorithm::Aes256GcmSiv => "AES-256-GCM-SIV",
AeadAlgorithm::ChaCha20Poly1305 => "ChaCha20-Poly1305",
AeadAlgorithm::XChaCha20Poly1305 => "XChaCha20-Poly1305",
}
}
}
impl core::fmt::Display for AeadAlgorithm {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HashAlgorithm {
Sha2_256,
Sha2_384,
Sha2_512,
Sha3_224,
Sha3_256,
Sha3_384,
Sha3_512,
}
impl HashAlgorithm {
pub fn as_str(self) -> &'static str {
match self {
HashAlgorithm::Sha2_256 => "SHA2-256",
HashAlgorithm::Sha2_384 => "SHA2-384",
HashAlgorithm::Sha2_512 => "SHA2-512",
HashAlgorithm::Sha3_224 => "SHA3-224",
HashAlgorithm::Sha3_256 => "SHA3-256",
HashAlgorithm::Sha3_384 => "SHA3-384",
HashAlgorithm::Sha3_512 => "SHA3-512",
}
}
}
impl core::fmt::Display for HashAlgorithm {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacAlgorithm {
HmacSha256,
HmacSha512,
}
impl MacAlgorithm {
pub fn as_str(self) -> &'static str {
match self {
MacAlgorithm::HmacSha256 => "HMAC-SHA-256",
MacAlgorithm::HmacSha512 => "HMAC-SHA-512",
}
}
}
impl core::fmt::Display for MacAlgorithm {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}