Skip to content

Commit f18bb80

Browse files
digest: add dev::initialized_mac_test function (#2367)
1 parent adcbc44 commit f18bb80

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

digest/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.11.3 (UNRELEASED)
9+
### Added
10+
- `dev::initialized_mac_test` function ([#2367])
11+
12+
[#2367]: https://github.com/RustCrypto/traits/pull/2367
13+
814
## 0.11.2 (2026-03-13)
915
### Changed
1016
- Do not implement `Clone` as part of `(Reset)MacTraits` in the `buffer_fixed!` macro ([#2341])

digest/src/dev/mac.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ pub fn mac_test<M: Mac + KeyInit + Clone>(
3131
return Err("Failed to initialize MAC instance");
3232
};
3333

34+
initialized_mac_test(mac0, input, tag, trunc_side)
35+
}
36+
37+
/// Run the MAC test directly on an initialized MAC.
38+
/// This is useful for when custom initialization is needed
39+
pub fn initialized_mac_test<M: Mac + Clone>(
40+
mac0: M,
41+
input: &[u8],
42+
tag: &[u8],
43+
trunc_side: MacTruncSide,
44+
) -> Result<(), &'static str> {
3445
let mut mac = mac0.clone();
3546
mac.update(input);
3647
let result = mac.finalize().into_bytes();

0 commit comments

Comments
 (0)