ascon-xof128 0.1.0

Implementation of Ascon-XOF128 and Ascon-СXOF128
Documentation

RustCrypto: Ascon-XOF128

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

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, CustomizedInit, ExtendableOutput, Update, XofReader};
use hex_literal::hex;

let mut xof = AsconCxof128::new_customized(b"some customization string");
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).

This limit is not enforced by the new_customized method; users must ensure their customization strings meet the size requirement if they intend to claim conformance to the standard.

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.