Expand description
§RustCrypto: KangarooTwelve
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.
Re-exports§
Modules§
- custom
- Customized variants.
Structs§
Traits§
- Extendable
Output - Trait for hash functions with extendable-output (XOF).
- Update
- Types which consume data with byte granularity.
- XofReader
- Trait for reader types which are used to extract extendable output from a XOF (extendable-output function) result.
Type Aliases§
- Kt128
- KT128 hasher.
- Kt256
- KT256 hasher.
- Kt128
Reader - KT128 XOF reader.
- Kt256
Reader - KT256 XOF reader.