Skip to content

Commit 075d06b

Browse files
committed
moved to zeroize_stack
1 parent 3e3a737 commit 075d06b

File tree

10 files changed

+57
-133
lines changed

10 files changed

+57
-133
lines changed

Cargo.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ members = [
1414
"opaque-debug",
1515
"wycheproof2blb",
1616
"zeroize",
17-
"zeroize_derive"
17+
"zeroize_derive",
18+
"zeroize_stack"
1819
]
1920
exclude = ["aarch64-dit"]
2021

zeroize/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ edition = "2024"
1919
rust-version = "1.85"
2020

2121
[dependencies]
22-
psm = { version = "0.1.26", optional = true }
2322
serde = { version = "1.0", default-features = false, optional = true }
2423
zeroize_derive = { version = "1.4", path = "../zeroize_derive", optional = true }
2524

2625
[features]
2726
default = ["alloc"]
2827
alloc = []
29-
stack_sanitization = ["psm"]
3028
std = ["alloc"]
3129

3230
aarch64 = [] # NOTE: vestigial no-op feature; AArch64 support is always enabled now

zeroize/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,6 @@ mod aarch64;
250250
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
251251
mod x86;
252252

253-
#[cfg(feature = "stack_sanitization")]
254-
mod stack_sanitization;
255-
256-
#[cfg(feature = "stack_sanitization")]
257-
pub use stack_sanitization::secure_crypto_call_heap;
258-
259-
#[cfg(all(feature = "stack_sanitization", feature = "alloc"))]
260-
pub use stack_sanitization::create_aligned_vec;
261-
262253
use core::{
263254
marker::{PhantomData, PhantomPinned},
264255
mem::{MaybeUninit, size_of},

zeroize/src/stack_sanitization.rs

Lines changed: 0 additions & 86 deletions
This file was deleted.

zeroize/tests/stack_sanitization.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

stack_sanitizer/Cargo.toml renamed to zeroize_stack/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
2-
name = "stack_sanitizer"
2+
name = "zeroize_stack"
33
version = "0.1.0"
44
description = """
5-
Securely sanitize the stack with a simple function built on
6-
the Portable Stack Manipulation (psm) crate.
5+
Securely zeroize the stack with a simple function built on
6+
the Portable Stack Manipulation (psm) crate and zeroize crate.
77
"""
88
authors = ["The RustCrypto Project Developers"]
99
license = "Apache-2.0 OR MIT"
@@ -16,7 +16,7 @@ edition = "2024"
1616
rust-version = "1.85"
1717

1818
[dependencies]
19-
psm = { version = "0.1.26", optional = true }
19+
psm = "0.1.26"
2020
zeroize = { version = "1.0" }
2121

2222
[features]

stack_sanitizer/README.md renamed to zeroize_stack/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [RustCrypto]: stack_sanitizer
1+
# [RustCrypto]: zeroize_stack
22

33
[![Crate][crate-image]][crate-link]
44
[![Docs][docs-image]][docs-link]
@@ -21,9 +21,9 @@ as make extra copies of data on the stack that cannot be easily zeroed. That's
2121
what this crate is for.
2222

2323
This crate isn't about tricks: it uses [psm::on_stack] to run a function on
24-
a portable stack, and then uses [zeroize] to zero the stack. `psm` implements
25-
all of the assembly for several different architectures, whereas the [zeroize]
26-
segment was implemented in pure Rust.
24+
a portable stack, and then uses [zeroize] to zero that stack. `psm` implements
25+
all of the assembly for several different architectures, and the [zeroize]
26+
portion of the task was implemented in pure Rust.
2727

2828
- `#![no_std]` i.e. **embedded-friendly**! (`alloc` is required)
2929
- No functionality besides securely zeroing the a function's stack usage!

stack_sanitizer/src/lib.rs renamed to zeroize_stack/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! # stack_bleach
1+
//! # zeroize_stack
22
//!
33
//! A crate for sanitizing stack memory after sensitive operations—sometimes referred to as _Stack Bleaching_.
44
//!
@@ -47,9 +47,9 @@ extern crate alloc;
4747

4848
use alloc::{vec, vec::Vec};
4949

50-
/// Executes a function/closure and clears the function's stack frames by using
50+
/// Executes a function/closure and clears the function's stack by using
5151
/// preallocated space on the heap as the function's stack, and then zeroing
52-
/// that allocated data once the code has ran.
52+
/// that allocated space once the code has ran.
5353
///
5454
/// This function does not clear the CPU registers.
5555
///
@@ -58,7 +58,7 @@ use alloc::{vec, vec::Vec};
5858
/// * `stack_size_kb` - how large the stack will be. `psm` recommends at least
5959
/// `4 KB` of stack size, but the total size cannot overflow an `isize`. Also,
6060
/// some architectures might consume more memory in the stack, such as SPARC.
61-
/// * `crypto_fn` - the code to run while on separate stack.
61+
/// * `crypto_fn` - the code to run while on the separate stack.
6262
///
6363
/// # Safety
6464
///

stack_sanitizer/tests/stack_sanitization.rs renamed to zeroize_stack/tests/zeroize_stack.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! Stack sanitization integration tests
22
33
mod stack_sanitization_tests {
4-
use stack_sanitizer::exec_on_sanitized_stack;
4+
use zeroize_stack::exec_on_sanitized_stack;
55

6+
#[inline(never)]
67
fn dummy_fn() -> (*const u8, u64) {
78
let temporary_data = 42;
89
let ptr = temporary_data as *const u8;
@@ -13,7 +14,8 @@ mod stack_sanitization_tests {
1314
fn stack_sanitization_v2() {
1415
let result = unsafe { exec_on_sanitized_stack(4, || dummy_fn()) };
1516
assert_eq!(result.1, 12345);
16-
// results in segmentation fault
17+
// results in segmentation fault, which is somewhat normal... just wanted
18+
// to try it
1719
// assert_eq!(unsafe {*result.0}, 42);
1820
}
1921
}

0 commit comments

Comments
 (0)