Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
lib-q-k12
A pure Rust implementation of KangarooTwelve per RFC 9861: KT128 (TurboSHAKE128) and KT256 (TurboSHAKE256) extendable-output functions, with domain separation via an optional customization string.
Overview
KangarooTwelve applies a Sakura tree mode on top of TurboSHAKE. This crate exposes the two standard instances as Kt128 and Kt256, matching the names and test vectors in RFC 9861.
- KT128 — 128-bit collision strength (typical 32-byte default digest context).
- KT256 — 256-bit collision strength (typical 64-byte default in high-security profiles).
Features
- Pure Rust: No unsafe code
- no_std: Embedded-friendly (
#![no_std]; works onthumb*andwasm32-unknown-unknown) - Streaming:
Updatefor incremental input - XOF: Arbitrary output length via
ExtendableOutput/XofReader - KATs: Vectors from RFC 9861 Appendix A
no_std, alloc, and WASM
- Default enables
alloc(needed forfinalize_boxedand similar helpers fromdigest). - For
coreonly, usedefault-features = falseandfinalize_xof/finalize_xof_intowith a fixed-size buffer instead offinalize_boxed. - CI runs
cargo checkfor this crate onwasm32-unknown-unknownandthumbv7em-none-eabiwith and without default features.
Integrated into lib-q-hash for KangarooTwelve; see the workspace README for the full dependency graph.
Usage
Basic hashing (KT128)
use ;
let mut hasher = default;
hasher.update;
let result = hasher.finalize_boxed;
With customization
use Kt128;
use ;
let customization = b"MyApplication";
let mut hasher = new;
hasher.update;
let result = hasher.finalize_boxed;
Streaming
use ;
let mut hasher = default;
hasher.update;
hasher.update;
let result = hasher.finalize_boxed;
XOF reader
use ;
let mut hasher = default;
hasher.update;
let mut reader = hasher.finalize_xof;
let mut output = ;
reader.read;
KT256
use ;
let mut hasher = default;
hasher.update;
let out = hasher.finalize_boxed;
API reference
| Type | Role |
|---|---|
Kt128 / Kt128Reader |
KangarooTwelve with TurboSHAKE128 (AlgorithmName: "KT128") |
Kt256 / Kt256Reader |
KangarooTwelve with TurboSHAKE256 (AlgorithmName: "KT256") |
Main methods: new, default, update, finalize_boxed, finalize_xof, reset (see digest traits).
Performance
Tree chunk size is 8192 bytes. Throughput depends on input length and CPU; see cargo bench -p lib-q-k12.
Security
- Collision strength:
U16bytes (128-bit) forKt128,U32bytes (256-bit) forKt256— see RFC 9861 §7.7–7.8. - Use KT256 when the application profile requires 256-bit collision security.
Testing
Standards
License
Licensed under the Apache License, Version 2.0. See LICENSE-APACHE for details.
Contributing
Run cargo test -p lib-q-k12 and follow project rustfmt/Clippy settings. See TESTING.md.