Skip to content

Latest commit

 

History

History
90 lines (65 loc) · 2.75 KB

README.md

File metadata and controls

90 lines (65 loc) · 2.75 KB

RustCrypto: Ascon

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

Pure Rust implementation of the lightweight cryptographic hash functions AsconHash and AsconAHash and the extendable output functions (XOF) AsconXOF and AsconAXOF.

Security Notes

No security audits of this crate have ever been performed.

USE AT YOUR OWN RISK!

Examples

Fixed output size hashing:

use ascon_hash::{AsconHash, Digest};
use hex_literal::hex;

let mut hasher = AsconHash::new();
hasher.update(b"some bytes");
let hash = hasher.finalize();

assert_eq!(hash, hex!("b742ca75e57038757059cccc6874714f9dbd7fc5924a7df4e316594fd1426ca8"));

// Hex-encode hash using https://docs.rs/base16ct
let hex_hash = base16ct::lower::encode_string(&hash);
assert_eq!(hex_hash, "b742ca75e57038757059cccc6874714f9dbd7fc5924a7df4e316594fd1426ca8");

XOF hashing:

use ascon_hash::{AsconXof, ExtendableOutput, Update, XofReader};
use hex_literal::hex;

let mut xof = AsconXof::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!("c21972fde9"));

Also, see the examples section in the RustCrypto/hashes readme.

Minimum Supported Rust Version

This crate requires Rust 1.71 at a minimum.

We may change the MSRV in the future, but it will be accompanied by a minor version bump.

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.