diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..56d4a93 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust-crypto-tests" +version = "0.1.0" +edition = "2021" + +[dependencies] +rand = "0.8.5" +rsa = "0.9.7" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..54ad01e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,21 @@ +use rsa::{RsaPrivateKey, RsaPublicKey}; +use std::time::Instant; +use rand::rngs::OsRng; + +fn generate_rsa_keys(count: usize, key_size: usize) -> Vec<(RsaPrivateKey, RsaPublicKey)> { + let mut rng = OsRng; + (0..count) + .map(|_| { + let private_key = RsaPrivateKey::new(&mut rng, key_size).expect("Failed to generate a key"); + let public_key = RsaPublicKey::from(&private_key); + (private_key, public_key) + }) + .collect() +} + +fn main() { + let start = Instant::now(); + generate_rsa_keys(10, 2048); + let duration = start.elapsed(); + println!("Execution time: {:?}", duration); +}