quantum_shield/
lib.rs

1//! # Quantum Shield
2//!
3//! Hybrid quantum-resistant cryptography library using NIST-standardized post-quantum algorithms.
4//!
5//! ## Features
6//!
7//! - Hybrid Encryption: RSA-4096 + Kyber-1024 (NIST Level 5)
8//! - Hybrid Signatures: RSA-4096-PSS + Dilithium5 (NIST Level 5)
9//! - Defense in Depth: Multiple independent security layers
10//! - Automatic Failover: Falls back to Kyber if RSA decryption fails
11//!
12//! ## Quick Example
13//!
14//! ```no_run
15//! use quantum_shield::{HybridCrypto, Result};
16//!
17//! # fn main() -> Result<()> {
18//! // Generate keypairs for Alice and Bob
19//! let alice = HybridCrypto::generate_keypair()?;
20//! let bob = HybridCrypto::generate_keypair()?;
21//!
22//! // Alice encrypts a message for Bob
23//! let message = b"Secret quantum-resistant message";
24//! let encrypted = alice.encrypt(message, &bob.public_keys())?;
25//!
26//! // Bob decrypts the message
27//! let decrypted = bob.decrypt(&encrypted)?;
28//! assert_eq!(message, &decrypted[..]);
29//! # Ok(())
30//! # }
31//! ```
32
33#![doc(html_root_url = "https://docs.rs/quantum-shield/0.1.0")]
34#![warn(missing_docs, rust_2018_idioms)]
35#![cfg_attr(docsrs, feature(doc_cfg))]
36
37mod constants;
38mod crypto;
39mod error;
40mod keys;
41mod types;
42mod security;
43
44pub use constants::*;
45pub use crypto::HybridCrypto;
46pub use error::{Error, Result};
47pub use keys::{PublicKeys, PrivateKeys, KeyPair};
48pub use types::{HybridCiphertext, HybridSignature, CryptoVersion};
49pub use security::{
50    SecurityManager, EntropyMonitor, TimingProtection, SecureMemory,
51    AlgorithmAgility, SecurityAuditResult, constant_time_compare,
52    constant_time_select
53};
54
55/// Re-export commonly used types
56pub mod prelude {
57    pub use crate::{HybridCrypto, PublicKeys, PrivateKeys, KeyPair, Result};
58    pub use crate::{HybridCiphertext, HybridSignature};
59}
60
61#[cfg(test)]
62mod tests {
63    use super::*;
64
65    #[test]
66    fn test_basic_encryption() {
67        let alice = HybridCrypto::generate_keypair().unwrap();
68        let bob = HybridCrypto::generate_keypair().unwrap();
69
70        let message = b"Test message";
71        let encrypted = alice.encrypt(message, &bob.public_keys()).unwrap();
72        let decrypted = bob.decrypt(&encrypted).unwrap();
73
74        assert_eq!(message, &decrypted[..]);
75    }
76
77    #[test]
78    fn test_basic_signature() {
79        let alice = HybridCrypto::generate_keypair().unwrap();
80
81        let message = b"Message to sign";
82        let signature = alice.sign(message).unwrap();
83        let valid = HybridCrypto::verify(message, &signature, &alice.public_keys()).unwrap();
84
85        assert!(valid);
86    }
87}
88