Skip to main content

ever_crypto/
lib.rs

1//! Ever Crypto - Simple cryptographic APIs for XChaCha20Poly1305 and Kyber1024
2//! 
3//! This library provides easy-to-use wrappers around:
4//! - XChaCha20Poly1305: Authenticated encryption with extended nonce
5//! - Kyber1024: Post-quantum key encapsulation mechanism
6
7pub mod xchacha;
8pub mod kyber;
9
10// Re-export main types for convenience
11pub use xchacha::{XChaChaCrypto, XChaChaKey, XChaChaNonce};
12pub use kyber::{KyberCrypto, KyberKeyPair, KyberPublicKey, KyberSecretKey, KyberSharedSecret};
13
14use thiserror::Error;
15
16/// Common error types for the library
17#[derive(Error, Debug)]
18pub enum CryptoError {
19    #[error("Encryption failed: {0}")]
20    EncryptionError(String),
21    
22    #[error("Decryption failed: {0}")]
23    DecryptionError(String),
24    
25    #[error("Invalid key length: expected {expected}, got {actual}")]
26    InvalidKeyLength { expected: usize, actual: usize },
27    
28    #[error("Invalid nonce length: expected {expected}, got {actual}")]
29    InvalidNonceLength { expected: usize, actual: usize },
30    
31    #[error("Random number generation failed")]
32    RngError,
33}
34
35pub type Result<T> = std::result::Result<T, CryptoError>;