Debian Codegraph @

/

debian rust-sha1collisiondetection 0.3.4-1debian librust-sha1collisiondetection-dev debian librust-sha1collisiondetection+clap-dev debian librust-sha1collisiondetection+clap-mangen-dev debian librust-sha1collisiondetection+const-oid-dev debian librust-sha1collisiondetection+default-dev debian librust-sha1collisiondetection+digest-dev debian librust-sha1collisiondetection+digest-trait-dev debian librust-sha1collisiondetection+oid-dev debian librust-sha1collisiondetection+std-dev debian librust-sha1collisiondetection-0-dev debian librust-sha1collisiondetection-0+clap-dev debian librust-sha1collisiondetection-0+clap-mangen-dev debian librust-sha1collisiondetection-0+const-oid-dev debian librust-sha1collisiondetection-0+default-dev debian librust-sha1collisiondetection-0+digest-dev debian librust-sha1collisiondetection-0+digest-trait-dev debian librust-sha1collisiondetection-0+oid-dev debian librust-sha1collisiondetection-0+std-dev debian librust-sha1collisiondetection-0.3-dev
19 more… debian librust-sha1collisiondetection-0.3+clap-dev debian librust-sha1collisiondetection-0.3+clap-mangen-dev debian librust-sha1collisiondetection-0.3+const-oid-dev debian librust-sha1collisiondetection-0.3+default-dev debian librust-sha1collisiondetection-0.3+digest-dev debian librust-sha1collisiondetection-0.3+digest-trait-dev debian librust-sha1collisiondetection-0.3+oid-dev debian librust-sha1collisiondetection-0.3+std-dev debian librust-sha1collisiondetection-0.3.4-dev debian librust-sha1collisiondetection-0.3.4+clap-dev debian librust-sha1collisiondetection-0.3.4+clap-mangen-dev debian librust-sha1collisiondetection-0.3.4+const-oid-dev debian librust-sha1collisiondetection-0.3.4+default-dev debian librust-sha1collisiondetection-0.3.4+digest-dev debian librust-sha1collisiondetection-0.3.4+digest-trait-dev debian librust-sha1collisiondetection-0.3.4+oid-dev debian librust-sha1collisiondetection-0.3.4+std-dev debian sha1cdsum cargo sha1collisiondetection 0.3.4
debianjsonmakefilemarkdownrustrustrust-c-abishelltoml 27 files · 502 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • rust-clap-mangen (librust-clap-mangen-0.3-dev)
  • rust-digest-0.10 (librust-digest-0.10+default-dev, librust-digest-0.10+std-dev)
  • cargo, debhelper-compat, librust-clap-4+derive-dev, librust-clap-4+help-dev, librust-clap-4+std-dev, librust-clap-4+wrap-help-dev, librust-const-oid-0.9-dev, librust-generic-array+default-dev, libstd-rust-dev, rustc
README (full)

sha1collisiondetection

Library and command line tool to detect SHA-1 collisions in files

This is a port of Marc Stevens' sha1collisiondetection algorithm to Rust. The code is translated from C to Rust using c2rust.

To improve the translation, the code is transformed first, replacing macros with inline functions. Running the test suite using make check tests the correctness of the transformation.

This crate, like the C implementation, is distributed under the MIT Software License.

Installation of the command line utility

The command line utility is a drop-in replacement for coreutils' sha1sum utility. It can be installed, for example, using cargo:

$ cargo install sha1collisiondetection
[...]
$ sha1cdsum --help
sha1cdsum 0.2.3
Print or check SHA1 (160-bit) checksums with collision detection.

USAGE:
    sha1cdsum [FLAGS] [files]...
[...]
$ sha1cdsum test/*1.*
4f3d9be4a472c4dae83c6314aa6c36a064c1fd14 *coll* test/sha-mbles-1.bin
16e96b70000dd1e7c85b8368ee197754400e58ec *coll* test/shattered-1.pdf

About

This library and command line tool were designed as near drop-in replacements for common SHA-1 libraries and sha1sum. They will compute the SHA-1 hash of any given file and additionally will detect cryptanalytic collision attacks against SHA-1 present in each file. It is very fast and takes less than twice the amount of time as regular SHA-1.

More specifically they will detect any cryptanalytic collision attack against SHA-1 using any of the top 32 SHA-1 disturbance vectors with probability 1:

    I(43,0), I(44,0), I(45,0), I(46,0), I(47,0), I(48,0), I(49,0), I(50,0), I(51,0), I(52,0),
    I(46,2), I(47,2), I(48,2), I(49,2), I(50,2), I(51,2),
    II(45,0), II(46,0), II(47,0), II(48,0), II(49,0), II(50,0), II(51,0), II(52,0), II(53,0), II(54,0), II(55,0), II(56,0),
    II(46,2), II(49,2), II(50,2), II(51,2)

The possibility of false positives can be neglected as the probability is smaller than 2^-90.

The library supports both an indicator flag that applications can check and act on, as well as a special safe-hash mode that returns the real SHA-1 hash when no collision was detected and a different safe hash when a collision was detected. Colliding files will have the same SHA-1 hash, but will have different unpredictable safe-hashes. This essentially enables protection of applications against SHA-1 collisions with no further changes in the application, e.g., digital signature forgeries based on SHA-1 collisions automatically become invalid.

For the theoretical explanation of collision detection see the award-winning paper on Counter-Cryptanalysis:

Counter-cryptanalysis, Marc Stevens, CRYPTO 2013, Lecture Notes in Computer Science, vol. 8042, Springer, 2013, pp. 129-146, https://marc-stevens.nl/research/papers/C13-S.pdf

Developers

The C implementation of the collision detection algorithm is implemented by:

  • Marc Stevens, CWI Amsterdam (https://marc-stevens.nl)
  • Dan Shumow, Microsoft Research (https://www.microsoft.com/en-us/research/people/danshu/)

The C implementation is maintained here.

Please report issues with the Rust port here.

Usage

use hex_literal::hex;
use sha1collisiondetection::{Sha1CD, Digest};

// create a Sha1CD object
let mut hasher = Sha1CD::new();

// process input message
hasher.update(b"hello world");

// acquire hash digest in the form of GenericArray,
// which in this case is equivalent to [u8; 20]
let result = hasher.finalize();
assert_eq!(result[..], hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"));

Feature flags

This crate uses features to enable or disable optional functionality. You can tweak the features in your Cargo.toml file, like so:

sha1collisiondetection = { version = "*", default-features = false, features = [...] }

Feature 'std'

If enabled, this crate requires the standard library. Enabled by default.

Feature 'digest-trait'

If enabled, this crate implements trait Digest from the digest crate. Enabled by default.

dir debian/
dir lib/
dir src/
dir test/
dir tests/
file .cargo_vcs_info.json
file .gitignore
file Cargo.lock
file Cargo.toml
file Cargo.toml.orig
file LICENSE.txt
file MAINTENANCE.md
file README.md
file build.rs