#hash #extendable-output

no-std k12

Implementation of the KangarooTwelve family of extendable-output functions

11 unstable releases (5 breaking)

Uses new Rust 2024

new 0.5.1 May 15, 2026
0.4.0 Apr 24, 2026
0.4.0-rc.1 Jan 24, 2026
0.3.0 Jun 10, 2023
0.0.0 Jun 4, 2017

#2936 in Cryptography

Download history 4311/week @ 2026-01-23 5683/week @ 2026-01-30 5697/week @ 2026-02-06 5450/week @ 2026-02-13 5032/week @ 2026-02-20 5815/week @ 2026-02-27 5250/week @ 2026-03-06 5932/week @ 2026-03-13 6982/week @ 2026-03-20 7078/week @ 2026-03-27 5662/week @ 2026-04-03 6077/week @ 2026-04-10 8398/week @ 2026-04-17 6404/week @ 2026-04-24 46532/week @ 2026-05-01 27533/week @ 2026-05-08

89,615 downloads per month
Used in 42 crates (10 directly)

Apache-2.0 OR MIT

37KB
731 lines

RustCrypto: KangarooTwelve

crate Docs Apache2/MIT licensed Rust Version Build Status

Pure Rust implementation of the KangarooTwelve family of extendable-output functions (XOF).

Examples

KangarooTwelve functions have an extendable output, so finalization methods return XOF reader from which results of arbitrary length can be read:

use k12::{Kt128, Update, ExtendableOutput, XofReader};
use hex_literal::hex;

let mut hasher = Kt128::default();
hasher.update(b"abc");
let mut reader = hasher.finalize_xof();
let mut buf = [0u8; 10];
reader.read(&mut buf);
assert_eq!(buf, hex!("ab174f328c55a5510b0b"));
reader.read(&mut buf);
assert_eq!(buf, hex!("209791bf8b60e801a7cf"));

Additionally, KangarooTwelve supports customization:

use k12::{CustomRefKt128, Update, ExtendableOutput, XofReader};
use hex_literal::hex;

let mut hasher = CustomRefKt128::new_customized(b"my customization string");
hasher.update(b"abc");
let mut reader = hasher.finalize_xof();
let mut buf = [0u8; 10];
reader.read(&mut buf);
assert_eq!(buf, hex!("fbe2ce557c1b115bfe1f"));
reader.read(&mut buf);
assert_eq!(buf, hex!("c9d7b4097c55f0f5ae86"));

CustomRefKt128/256 keep reference to the customization string, while CustomKt128/256 keep an owned copy of it. Note that the latter types are gated on the alloc crate feature.

See the digest crate docs for additional examples.

License

The crate is licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~715KB
~18K SLoC