Skip to content

Migrate to buffering macros #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8f9f392
Migrate to newtype macros
newpavlov May 4, 2025
7dcfe8e
migrate ascon
newpavlov May 4, 2025
d8f20d0
minor code tweaks
newpavlov May 4, 2025
7bac829
migrate to generic fixed newtype
newpavlov May 4, 2025
7181dfc
Migrate groestl
newpavlov May 4, 2025
a653808
tweak groestl tests
newpavlov May 4, 2025
e66f85b
update digest
newpavlov May 4, 2025
2c991b6
Migrate kupyna
newpavlov May 5, 2025
0408fdf
tweak groestl docs
newpavlov May 5, 2025
ee772f9
tweak kupyna docs
newpavlov May 5, 2025
015815d
update k12
newpavlov May 5, 2025
8e446e1
use new fixed macro
newpavlov May 5, 2025
4672e8e
use re-exported buffer kinds
newpavlov May 6, 2025
ab285fe
sha3: remove deprecated module
newpavlov May 6, 2025
bfc659e
sha3: rename core types
newpavlov May 6, 2025
7f45288
update to `newtype_rt_variable_hash!`
newpavlov May 7, 2025
8837461
migrate to new `newtype_ct_variable_hash!`
newpavlov May 7, 2025
9a29611
sha3: move `xor_block`
newpavlov May 7, 2025
bdef41a
Migrate to CtOutWrapper
newpavlov May 16, 2025
fc69e6e
update
newpavlov May 19, 2025
2007344
update xofs
newpavlov May 19, 2025
91f813d
Simplify bounds
newpavlov May 19, 2025
ce4e334
Simplify bounds
newpavlov May 19, 2025
ada0115
use renamed macros
newpavlov May 19, 2025
9c248f1
Update TurboSHAKE
newpavlov May 25, 2025
3209ce6
rename core_api to block_api
newpavlov May 25, 2025
6a4688d
Update changelogs
newpavlov May 26, 2025
45241ee
Move core types to block_api module
newpavlov May 26, 2025
0b18851
tweak sha1
newpavlov May 26, 2025
10f1040
tweak jh
newpavlov May 26, 2025
025655c
switch to digest from master
newpavlov May 26, 2025
1d857ee
Update Cargo.lock
newpavlov May 26, 2025
57e45a8
Update changelogs
newpavlov May 26, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/sha3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: cargo hack build --target ${{ matrix.target }} --each-feature --exclude-features default,std,asm
- run: cargo hack build --target ${{ matrix.target }} --each-feature --exclude-features default,asm

test:
needs: set-msrv
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ opt-level = 2

