Expand description
§RustCrypto: Ascon-XOF128
Pure Rust implementation of the Ascon-XOF128 and Ascon-СXOF128 extendable output functions (XOF) specified in NIST SP 800-232.
§Examples
Ascon-XOF128 has an extendable output, so finalization methods return XOF reader from which results of arbitrary length can be read.
use ascon_xof128::{AsconXof128, ExtendableOutput, Update, XofReader};
use hex_literal::hex;
let mut xof = AsconXof128::default();
xof.update(b"some bytes");
let mut reader = xof.finalize_xof();
let mut dst = [0u8; 5];
reader.read(&mut dst);
assert_eq!(dst, hex!("8C7DD114A0"));Ascon-CXOF128 works similarly, but you must specify a customization string to initialize it:
use ascon_xof128::{AsconCxof128, ExtendableOutput, TryCustomizedInit, Update, XofReader};
use hex_literal::hex;
let mut xof = AsconCxof128::try_new_customized(b"some customization string").unwrap();
xof.update(b"some bytes");
let mut reader = xof.finalize_xof();
let mut dst = [0u8; 5];
reader.read(&mut dst);
assert_eq!(dst, hex!("7824810FF7"));Note that the NIST specifies that:
The length of the customization string shall be at most 2048 bits (i.e., 256 bytes).
Implementation of the TryCustomizedInit trait for this type returns InvalidCustomizationError
for longer customization strings.
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§
- Ascon
Cxof128 - Ascon-CXOF128 hasher.
- Ascon
Xof128 - Ascon-XOF128 hasher.
- Ascon
Xof128 Reader - XOF reader used by Ascon-XOF128 and Ascon-CXOF128
Traits§
- Extendable
Output - Trait for hash functions with extendable-output (XOF).
- TryCustomized
Init - Trait for hash functions with customization string for domain separation which place restrictions on customization strings.
- 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.