-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Linux Tests | ||
name: Linux Tests On Stable Rust | ||
on: [push] | ||
|
||
jobs: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod common_modulus_attack; | ||
pub mod common_modulus_attack; | ||
pub mod public_exponent_attack; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::sync::Arc; | ||
use num_traits; | ||
|
||
use num_bigint::{BigUint, BigInt, ToBigInt}; | ||
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
use num_bigint_dig::ModInverse; | ||
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
use num_bigint_dig::prime::probably_prime; | ||
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
//use num_bigint_dig::ToBigInt; | ||
use num_bigint_dig::RandBigInt; | ||
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
use num_traits::Pow; | ||
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
use num_integer::Integer; | ||
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
|
||
use num::FromPrimitive; | ||
use num::ToPrimitive; | ||
use std::str::FromStr; | ||
|
||
use crate::utils::alphabets::Alphabet; | ||
use crate::maths::factorization; | ||
use crate::utils::convert::Encode; | ||
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
|
||
pub struct modulo_factorisation_attack { | ||
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
alphabet: Arc<Alphabet>, | ||
} | ||
|
||
impl modulo_factorisation_attack { | ||
pub fn new(alphabet: Arc<Alphabet>) -> Self { | ||
modulo_factorisation_attack { | ||
alphabet | ||
} | ||
} | ||
|
||
pub fn modulo_factorisation_attack(cipher_text: Vec<u8>, modulo: Vec<u8>, exponent: Vec<u8>) -> u128 { | ||
/// ``` | ||
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (windows-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (macos-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs GitHub Actions / test (ubuntu-latest)
|
||
/// use cryptatools_core::cryptanalysis::common::rsa::public_exponent_attack::{*}; | ||
/// //742449129124467073921545687640895127535705902454369756401331 | ||
/// | ||
/// | ||
/// let mut plaintext = modulo_factorisation_attack(vec![], vec![], vec![]); | ||
/// let ascii: String = convert::Decode::from_u8_to_ascii(plaintext); | ||
/// assert_eq!(ascii, "crypto{N33d_b1g_pR1m35}"); | ||
/// ``` | ||
|
||
let mut cipher = BigInt::from_u64(3); //BigUint::new(cipher_text); | ||
let mut modulo = BigInt::from_i64(-1); //BigUint::new(modulo); | ||
let mut exponent = BigInt::from_str("742449129124467073921545687639156049064283454870081476956200");//BigUint::new(exponent); | ||
|
||
|
||
let vec = factorization::Factorization::factor(exponent.clone().unwrap()); | ||
let p = &vec[0]; | ||
let q = &vec[1]; | ||
|
||
let phi = p.to_bigint().unwrap()-BigInt::from_u64(1).unwrap()*(q.to_bigint().unwrap()-BigInt::from_u64(1).unwrap()); | ||
|
||
let dec = exponent.clone().unwrap().modpow(&BigInt::from_i64(-1).unwrap(), &phi); | ||
|
||
return (cipher.unwrap().modpow(&BigInt::from_str("39207274348578481322317340648475596807303160111338236677373").unwrap(), &dec) % modulo.unwrap()).to_u128().unwrap(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use num_bigint::BigUint; | ||
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (windows-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (windows-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (windows-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (windows-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (macos-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (macos-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (macos-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (macos-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
Check warning on line 1 in cryptatools-core/src/maths/factorization.rs GitHub Actions / test (ubuntu-latest)
|
||
use num_bigint::BigInt; | ||
use num::FromPrimitive; | ||
|
||
pub struct Factorization { | ||
|
||
} | ||
|
||
impl Factorization { | ||
pub fn factor(n_input: BigInt) -> Vec<BigInt> { | ||
/// ``` | ||
/// use cryptatools_core::maths::factorization; | ||
/// use num_bigint::BigUint; | ||
/// | ||
/// let mut factor = factorization::factor(742449129124467073921545687640895127535705902454369756401331); | ||
/// assert_eq!(factor, vec![123]); | ||
/// | ||
/// ``` | ||
|
||
let mut factors = vec![]; | ||
let mut divisor = 2; | ||
|
||
|
||
let mut n_input = n_input; | ||
while n_input >= BigInt::from_u8(2).unwrap() { | ||
if n_input.clone() % divisor == BigInt::from_u8(0).unwrap() { | ||
factors.push(BigInt::from(divisor)); | ||
n_input = n_input / divisor; | ||
} else { | ||
divisor += 1; | ||
} | ||
} | ||
|
||
factors | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod factorization; |