Skip to content
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

Original data are not actually zeroed #4

Closed
oblique opened this issue Jan 5, 2020 · 2 comments
Closed

Original data are not actually zeroed #4

oblique opened this issue Jan 5, 2020 · 2 comments

Comments

@oblique
Copy link
Contributor

oblique commented Jan 5, 2020

Consider this example:

use seckey::SecKey;

fn main() {
    let buf: [u8; 7] = [1, 2, 3, 4, 5, 6, 7];
    let orig_data = unsafe { std::slice::from_raw_parts(buf.as_ptr(), buf.len()) };

    let sec = SecKey::new(buf).unwrap();

    dbg!(orig_data);
}

Because buf is an array, by moving it, you are actually copying it to another place on the stack. So, original data stay there untouched and never zeroed.

I was thinking that &mut T could be a solution, but this will make SecKey unsafe.
What do you think?

@quininer
Copy link
Owner

quininer commented Jan 5, 2020

A few years ago I tried to solve this problem with inplace syntax, which has been deprecated.

@quininer
Copy link
Owner

quininer commented Aug 5, 2020

close by 0.11

@quininer quininer closed this as completed Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants