-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Securely erasing memory #2
Comments
There is more trouble in this regard in the initialization methods for the |
It seems like the only way to do this without stack bleaching would involve having several members of the structs as #[cfg(feature = "boxed")]
type Boxed<T> = Box<T>;
#[cfg(not(feature = "boxed"))]
type Boxed<T> = T;
pub fn new(arr: &[u8]) -> Boxed<Self> {
let mut s: Boxed<Self> = Boxed::new(Self {
hkdf: Hkdf::from_prk(arr).expect("should be long enough"),
hkdf_2: None,
kdf_key: Default::default(),
});
s.hkdf.expand(b"level 2 kdf", &mut s.kdf_key);
s.hkdf_2 = Some(Hkdf::from_prk(&s.kdf_key).expect("long enough"));
s
} Keep in mind that there would likely need to be a trait called |
Currently, there are a few aspects of this crate that can't be easily erased from memory:
hkdf
might use some temporary values as wellThis library doesn't perform some of the more large operations to be able to sufficiently implement "stack bleaching", such as signing data with private keys. This library merely generates the key, so a library that uses this library might be more suited for stack bleaching.
My question is: is it even worth it to eliminate all temporary variables, or should people try to use stack bleaching until there is a new development with Rust and/or the LLVM that allows for the developer to indicate that the compiler should not make certain stack data persist longer than required?
The text was updated successfully, but these errors were encountered: