diff --git a/Cargo.lock b/Cargo.lock index 72d50b02..500df131 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,12 +86,9 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "ascon" -version = "0.5.0-rc.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953707d565de11d13f8cf7d880e9a46c9c403693cb7d79dcfa49feaac2d2020f" -dependencies = [ - "zeroize", -] +checksum = "f5a0543d9a0a29ecb1d2046beb7547e97941de03228a3f31e15addfc78836049" [[package]] name = "ascon-aead128" diff --git a/ascon-aead128/CHANGELOG.md b/ascon-aead128/CHANGELOG.md index 76ea61c0..1de3ef18 100644 --- a/ascon-aead128/CHANGELOG.md +++ b/ascon-aead128/CHANGELOG.md @@ -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]) diff --git a/ascon-aead128/Cargo.toml b/ascon-aead128/Cargo.toml index f5a5c2ba..ab8267f8 100644 --- a/ascon-aead128/Cargo.toml +++ b/ascon-aead128/Cargo.toml @@ -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 @@ -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 diff --git a/ascon-aead128/src/asconcore.rs b/ascon-aead128/src/asconcore.rs index 4c8c3bde..c21a0ff6 100644 --- a/ascon-aead128/src/asconcore.rs +++ b/ascon-aead128/src/asconcore.rs @@ -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. @@ -103,17 +103,24 @@ pub(crate) struct AsconCore<'a, P: Parameters> { key: &'a P::InternalKey, } +#[cfg(feature = "zeroize")] +impl 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) -> 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(); @@ -125,7 +132,7 @@ 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(); } @@ -133,7 +140,7 @@ impl<'a, P: Parameters> AsconCore<'a, P> { /// 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]) {