Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ascon-aead128/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- Build against the released `ascon` v0.5.0: the permutation state is now a
plain array with free `permute*` functions, and the state is zeroized by
this crate under the `zeroize` feature since `ascon` no longer has one

## 0.1.1 (2026-08-21)
### Changed
- Replace `subtle` with `ctutils` ([#879])
Expand Down
4 changes: 2 additions & 2 deletions ascon-aead128/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust-version = "1.85"

[dependencies]
aead = { version = "0.6", default-features = false }
ascon = "0.5.0-rc.0"
ascon = "0.5"
ctutils = "0.4"

# optional dependencies
Expand All @@ -29,7 +29,7 @@ arrayvec = ["aead/arrayvec"]
bytes = ["aead/bytes"]
getrandom = ["aead/getrandom"]
rand_core = ["aead/rand_core"]
zeroize = ["dep:zeroize", "ascon/zeroize"]
zeroize = ["dep:zeroize"]

[lints]
workspace = true
Expand Down
19 changes: 13 additions & 6 deletions ascon-aead128/src/asconcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use aead::{
consts::U16,
inout::InOutBuf,
};
use ascon::State;
use ascon::{State, permute8, permute12};
use ctutils::CtEq;

/// Produce mask for padding.
Expand Down Expand Up @@ -103,17 +103,24 @@ pub(crate) struct AsconCore<'a, P: Parameters> {
key: &'a P::InternalKey,
}

#[cfg(feature = "zeroize")]
impl<P: Parameters> Drop for AsconCore<'_, P> {
fn drop(&mut self) {
zeroize::Zeroize::zeroize(&mut self.state);
}
}

impl<'a, P: Parameters> AsconCore<'a, P> {
pub(crate) fn new(internal_key: &'a P::InternalKey, nonce: &Array<u8, U16>) -> Self {
let mut state = State::new(
let mut state: State = [
P::IV,
internal_key.get_k1(),
internal_key.get_k2(),
u64_from_bytes(&nonce[..8]),
u64_from_bytes(&nonce[8..]),
);
];

state.permute_12();
permute12(&mut state);
state[3] ^= internal_key.get_k1();
state[4] ^= internal_key.get_k2();

Expand All @@ -125,15 +132,15 @@ impl<'a, P: Parameters> AsconCore<'a, P> {

/// Permutation with 12 rounds and application of the key at the end
fn permute_12_and_apply_key(&mut self) {
self.state.permute_12();
permute12(&mut self.state);
self.state[3] ^= self.key.get_k1();
self.state[4] ^= self.key.get_k2();
}

/// Permutation with 6 or 8 rounds based on the parameters
#[inline(always)]
fn permute_state(&mut self) {
self.state.permute_8();
permute8(&mut self.state);
}

fn process_associated_data(&mut self, associated_data: &[u8]) {
Expand Down
Loading