[patch.crates-io]
# https://github.com/RustCrypto/traits/pull/1787
# https://github.com/RustCrypto/traits/pull/1799
digest = { git = "https://github.com/RustCrypto/traits" }
2 changes: 2 additions & 0 deletions ascon-hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Edition changed to 2024 and MSRV bumped to 1.85 ([#652])
- Relax MSRV policy and allow MSRV bumps in patch releases
- Update to `digest` v0.11
- Replace type aliases with newtypes [#678]
- Adopt to changes from NIST draft
- Remove `AsconAHash` and `AsconAXof`
- Rename `AsonHash` to `AsconHAsh256`
- Rename `AsconXof` to `AsconXof128`

[#652]: https://github.com/RustCrypto/hashes/pull/652
[#678]: https://github.com/RustCrypto/hashes/pull/678

## 0.2.0 (2023-03-21)
### Changed
Expand Down
6 changes: 3 additions & 3 deletions ascon-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["crypto", "hash", "ascon"]
categories = ["cryptography", "no-std"]

[dependencies]
digest = { version = "=0.11.0-pre.10", default-features = false, features = ["core-api"] }
digest = "=0.11.0-pre.10"
ascon = { version = "0.4", default-features = false }

[dev-dependencies]
Expand All @@ -26,8 +26,8 @@ hex-literal = "1"
base16ct = { version = "0.2", features = ["alloc"] }

[features]
default = ["std"]
std = ["digest/std"]
default = ["alloc"]
alloc = ["digest/alloc"]
zeroize = ["ascon/zeroize", "digest/zeroize"]

[package.metadata.docs.rs]
Expand Down
91 changes: 59 additions & 32 deletions ascon-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use ascon::State;
pub use digest::{self, Digest, ExtendableOutput, Reset, Update, XofReader};
use digest::{
HashMarker, Output, OutputSizeUser,
block_buffer::Eager,
consts::{U8, U32},
core_api::{
AlgorithmName, Block, Buffer, BufferKindUser, CoreWrapper, ExtendableOutputCore,
FixedOutputCore, UpdateCore, XofReaderCore, XofReaderCoreWrapper,
block_api::{
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, Eager, ExtendableOutputCore,
FixedOutputCore, UpdateCore, XofReaderCore,
},
crypto_common::BlockSizeUser,
consts::{U8, U32, U40},
crypto_common::hazmat::{DeserializeStateError, SerializableState, SerializedState},
};

/// Produce mask for padding.
Expand Down Expand Up @@ -176,6 +175,26 @@ impl AlgorithmName for AsconCore {
}
}

impl SerializableState for AsconCore {
type SerializedStateSize = U40;

fn serialize(&self) -> SerializedState<Self> {
self.state.state.as_bytes().into()
}

fn deserialize(
serialized_state: &SerializedState<Self>,
) -> Result<Self, DeserializeStateError> {
let state = ascon::State::from(&serialized_state.0);
Ok(Self {
state: HashCore {
state,
phantom: PhantomData,
},
})
}
}

/// Ascon XOF
#[derive(Clone, Debug, Default)]
pub struct AsconXofCore {
Expand Down Expand Up @@ -241,29 +260,37 @@ impl AlgorithmName for AsconXofCore {
}
}

/// Ascon-Hash256
///
/// ```
/// use ascon_hash::{AsconHash256, Digest};
///
/// let mut hasher = AsconHash256::new();
/// hasher.update(b"some bytes");
/// let digest = hasher.finalize();
/// assert_eq!(&digest[..], b"\xe9\x09\xc2\xf6\xda\x9c\xb3\x02\x84\x23\x26\x5c\x8f\x23\xfc\x2d\x26\xbf\xc0\xf3\xdb\x70\x46\x83\xef\x16\xb7\x87\xa9\x45\xed\x68");
/// ```
pub type AsconHash256 = CoreWrapper<AsconCore>;
/// Ascon-XOF128
///
/// ```
/// use ascon_hash::{AsconXof128, ExtendableOutput, Update, XofReader};
///
/// let mut xof = AsconXof128::default();
/// xof.update(b"some bytes");
/// let mut reader = xof.finalize_xof();
/// let mut dst = [0u8; 5];
/// reader.read(&mut dst);
/// assert_eq!(&dst, b"\x8c\x7d\xd1\x14\xa0");
/// ```
pub type AsconXof128 = CoreWrapper<AsconXofCore>;
/// Reader for AsconXOF output
pub type AsconXof128Reader = XofReaderCoreWrapper<AsconXofReaderCore>;
impl SerializableState for AsconXofCore {
type SerializedStateSize = U40;

fn serialize(&self) -> SerializedState<Self> {
self.state.state.as_bytes().into()
}

fn deserialize(
serialized_state: &SerializedState<Self>,
) -> Result<Self, DeserializeStateError> {
let state = ascon::State::from(&serialized_state.0);
Ok(Self {
state: HashCore {
state,
phantom: PhantomData,
},
})
}
}

digest::buffer_fixed!(
/// Ascon-Hash256
pub struct AsconHash256(AsconCore);
impl: FixedHashTraits;
);

digest::buffer_xof!(
/// Ascon-XOF128 hasher.
pub struct AsconXof128(AsconXofCore);
impl: XofHasherTraits;
/// Ascon-XOF128 reader.
pub struct AsconXof128Reader(AsconXofReaderCore);
impl: XofReaderTraits;
);
8 changes: 8 additions & 0 deletions belt-hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ 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).

## 0.2.0 (UNRELEASED)
### Added
- `alloc` crate feature ([#678])

### Changed
- Edition changed to 2024 and MSRV bumped to 1.85 ([#652])
- Relax MSRV policy and allow MSRV bumps in patch releases
- Update to `digest` v0.11
- Replace type aliases with newtypes ([#678])

### Removed
- `std` crate feature ([#678])

[#652]: https://github.com/RustCrypto/hashes/pull/652
[#678]: https://github.com/RustCrypto/hashes/pull/678

## 0.1.1 (2022-11-22)
### Added
Expand Down
4 changes: 2 additions & 2 deletions belt-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ hex-literal = "1"
base16ct = { version = "0.2", features = ["alloc"] }

[features]
default = ["oid", "std"]
std = ["digest/std"]
default = ["alloc", "oid"]
alloc = ["digest/alloc"]
oid = ["digest/oid"]
zeroize = ["digest/zeroize"]

Expand Down
Loading
Loading