Skip to content

Commit 6febd9f

Browse files
committed
fmt
1 parent b02d547 commit 6febd9f

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

zeroize_stack/src/lib.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
//! caller must ensure:
4040
//! - The stack size provided is large enough for the closure to run with.
4141
//! - The closure does not unwind or return control flow by any means other than
42-
//! directly returning. `std` users do not need to worry about this due to
42+
//! directly returning. `std` users do not need to worry about this due to
4343
//! the existence of `catch_unwind`.
4444
//!
4545
//! ## `nostd` Support
46-
//!
46+
//!
4747
//! This crate is compatible with `nostd` environments, but it is less safe
48-
//! in the event that your stack-switched stack panics. Panicking on a separate
49-
//! stack can cause undefined behavior (UB), but if it can be caught with
48+
//! in the event that your stack-switched stack panics. Panicking on a separate
49+
//! stack can cause undefined behavior (UB), but if it can be caught with
5050
//! `std::panic::catch_unwind`, that aspect of the safety should be more safe.
51-
//!
51+
//!
5252
//! ## Use Cases
5353
//!
5454
//! - Cryptographic routines
@@ -66,10 +66,7 @@ extern crate std;
6666
#[cfg(feature = "std")]
6767
use core::any::Any;
6868
#[cfg(feature = "std")]
69-
use std::{
70-
boxed::Box,
71-
panic::catch_unwind,
72-
};
69+
use std::{boxed::Box, panic::catch_unwind};
7370
#[cfg(feature = "std")]
7471
type StackSwitchResult<T> = Result<T, Box<dyn Any + Send>>;
7572
#[cfg(not(feature = "std"))]
@@ -79,7 +76,7 @@ use core::panic::{AssertUnwindSafe, UnwindSafe};
7976

8077
#[derive(Debug)]
8178
enum Error {
82-
StackPanicked
79+
StackPanicked,
8380
}
8481

8582
psm::psm_stack_manipulation! {
@@ -98,23 +95,23 @@ psm::psm_stack_manipulation! {
9895
/// * `crypto_fn` - the code to run while on the separate stack.
9996
///
10097
/// ## Panicking
101-
///
98+
///
10299
/// This function panics when `psm` detects that `on_stack` is unavailable.
103-
///
100+
///
104101
/// ## Errors
105-
///
106-
/// With the `std` feature enabled, this function will result in an error when
107-
/// the closure panics. You may want to log these errors securely, privately,
108-
/// as cryptography panics could be a little revealing if displayed to
102+
///
103+
/// With the `std` feature enabled, this function will result in an error when
104+
/// the closure panics. You may want to log these errors securely, privately,
105+
/// as cryptography panics could be a little revealing if displayed to
109106
/// the end user.
110-
///
107+
///
111108
/// ## Debugging
112-
///
113-
/// Using `#[inline(never)]` on the closure's function definition could
109+
///
110+
/// Using `#[inline(never)]` on the closure's function definition could
114111
/// make it easier to debug as the function should show up.
115-
///
112+
///
116113
/// # Safety
117-
///
114+
///
118115
/// * The stack needs to be large enough for `crypto_fn()` to execute without
119116
/// overflow.
120117
/// * `nostd` only: `crypto_fn()` must not unwind or return control flow by any other means
@@ -128,7 +125,7 @@ psm::psm_stack_manipulation! {
128125
"Stack size must be greater than 0 kb and `* 1024` must not overflow `isize`"
129126
);
130127
let mut stack = create_aligned_vec(stack_size_kb as usize, align_of::<u128>());
131-
128+
132129
let res = unsafe {
133130
psm::on_stack(stack.as_mut_ptr(), stack.len(), || {
134131
#[cfg(not(feature = "std"))]

0 commit comments

Comments
 (0)