Skip to main content

Crate ascon

Crate ascon 

Source
Expand description

Byte-oriented Ascon algorithms from NIST SP 800-232 (August 2025).

All operations use caller-owned buffers and work without allocation. Disable default features for no_std. See Aead128, Hash256, Xof128, and Cxof128. Nonces must never repeat under the same encryption key.

use ascon::{Aead128, hash256};
let cipher = Aead128::new(&[7; 16]);
let nonce = [1; 16]; // Use a unique nonce for every encryption with this key.
let mut message = *b"hello";
let tag = cipher.encrypt_in_place(&nonce, b"metadata", &mut message);
cipher.decrypt_in_place(&nonce, b"metadata", &mut message, &tag)?;
assert_eq!(&message, b"hello");
assert_eq!(hash256(&message).len(), 32);

Structs§

Aead128
Ascon-AEAD128 with a 128-bit key and full 128-bit tags.
Cxof128
Streaming Ascon-CXOF128, domain separated by a customization string.
Hash256
Streaming Ascon-Hash256 with a 32-byte digest.
Xof128
Streaming Ascon-XOF128 with caller-selected output length.
XofReader
Squeezing state for XOF128 or CXOF128. Each read continues the output stream.

Enums§

Error
Errors from the public cryptographic API.

Constants§

KEY_SIZE
Key length in bytes.
NONCE_SIZE
Nonce length in bytes.
TAG_SIZE
Full authentication tag length in bytes.

Functions§

cxof128
Fill output with Ascon-CXOF128 bytes, using at most 256 customization bytes. On error output is unchanged. Empty output is a no-op extension.
hash256
Hash a byte string using Ascon-Hash256.
xof128
Fill output with Ascon-XOF128 bytes. Empty output is a no-op extension.