Giter VIP home page Giter VIP logo

dh-hash-collisions-rs's Introduction

Hash collisions in Deffie-Hellman Key Exchange

This program is based on the concept of the so-called Birthday attack to find hash collisions in the context of the Deffie-Hellman Key Exchange.

Context

Alice and Bob generate their own private and public keys. They then exchange their public keys and compute the shared secret using their own private key and the public key of the other. The result is hashed using SHA3-224 and verified over the phone (it is supposed to be identical).

Attack implementation

The idea is to intercept the public keys of both Alice and Bob and establish a man-in-the-middle, pretending to be Alice for Bob and Bob for Alice. The program brute-forces private keys for each so that, when hashed, the computed shared secret in "Attacker-Alice" and "Attacker-Bob" communication would have the same first n hex digits (the assumption is that Alice and Bob would stop verifying the hashed secret over the phone after n digits).

Execute

The program takes three args: the public key of Alice in hex, the public key of Bob in hex and the number of the first hex digits of the shared hashed secret to collide

docker build -t collisions .
docker run collisions <Alice_pub_key> <Bob_pub_key> <hash_collision_prefix>

where hash_collision_prefix is the first n hex digits of the matching hashed shared secret.

Note: I haven't tried setting hash_collision_prefix > 12.

Runtime

The main motivation behind this program is to reduce long execution times caused by heavy cryptographic computation. It was written to compare different Rust libraries for big numbers and compared to an identical program written in Python (Standard library, no optimizations). The following table provides results for the 12 first hex digits of the hashed shared secret. For Rust programs, the optimized version was used (cargo run --release).

Language Library Num type Appr. Runtime Commit
Python Standard Library int ~1h:15m
Rust num_bigint BigInt ~1h:40m e50b4ec
Rust openssl BigNum ~16m 0c92339
Rust rug Integer ~16m latest version on main

dh-hash-collisions-rs's People

Contributors

kristina-pianykh avatar

Stargazers

 avatar

Watchers

 avatar

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.