Skip to main content

auths_core/crypto/
mod.rs

1//! Cryptographic primitives.
2
3pub mod encryption;
4pub mod provider_bridge;
5pub mod said;
6pub mod signer;
7pub mod ssh;
8
9#[cfg(feature = "crypto-secp256k1")]
10pub mod secp256k1;
11
12pub use said::{compute_next_commitment, compute_said, verify_commitment};
13pub use signer::SignerKey;
14
15#[cfg(feature = "crypto-secp256k1")]
16pub use secp256k1::Secp256k1KeyPair;
17
18/// Supported encryption algorithms for keypair encryption.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum EncryptionAlgorithm {
21    /// AES-256-GCM encryption (default tier).
22    AesGcm256,
23    /// ChaCha20-Poly1305 encryption (pro tier).
24    ChaCha20Poly1305,
25}
26
27impl EncryptionAlgorithm {
28    /// Returns the numeric tag byte for this algorithm.
29    pub fn tag(&self) -> u8 {
30        match self {
31            EncryptionAlgorithm::AesGcm256 => 1,
32            EncryptionAlgorithm::ChaCha20Poly1305 => 2,
33        }
34    }
35
36    /// Parse an algorithm from its numeric tag byte.
37    pub fn from_tag(tag: u8) -> Option<Self> {
38        match tag {
39            1 => Some(EncryptionAlgorithm::AesGcm256),
40            2 => Some(EncryptionAlgorithm::ChaCha20Poly1305),
41            _ => None,
42        }
43    }
44}