Skip to main content

Crate turboshake

Crate turboshake 

Source
Expand description

§RustCrypto: TurboSHAKE

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Implementation of the TurboSHAKE family of extendable-output functions (XOFs).

§Examples

SHAKE functions have an extendable output, so finalization method returns XOF reader from which results of arbitrary length can be read. Note that these functions do not implement Digest, so lower-level traits have to be imported:

TurboSHAKE supports limited customization using “domain separator” value. This implementation handles it using the const generic parameter DS.

With the default domain separator:

use turboshake::TurboShake128;
use turboshake::digest::{Update, ExtendableOutput, XofReader};
use hex_literal::hex;

let mut hasher = TurboShake128::default();
hasher.update(b"abc");
let mut reader = hasher.finalize_xof();
let mut buf = [0u8; 10];
reader.read(&mut buf);
assert_eq!(buf, hex!("dcf1646dfe993a8eb6b7"));
reader.read(&mut buf);
assert_eq!(buf, hex!("82d1faaca6d82416a5dc"));

With a custom domain separator:

use turboshake::CTurboShake128;
use turboshake::digest::{Update, ExtendableOutput, XofReader};
use hex_literal::hex;

let mut hasher = CTurboShake128::<0x10>::default();
hasher.update(b"abc");
let mut reader = hasher.finalize_xof();
let mut buf = [0u8; 10];
reader.read(&mut buf);
assert_eq!(buf, hex!("6702f7b19ea87087ed0f"));
reader.read(&mut buf);
assert_eq!(buf, hex!("45a2fa692bc18c3526d3"));

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§

pub use digest;

Structs§

TurboShake
TurboSHAKE hasher generic over rate and domain separator.
TurboShakeReader
Generic TurboSHAKE XOF reader

Constants§

DEFAULT_DS
Default domain separator value.

Type Aliases§

CTurboShake128
TurboSHAKE128 hasher with a custom domain separator.
CTurboShake256
TurboSHAKE256 hasher with a custom domain separator.
TurboShake128
TurboSHAKE128 hasher with the default domain separator.
TurboShake256
TurboSHAKE256 hasher with the default domain separator.
TurboShake128Reader
TurboSHAKE128 XOF reader.
TurboShake256Reader
TurboSHAKE256 XOF reader.