Skip to content

Commit

Permalink
add factorization attack on RSA
Browse files Browse the repository at this point in the history
  • Loading branch information
gogo2464 committed Jan 22, 2024
1 parent f53fbcf commit a1bb162
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-tests-stable-rust.yml
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:
Expand Down
9 changes: 8 additions & 1 deletion cryptatools-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ itertools = "*"
uniffi_bindgen = "*"
time = "*"
rand = "*"
num-bigint = "*"
num-traits = "*"
num = "*"
num-bigfloat = "*"
num-bigint = { version = "*", features = [] } #"prime", "rand"
num-bigint-dig = { version = "*", features = ["prime", "rand"], default-features=false }
num-integer = "*"

indicatif = { version = "0.17", optional = true }
primal = "0.3"
thiserror = "1"


[build-dependencies]
uniffi = {version = "*", features = [ "build", "cli" ]}
Expand Down
3 changes: 2 additions & 1 deletion cryptatools-core/src/cryptanalysis/common/rsa/mod.rs
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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`

Check warning on line 4 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `BigUint`
use num_bigint_dig::ModInverse;

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`

Check warning on line 5 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::ModInverse`
use num_bigint_dig::prime::probably_prime;

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`

Check warning on line 6 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::prime::probably_prime`
//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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`

Check warning on line 8 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint_dig::RandBigInt`
use num_traits::Pow;

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`

Check warning on line 9 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_traits::Pow`
use num_integer::Integer;

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

Check warning on line 10 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_integer::Integer`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

Check warning on line 18 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::utils::convert::Encode`

pub struct modulo_factorisation_attack {

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name

Check warning on line 20 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

type `modulo_factorisation_attack` should have an upper camel case name
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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment

Check warning on line 32 in cryptatools-core/src/cryptanalysis/common/rsa/public_exponent_attack.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused doc comment
/// 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();
}
}
1 change: 1 addition & 0 deletions cryptatools-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod cryptanalysis;
pub mod cryptography;
pub mod utils;
pub mod maths;

use crate::utils::alphabets::{Encoding, Alphabet, split_bytes_by_characters_representation, uniffy_opcode_group};
use crate::cryptography::classical::encryption::monoalphabetic_ciphers::caesar_number::CaesarNumberAlgorithm;
Expand Down
38 changes: 38 additions & 0 deletions cryptatools-core/src/maths/factorization.rs
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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`

Check warning on line 1 in cryptatools-core/src/maths/factorization.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `num_bigint::BigUint`
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
}
}


1 change: 1 addition & 0 deletions cryptatools-core/src/maths/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod factorization;

0 comments on commit a1bb162

Please sign in to comment.