cryptanalysis

Automated cryptanalysis of substitution permutation network cipher

https://github.com/deut-erium/auto-cryptanalysis

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary

Keywords

cryptanalysis crypto cryptography differential-cryptanalysis linear-cryptanalysis pypi substitution-permutation-network z3
Last synced: 6 months ago · JSON representation ·

Repository

Automated cryptanalysis of substitution permutation network cipher

Basic Info
Statistics
  • Stars: 32
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
cryptanalysis crypto cryptography differential-cryptanalysis linear-cryptanalysis pypi substitution-permutation-network z3
Created almost 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme Contributing License Citation

README.md

Auto Cryptanalysis

This project implements python module for automatic cryptanalysis of Substitution Permutation Network ciphers by performing extensive linear and differential characteristic search and finding keybits

Structure

The project is structured as follows:

  • The cryptanalysis directory contains the main Python module for cryptanalysis.
  • The tests directory contains unit tests for the module
  • The examples directory contains examples for using the module
  • The docs directory contains html documentation autogenerated from code doc-strings

Installation

Pip

The project can be installed directly from pip bash pip install cryptanalysis

Otherwise clone and install is also viable

bash git clone https://github.com/deut-erium/auto-cryptanalysis.git cd auto-cryptanalysis pip install .

Requirements

This project requires Python3.6+ and the following Python packages: - z3-solver - tqdm

Requirements are auto installed as a part of the installation process but

You can also install these packages using pip: bash pip install -r requirements.txt

Usage

```python import random import cryptanalysis

sboxsize = 6 # bits pboxsize = sboxsize * 16 # 16 sboxes numrounds = 4 sbox = list(range(2**sboxsize)) pbox = list(range(pboxsize))

random pbox and sbox

random.shuffle(sbox) random.shuffle(pbox)

randomkey = random.randint(0, (2**pboxsize) - 1)

random spn instance whose key is unknown to us

spn = cryptanalysis.SPN(sbox, pbox, randomkey, numrounds)

dc = cryptanalysis.differentialcryptanalysis.DifferentialCryptanalysis(sbox, pbox, num_rounds+1)

override batch_encrypt with the oracle

maxnumencryptions = 50000 def batch_encrypt(plaintexts): return [spn.encrypt(i) for i in plaintexts]

dc.batchencrypt = batchencrypt differentialcharacteristics = dc.characteristicsearcher.searchexclusivemasks() lastroundkeyblocks = dc.findlastroundkey(differentialcharacteristics, maxnum_encryptions//16)

print("recovered last round key:",lastroundkeyblocks) print("original last round key:",dc.inttolist(spn.round_keys[-1])) ```

Tests

You can run the tests using the following command: bash python -m unittest discover

Documentation

Read the documentation
Autogenerated documentation from code doc-strings can be found under docs

Contributing

Please feel free to submit pull requests or create issues if you find any bugs or have any suggestions for improvements.
List of ideas to implement/TODO is present in CONTRIBUTING.md

License

This project is licensed under the GPL License.

Owner

  • Name: Himanshu Sheoran
  • Login: deut-erium
  • Kind: user
  • Location: India
  • Company: @vmware

Spreading nerdona virus since ever. Participates actively in CTFs and finds crypto, rev, pwn interesting. Intrigued? hmu with your best python one-liner

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: auto-cryptanalysis
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Himanshu Sheoran
identifiers:
  - type: url
    value: 'https://github.com/deut-erium/auto-cryptanalysis'
    description: Github
repository-code: 'https://github.com/deut-erium/auto-cryptanalysis'
url: 'https://deut-erium.github.io/auto-cryptanalysis/'
abstract: >-
  A tool for automated cryptanalysis of Substitution-Permutation Network (SPN) ciphers
  is presented. The tool identifies optimal characteristic paths on SPNs to perform 
  linear and differential cryptanalysis. It employs advanced Satisfiability Modulo Theories 
  (SMT) analysis using the z3 solver to examine combinations of Substitution Boxes (SBOX)
  and Permutation Boxes (PBOX). This enables efficient exploration of large state spaces, enhancing
  the tool's ability to uncover hidden vulnerabilities in SPN-based cryptographic schemes.
keywords:
  - SMT
  - Z3
  - SPN
  - Block cipher
license: GPL
commit: >-
  https://github.com/deut-erium/auto-cryptanalysis/commit/fde6065eeeed2ffd6521b1fcaf67202ab3843752

GitHub Events

Total
  • Watch event: 6
Last Year
  • Watch event: 6

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 94 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 3
  • Total maintainers: 1
pypi.org: cryptanalysis

Automated cryptanalysis library for substitution permutation network

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 94 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 13.6%
Dependent repos count: 21.6%
Average: 24.8%
Forks count: 29.8%
Downloads: 49.1%
Maintainers (1)
Last synced: 6 months ago