This commit is contained in:
Andrea Moro 2024-11-22 08:53:37 +01:00
parent b436e25188
commit 5ae2a09239

View file

@ -1,5 +1,5 @@
use colog; use colog;
use log::{info, error, warn}; use log::{error, info, warn};
use num::BigUint; use num::BigUint;
use num_primes::Generator; use num_primes::Generator;
use num_traits::cast::ToPrimitive; use num_traits::cast::ToPrimitive;
@ -24,8 +24,7 @@ impl RSA {
let n = &p_bigint * &q_bigint; let n = &p_bigint * &q_bigint;
let phi = let phi = (&p_bigint - BigUint::one()) * (&q_bigint - BigUint::one());
(&p_bigint - BigUint::one()) * (&q_bigint - BigUint::one());
let e = num::BigUint::from(65537u32); let e = num::BigUint::from(65537u32);
@ -90,8 +89,8 @@ fn main() {
let mut rsa_size: usize = get_input().trim().parse::<usize>().unwrap(); let mut rsa_size: usize = get_input().trim().parse::<usize>().unwrap();
if rsa_size < 1024 { if rsa_size < 1024 {
warn!("Invalid RSA Size, Defaulting to 1024"); warn!("Invalid RSA Size, Defaulting to 1024");
rsa_size = 1024; rsa_size = 1024;
} }
let rsa = RSA::new(rsa_size); let rsa = RSA::new(rsa_size);