Skip to content

add wrapper for ESDM & Jitter RNG #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions botan-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,14 @@ fn find_botan_include_dir() -> std::path::PathBuf {
for major in [3, 2] {
let lib_name = format!("botan-{}", major);

let statik = if cfg!(feature = "static") {
true
} else {
false
};
let statik = cfg!(feature = "static");

if let Ok(config) = pkg_config::Config::new().statik(statik).probe(&lib_name) {
return config.include_paths[0].clone();
}
}

panic!("Unable to find the headers corresponding with any supported version of Botan");
}

#[cfg(not(feature = "pkg-config"))]
Expand Down Expand Up @@ -206,7 +204,7 @@ fn find_botan_include_dir() -> std::path::PathBuf {
}
}

panic!("Unable to find the headers cooresponding with any supported version of Botan");
panic!("Unable to find the headers corresponding with any supported version of Botan");
}
}

Expand Down
6 changes: 5 additions & 1 deletion botan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ default = ["std"]
std = []
vendored = ["botan-sys/vendored"]
static = ["botan-sys/static"]
pkg-config = ["botan-sys/pkg-config"]
pkg-config = ["botan-sys/pkg-config"]

[lints.clippy]
# introduced because of from_str
should_implement_trait = "allow"
39 changes: 39 additions & 0 deletions botan/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ impl RandomNumberGenerator {
RandomNumberGenerator::new_of_type("system")
}

/// Create a new reference to the ESDM PRNG (fully seeded)
///
/// Availability of this RNG depends on botan being compiled
/// with ESDM support.
///
/// # Examples
/// ```ignore
/// let esdm_rng = botan::RandomNumberGenerator::new_esdm().unwrap();
/// ```
pub fn new_esdm() -> Result<RandomNumberGenerator> {
RandomNumberGenerator::new_of_type("esdm-full")
}

/// Create a new reference to the ESDM PRNG (with prediction resistance)
///
/// Availability of this RNG depends on botan being compiled
/// with ESDM support.
///
/// # Examples
/// ```ignore
/// let esdm_rng = botan::RandomNumberGenerator::new_esdm_pr().unwrap();
/// ```
pub fn new_esdm_pr() -> Result<RandomNumberGenerator> {
RandomNumberGenerator::new_of_type("esdm-pr")
}

/// Create a new reference to the Jitter RNG
///
/// Availability of this RNG depends on botan being compiled
/// with Jitter RNG support.
///
/// # Examples
/// ```ignore
/// let jitter_rng = botan::RandomNumberGenerator::new_jitter().unwrap();
/// ```
pub fn new_jitter() -> Result<RandomNumberGenerator> {
RandomNumberGenerator::new_of_type("jitter")
}

/// Create a new reference to an RNG of some arbitrary type
///
/// # Examples
Expand Down