diff --git a/x-wing/Cargo.toml b/x-wing/Cargo.toml index 129c46d..1c26b42 100644 --- a/x-wing/Cargo.toml +++ b/x-wing/Cargo.toml @@ -11,9 +11,12 @@ readme = "README.md" homepage = "https://github.com/RustCrypto/KEMs/tree/master/x-wing" repository = "https://github.com/RustCrypto/KEMs/tree/master/x-wing" categories = ["cryptography", "no-std"] -keywords = ["crypto", "x-wing-kem", "x-wing", "xwing", "kem", "post-quantum"] +keywords = ["crypto", "x-wing", "xwing", "kem", "post-quantum"] exclude = ["src/test-vectors.json"] +[features] +getrandom = ["rand_core/getrandom"] + [lints.clippy] pedantic = "warn" # Be pedantic by default similar_names = { level = "allow", priority = 1 } # So we can use the names as in the RFC diff --git a/x-wing/src/lib.rs b/x-wing/src/lib.rs index 8257eda..ee1fe34 100644 --- a/x-wing/src/lib.rs +++ b/x-wing/src/lib.rs @@ -115,6 +115,12 @@ pub struct DecapsulationKey { } impl DecapsulationKey { + /// Generate a new `DecapsulationKey` using `OsRng` + #[cfg(feature = "getrandom")] + pub fn generate_rng() -> DecapsulationKey { + Self::generate(&mut rand_core::OsRng) + } + /// Generate a new `DecapsulationKey` using the provided RNG pub fn generate(rng: &mut impl CryptoRngCore) -> DecapsulationKey { let sk = generate(rng); @@ -211,6 +217,12 @@ impl From<&[u8; 1120]> for Ciphertext { } } +/// Generate a X-Wing key pair using a the `OsRng` +#[cfg(feature = "getrandom")] +pub fn generate_key_pair_rng() -> (DecapsulationKey, EncapsulationKey) { + generate_key_pair(&mut rand_core::OsRng) +} + /// Generate a X-Wing key pair pub fn generate_key_pair(rng: &mut impl CryptoRngCore) -> (DecapsulationKey, EncapsulationKey) { let sk = DecapsulationKey::generate(rng);