Code Monkey home page Code Monkey logo

cryptanalib3's People

Contributors

baroncrowley avatar istrangeloop avatar unicornsasfuel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cryptanalib3's Issues

Clean up and standardize function help blurbs

Standardize all function help blurbs to this:

"""
Function does XYZ.

Inputs:
``bytes`` sample - The sample to process.

Outputs:
``(bytes, int)`` - The processed sample and its length.

Raises:
``ValueError`` when the sample is too short.
"""

Allow ECDSA / DSA hash algos other than SHA1

As of now, ca3.modern.dsa_repeated_nonce_attack() has SHA1 hard-coded as the hash algorithm to use, but some systems choose to use other hash functions, such as SHA256.

It would be relatively easy to either pass an object with a method digest(self, plaintext) that returns a raw hash digest with the hash function desired, or perhaps just any hash function hash_function(plaintext) that as before, returns a raw hash digest.

Add CBC-static-IV CPA secret suffix attack

There is an attack on ECB where a secret appended to user input, encrypted, and disclosed in encrypted form can be obtained in plaintext form by bytewise brute force with carefully aligned boundaries. This attack is already implemented as ca3.ecb_cpa_decrypt.

This attack ALSO applies to CBC mode when a static IV is in use. It's a common flaw to use a static IV with CBC mode, and as such this is a very practical attack. We should add this attack to cryptanalib.

LCG modulus recovery multiplier detection

If the modulus recovery fails but GCD(states) > 1, it is often because the recovered modulus RM is a multiple of the actual modulus.

We can ceil_divide RM by the largest known state to get the maximum divisor by which to divide RM, check which of those are factors of RM, and try each in descending order, recovering a potential a constant and checking a/m until we find, or fail to find, the actual modulus.

Complete code test coverage

Perfect code coverage is tough, but there are a few things that really should have tests:

  • Morse code encode / decode
  • break_ascii_shift()
  • show_histogram()
  • make_polybius_square()
  • polybius_decrypt()
  • libc rand() next/prev state wrappers
  • unsuccessful rsa-crt fault attack
  • recovery of rsa modulus from signatures

Add Pollard Rho's method for solving EC discrete logarithms

from @sonOfRa:

There's two versions of this algorithm:

The local version that uses Floyd's cycle finding algorithm to find collisions
The distributed version that uses Distinguished Points to find collisions
The code I have uses the latter (it can just be used on a single computer, using multiple cores).

The algorithm can be used when given a Point Q, and its generator P, to find k such that k*P = Q. For small curves (40 bit) the algorithm finishes in below 5 seconds on my machine. For a larger (70 bit) curve, it took about 12 hours to find a collision. For large curves (>128 bit) it is unlikely to finish in a reasonable time frame.

The algorithm is also portable to "regular" Discrete Logarithms (used in DHKE): Given a group element x and its generator g, find k such that g^k = x

This issue is mostly a reminder for myself so I can find this again and port and contribute my code when I find the time.

Create RSA key reconstructor

It would be cool to have a function whose prototype is like:

rebuild_rsa_key(p=None, q=None, d=None, dp=None, dq=None, N=None, e=None, c=None, m=None)

It would step through a bunch of use cases to see if it could reconstruct the rest of the key. Mostly useful for CTF stuff, but would be nice once we have functions that could be used to recover a single factor or some such.

Make 2/3 compatible

There's a tool called pasteurize, part of the future module, that may allow this code to work in Python2, and thus Jython.

Allow for alternate expected plaintext frequency distributions across ca3

ca3 is currently very English-centric insofar as several functions are coded to expect English text frequency instead of other human languages like German or data formats like JSON. It would be great if, across all of ca3, we supported the use of alternate plaintext frequency distribution data.

Add RSA `d`/`N` corruption fault attack

This would be useful for fault injection against hardware that performs RSA private key operations. ca3 already has RSA-CRT fault attack code, but the non-CRT variant of the attack gets into a little more crazy math.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.