From 42a91e54b612f382ba93c132f69acc4c21601430 Mon Sep 17 00:00:00 2001 From: Maciej Lebiest Date: Wed, 4 Dec 2024 19:13:42 +0100 Subject: [PATCH] initial commit --- Cargo.toml | 8 ++++++++ src/main.rs | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs 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); +}