ASCON Hash with RustASCON was designed by Christoph Dobraunig, Maria Eichlseder, Florian Mendel and Martin Schläffer from Graz University of Technology, Infineon Technologies, and Radboud University. It has been defined by NIST as a standard for light-weight encryption. In this case we will use Rust [4] to implement AEAD (Authenticated Encryption with Additional Data), and generate a random 128-bit encryption key and use a random nonce value. For ASCON Hashing, we create a 256-bit (32 byte) hash value. |
Performance
The following shows the performance analysis of ASCON compared to other hashes:
Coding
We first create a new cargo with:
cargo new asc_hash
Next we can edit the cargo.toml file with:
[package] name = "asc_hash" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] ascon-hash = "0.2.0" hex="0.4.3"
And then add the following code to main.rs:
use ascon_hash::{AsconHash, Digest}; use hex::{self}; use std::env; fn main() { let mut msg="abc"; let args: Vec= env::args().collect(); if args.len() >1 { msg = args[1].as_str();} let mut hasher = AsconHash::new(); hasher.update(msg.as_bytes()); let digest = hasher.finalize(); println!("Message:\t{}\n",msg); println!("Hash:\t\t{}\n",hex::encode(digest)); }
A sample run is:
Message: abc Hash: d37fe9f1d10dbcfad8408a6804dbe91124a8912693322bb23ec1701e19e3fd51
If you want to run the code yourself, try:
References
[1] ASCON Rust GitHub [here].