Skip to content

Commit f8cf577

Browse files
authored
k12: new implementation with parallel processing support (#839)
New implementation supports parallel processing of data and consumes data as soon as possible, which allows to remove the 8 KiB buffer used previously. It also introduces separate customized types with owned and borrowed customization strings, while the base type can not be customized.
1 parent 4edcb7b commit f8cf577

24 files changed

Lines changed: 1103 additions & 443 deletions

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ opt-level = 2
3535

3636
[patch.crates-io]
3737
sha1 = { path = "sha1" }
38-
turbo-shake = { path = "turbo-shake" }
3938
whirlpool = { path = "whirlpool" }

k12/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ repository = "https://github.com/RustCrypto/hashes"
1010
license = "Apache-2.0 OR MIT"
1111
keywords = ["hash", "digest"]
1212
categories = ["cryptography", "no-std"]
13-
description = "Pure Rust implementation of the KangarooTwelve hash function"
13+
description = "Implementation of the KangarooTwelve family of extendable-output functions"
1414

1515
[dependencies]
1616
digest = "0.11"
17-
turbo-shake = { version = "0.1.0", default-features = false }
17+
keccak = { version = "0.2", features = ["parallel"] }
1818

1919
[dev-dependencies]
2020
digest = { version = "0.11", features = ["alloc", "dev"] }
@@ -23,7 +23,7 @@ hex-literal = "1"
2323
[features]
2424
default = ["alloc"]
2525
alloc = ["digest/alloc"]
26-
zeroize = ["digest/zeroize", "turbo-shake/zeroize"]
26+
zeroize = ["digest/zeroize"]
2727

2828
[package.metadata.docs.rs]
2929
all-features = true

k12/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
![Rust Version][rustc-image]
77
[![Build Status][build-image]][build-link]
88

9-
Pure Rust implementation of the [KangarooTwelve] eXtendable-Output Function (XOF).
9+
Pure Rust implementation of the [KangarooTwelve] family of extendable-output functions (XOF).
1010

1111
## License
1212

k12/benches/kt128.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(test)]
2+
extern crate test;
3+
4+
use test::Bencher;
5+
6+
digest::bench_update!(
7+
k12::Kt128::default();
8+
kt128_1_10 10;
9+
kt128_2_100 100;
10+
kt128_3_1k 1000;
11+
kt128_4_10k 10_000;
12+
kt128_5_100k 100_000;
13+
kt128_6_1m 1_000_000;
14+
);

k12/benches/kt256.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(test)]
2+
extern crate test;
3+
4+
use test::Bencher;
5+
6+
digest::bench_update!(
7+
k12::Kt256::default();
8+
kt256_1_10 10;
9+
kt256_2_100 100;
10+
kt256_3_1k 1000;
11+
kt256_4_10k 10_000;
12+
kt256_5_100k 100_000;
13+
kt256_6_1m 1_000_000;
14+
);

k12/benches/mod.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

k12/src/block_api.rs

Lines changed: 0 additions & 274 deletions
This file was deleted.

k12/src/consts.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Number of permutation rounds used by k12
2+
pub(crate) const ROUNDS: usize = 12;
3+
/// Chunk size used by k12
4+
pub(crate) const CHUNK_SIZE: usize = 1 << 13;
5+
pub(crate) const CHUNK_SIZE_U64: u64 = CHUNK_SIZE as u64;
6+
7+
pub(crate) const SINGLE_NODE_DS: u8 = 0x07;
8+
pub(crate) const INTERMEDIATE_NODE_DS: u8 = 0x0B;
9+
pub(crate) const FINAL_NODE_DS: u8 = 0x06;
10+
11+
pub(crate) const S0_DELIM: u64 = 0x03;
12+
13+
/// Padding byte
14+
pub(crate) const PAD: u8 = 0x80;

0 commit comments

Comments
 (0)