diff --git a/inout/CHANGELOG.md b/inout/CHANGELOG.md index d95336f6..9fb3ac46 100644 --- a/inout/CHANGELOG.md +++ b/inout/CHANGELOG.md @@ -4,6 +4,13 @@ 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). +## 0.2.5 (2026-10-16) +### Fixed +- Return `PadError` from `InOutBufReserved::into_padded_blocks` + for incorrect `Padding` implementations ([#1562]) + +[#1562]: https://github.com/RustCrypto/utils/pull/1562 + ## 0.2.4 (2026-10-16) ### Fixed - Output buffer length check in `InOutBufReserved::into_padded_blocks` ([#1559]) diff --git a/inout/src/reserved.rs b/inout/src/reserved.rs index 101b29f0..d165fadc 100644 --- a/inout/src/reserved.rs +++ b/inout/src/reserved.rs @@ -168,7 +168,6 @@ impl<'inp, 'out> InOutBufReserved<'inp, 'out, u8> { /// # Errors /// If the padding is invalid #[inline(always)] - #[allow(clippy::missing_panics_doc)] pub fn into_padded_blocks(self) -> Result, PadError> where P: Padding, @@ -197,8 +196,13 @@ impl<'inp, 'out> InOutBufReserved<'inp, 'out, u8> { PaddedData::Error => return Err(PadError), }; - // This invariant must hold for all valid padding implementations. - debug_assert_eq!(blocks.len(), self.in_len / BS::USIZE); + // These invariants must hold for all valid padding implementations. + if blocks.as_ptr().cast() != self.in_ptr { + return Err(PadError); + } + if blocks.len() != self.in_len / BS::USIZE { + return Err(PadError); + } Ok(PaddedInOutBuf { in_ptr: blocks.as_ptr(),