-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Best effort zeroisation of secret data
- ecdsa: intermediate private key encoding - aarch64::aes: round keys - aarch64::ghash: hash key powers - posint: newtype for sensitive ones: use in rsa_priv. erase modexp powers. - x86_64::aes: round keys - x86_64::ghash: hash key powers - p256: scalar & shared secret - p384: scalar & shared secret - x25519: private key & shared secret
- Loading branch information
Showing
19 changed files
with
408 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Written for Graviola by Joe Birr-Pixton, 2024. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 | ||
|
||
use crate::low::zero_bytes; | ||
|
||
/// Writes zeroes over the whole of the `v` slice. | ||
pub(crate) fn zeroise<T: Zeroable>(v: &mut [T]) { | ||
zero_bytes(v.as_mut_ptr().cast(), size_of_val(v)); | ||
} | ||
|
||
/// Writes zeroes over the whole of the `v` value. | ||
pub(crate) fn zeroise_value<T: Zeroable>(v: &mut T) { | ||
zero_bytes(v as *mut T as *mut _, size_of::<T>()); | ||
} | ||
|
||
/// Marker trait for types who have valid all-bits-zero values. | ||
pub(crate) trait Zeroable {} | ||
|
||
impl Zeroable for u8 {} | ||
impl Zeroable for u64 {} | ||
impl Zeroable for usize {} | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
impl Zeroable for core::arch::x86_64::__m256i {} | ||
#[cfg(target_arch = "x86_64")] | ||
impl Zeroable for core::arch::x86_64::__m128i {} | ||
|
||
#[cfg(target_arch = "aarch64")] | ||
impl Zeroable for core::arch::aarch64::uint8x16_t {} | ||
#[cfg(target_arch = "aarch64")] | ||
impl Zeroable for core::arch::aarch64::uint64x2_t {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.