oxedyne/fe2o3/fe2o3_crypto/src/lib.rs
2.8 KiB, 27 runs
created by r1870400018:234, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! This crate provides cryptographic primitives and implementations focused on post-quantum security. |
| 2 | //! |
| 3 | //! With the advent of quantum computers, many widely-used cryptographic algorithms based on |
| 4 | //! classical hard problems like integer factorisation will become vulnerable. This crate |
| 5 | //! implements quantum-resistant schemes that were selected as finalists in the NIST Post-Quantum |
| 6 | //! Cryptography standardisation process. |
| 7 | //! |
| 8 | //! # Key Features |
| 9 | //! |
| 10 | //! - SABER key encapsulation mechanism (KEM) for quantum-resistant key exchange |
| 11 | //! - Includes LightSaber, Saber and FireSaber variants |
| 12 | //! - Pure Rust and C reference implementations |
| 13 | //! - Constant-time operations where possible |
| 14 | //! |
| 15 | //! - Dilithium digital signature scheme for quantum-resistant signatures |
| 16 | //! - Pure Rust implementation |
| 17 | //! - Based on module lattice problems |
| 18 | //! - Configurable security levels |
| 19 | //! |
| 20 | //! - Classical cryptographic primitives |
| 21 | //! - AES-256-GCM for symmetric encryption |
| 22 | //! - Ed25519 for classical digital signatures |
| 23 | //! |
| 24 | //! - Generic traits and types |
| 25 | //! - `EncryptionScheme` for symmetric encryption |
| 26 | //! - `KeyExchangeScheme` for key exchange/encapsulation |
| 27 | //! - `SignatureScheme` for digital signatures |
| 28 | //! - Safe key management with `Keys` type |
| 29 | //! |
| 30 | //! The implementations aim to be memory safe and avoid panics while maintaining efficiency. |
| 31 | //! Post-quantum schemes are implemented based on reference implementations and validated against |
| 32 | //! test vectors. |
| 33 | //! |
| 34 | //! # Example Usage |
| 35 | //! |
| 36 | //! ```ignore |
| 37 | //! use oxedyne_fe2o3_crypto::{EncryptionScheme, SignatureScheme}; |
| 38 | //! use oxedyne_fe2o3_core::prelude::*; |
| 39 | //! |
| 40 | //! // Create a post-quantum signature scheme |
| 41 | //! let scheme = res!(SignatureScheme::new_dilithium2()); |
| 42 | //! |
| 43 | //! // Sign a message |
| 44 | //! let message = b"Hello, post-quantum world!"; |
| 45 | //! let signature = res!(scheme.sign(message)); |
| 46 | //! |
| 47 | //! // Verify the signature |
| 48 | //! assert!(res!(scheme.verify(message, &signature))); |
| 49 | //! |
| 50 | //#![forbid(unsafe_code)] // Unfortunately need to remove for c interop. TODO Rust all the things! |
| 51 | #![allow(non_upper_case_globals)] |
| 52 | #![allow(non_camel_case_types)] |
| 53 | #![allow(non_snake_case)] |
| 54 | //#![allow(unused)] |
| 55 | |
| 56 | // The bindings bindgen generated for the SABER C reference implementation. There are none without |
| 57 | // the `pq` feature, because there is no C build without it. |
| 58 | #[cfg(feature = "pq")] |
| 59 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
| 60 | |
| 61 | //#[macro_use] |
| 62 | //pub mod macros_dilithium; |
| 63 | //pub mod macros_saber; |
| 64 | |
| 65 | pub mod agree; |
| 66 | pub mod command; |
| 67 | pub mod credential; |
| 68 | pub mod enc; |
| 69 | /// The SABER key exchange, which rests on the C reference implementation. |
| 70 | #[cfg(feature = "pq")] |
| 71 | pub mod kem; |
| 72 | pub mod keys; |
| 73 | pub mod keystore; |
| 74 | pub mod linkring; |
| 75 | #[cfg(feature = "p256")] |
| 76 | pub mod p256; |
| 77 | pub mod pqc; |
| 78 | pub mod scheme; |
| 79 | pub mod sign; |
| 80 | //pub mod wasm; |
| 81 | |
| 82 | use oxedyne_fe2o3_jdat::version::SemVer; |
| 83 | |
| 84 | pub const VERSION: SemVer = SemVer::new(0,0,1); |