Skip to content

Commit

Permalink
zeroize: Remove some unsafe code
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlf committed Oct 29, 2023
1 parent 6c39ebb commit ca89cfc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
21 changes: 21 additions & 0 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 zeroize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rust-version = "1.60"
[dependencies]
serde = { version = "1.0", default-features = false, optional = true }
zeroize_derive = { version = "1.3", path = "derive", optional = true }
zerocopy = { version = "0.7.19", default-features = false, features = ["simd"] }

[features]
default = ["alloc"]
Expand Down
4 changes: 3 additions & 1 deletion zeroize/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use crate::{atomic_fence, volatile_write, Zeroize};

use core::arch::aarch64::*;

use zerocopy::FromZeroes;

macro_rules! impl_zeroize_for_simd_register {
($($type:ty),* $(,)?) => {
$(
#[cfg_attr(docsrs, doc(cfg(target_arch = "aarch64")))]
impl Zeroize for $type {
#[inline]
fn zeroize(&mut self) {
volatile_write(self, unsafe { core::mem::zeroed() });
volatile_write(self, Self::new_zeroed());
atomic_fence();
}
}
Expand Down
4 changes: 3 additions & 1 deletion zeroize/src/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;

use zerocopy::FromZeroes;

macro_rules! impl_zeroize_for_simd_register {
($($type:ty),* $(,)?) => {
$(
#[cfg_attr(docsrs, doc(cfg(any(target_arch = "x86", target_arch = "x86_64"))))]
impl Zeroize for $type {
#[inline]
fn zeroize(&mut self) {
volatile_write(self, unsafe { core::mem::zeroed() });
volatile_write(self, Self::new_zeroed());
atomic_fence();
}
}
Expand Down

0 comments on commit ca89cfc

Please sign in to comment.