cr-marcstevens/sha1collisiondetection
FreeLibrary and command line tool to detect SHA-1 collision in a file
FreeFree tier
About cr-marcstevens/sha1collisiondetection
Library and command line tool for detecting SHA-1 collision attacks in files. Designed as a near drop-in replacement for common SHA-1 libraries and sha1sum, it computes the SHA-1 hash of any given file and additionally detects cryptanalytic collision attacks using the top 32 disturbance vectors with probability 1. The library supports an indicator flag for collision detection and a safe-hash mode that returns a different unpredictable hash when a collision is detected, protecting applications like digital signature verification. It is very fast, taking less than twice the time of regular SHA-1. Developed by Marc Stevens and Dan Shumow, distributed under the MIT license.
Key Features
Detects cryptanalytic collision attacks against SHA-1 using top 32 disturbance vectors with probability 1
Near drop-in replacement for common SHA-1 libraries and sha1sum
Safe-hash mode: returns a different unpredictable hash when collision is detected
Very fast: takes less than twice the time of regular SHA-1
Provides both indicator flag and safe-hash for application integration
Includes two command line programs: sha1dcsum and sha1dcsum_partialcoll
Distributed under MIT license
Pros & Cons
Pros
- Very fast performance (less than 2x regular SHA-1)
- Safe-hash mode prevents silent acceptance of colliding files
- Near drop-in replacement minimizes integration effort
- Actively maintained and used in major projects
- Open source with permissive MIT license
Cons
- Only detects specific known cryptanalytic collision attacks, not all possible SHA-1 weaknesses
- Requires recompilation or linking to replace existing SHA-1 usage
- Limited to SHA-1; does not provide general hash verification or other algorithms
Best For
Detecting SHA-1 collision attacks in filesProtecting digital signature verification against SHA-1 collision forgeriesSecurity auditing of files for known SHA-1 collision attacks (e.g., SHAttered, sha-mbles)Replacing sha1sum with collision detection capability
FAQ
What is safe-hash mode?
In safe-hash mode, the library returns the real SHA-1 hash when no collision is detected, and a different unpredictable safe hash when a collision is detected. This protects applications like digital signature verification by making colliding files produce different hashes.
How fast is the collision detection compared to regular SHA-1?
It takes less than twice the amount of time as regular SHA-1, making it very fast for a collision detection enhancement.
Which collision attacks are detected?
The library detects any cryptanalytic collision attack against SHA-1 using any of the top 32 SHA-1 disturbance vectors, including those used in the SHAttered and sha-mbles attacks, with probability 1.
How do I compile and use the tool?
Run `make` to compile. Use `bin/sha1dcsum` to detect full SHA-1 collisions and `bin/sha1dcsum_partialcoll` to detect reduced-round collisions. Pipe data or provide file paths as arguments.