Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rsa attacks #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linux Tests
name: Linux Tests On Rust Nightly Toolchain
on: [push]

jobs:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/linux-tests-on-stable-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Linux Tests On Rust Stable Toolchain
on: [push]

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on:
- ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features

- name: Install dependencies
run: |
pip install setuptools wheel

- name: Build cryptatools
run: cargo build --all

- name: Install cryptatools clis
run: cargo install --path ./cryptatools-cli

- name: Run tests
run: |
cargo test --all

- name: Generate documentation
run: |
cargo doc --package cryptatools-core --workspace --no-deps

- name: Build and install Python Bindings
run: |
python3 ./cryptatools-core/setup.py bdist_wheel --verbose ;
pip3 install ./dist/* --force-reinstall ;

- name: Test python bindings
run: |
python3 ./cryptatools-core/binding-testing/testing.py ;
10 changes: 8 additions & 2 deletions cryptatools-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ 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 All @@ -34,4 +40,4 @@ doc = true
[[bin]]
# This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen.
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
path = "uniffi-bindgen.rs"
Original file line number Diff line number Diff line change
@@ -1,0 +1,24 @@
//! Attack on RSA using common modulus attack.
use num_bigint::BigUint;

struct CommonModulusAttack {

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

struct `CommonModulusAttack` is never constructed

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

struct `CommonModulusAttack` is never constructed

}

/// attack a common modulus on a public exponent in public key using Lenstra’s Elliptic Curve Factorization
impl CommonModulusAttack {
pub fn native_factorization(n: BigUint) -> Vec<u32> {

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

associated functions `native_factorization` and `attack` are never used

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`
/*for i in n {

}*/

vec![]
}

pub fn attack(n: BigUint) -> Vec<u32> {

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`

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

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `n`
/*for i in n {

}*/
vec![]
}
}
2 changes: 2 additions & 0 deletions cryptatools-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub mod cryptanalysis;
pub mod cryptography;
pub mod utils;
pub mod maths;

use crate::maths::ECC;

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::maths::ECC`

Check warning on line 6 in cryptatools-core/src/lib.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused import: `crate::maths::ECC`
use crate::utils::alphabets::{Encoding, Alphabet, split_bytes_by_characters_representation, uniffy_opcode_group};
use crate::cryptography::classical::encryption::monoalphabetic_ciphers::caesar_number::CaesarNumberAlgorithm;
use crate::cryptography::classical::encryption::transpositional_ciphers::columnar_transposition::ColumnarTranspositionAlgorithm;
Expand Down
Loading
Loading