diff --git a/zeroize/CHANGELOG.md b/zeroize/CHANGELOG.md index 102b4d08..72ae5e6b 100644 --- a/zeroize/CHANGELOG.md +++ b/zeroize/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). +## 1.9.2 (UNRELEASED) +### Changed +- Implement `optimization_barrier` using `core::hint::black_box` + on targets without stable `asm!` ([#1592]) + +[#1592]: https://github.com/RustCrypto/utils/pull/1592 + ## 1.9.1 (2026-10-06) ### Changed - Replace `Zeroizing`'s derived `Debug` with opaque impl ([#1497]) diff --git a/zeroize/src/barrier.rs b/zeroize/src/barrier.rs index d6a5004c..5336bb22 100644 --- a/zeroize/src/barrier.rs +++ b/zeroize/src/barrier.rs @@ -7,8 +7,7 @@ /// i.e. `aarch64`, `arm`, `arm64ec`, `loongarch64`, `riscv32`, `riscv64`, `s390x`, `x86`, and /// `x86_64`. /// -/// On all other targets it's implemented using [`core::hint::black_box`] and custom `black_box` -/// implemented using `#[inline(never)]` and `read_volatile`. +/// On all other targets it's implemented using [`core::hint::black_box`]. /// /// # Examples /// ``` @@ -86,19 +85,5 @@ pub fn optimization_barrier(val: &T) { target_arch = "x86_64", ) )))] - { - /// Custom version of `core::hint::black_box` implemented using - /// `#[inline(never)]` and `read_volatile`. - #[inline(never)] - fn custom_black_box(p: *const u8) { - use core::mem::MaybeUninit; - - let _: MaybeUninit = unsafe { core::ptr::read_volatile(p.cast()) }; - } - - core::hint::black_box(val); - if size_of_val(val) > 0 { - custom_black_box(core::ptr::from_ref(val).cast::()); - } - } + core::hint::black_box(val); }