News for hackers. Stuff that matters.
Re:How to securely encrypt a file with an insecure password ... by stouset on Wednesday January 19, 2022 @02:34PM (#29998810)
Alternatively, you could use secrets[1] (full disclosure, I'm the author). The secrecy crate does very little to prevent you from accidentally creating copies of secret data. Additionally, my crate punts to libsodium's memory management[2] API so provides all the features it does: memory is prevented from being paged to disk, memory is protected by `mprotect` when not being accessed, memory is protected with guard pages before and after, and memory is preceded by a canary to protect against underflow. secrets' functionality and protections are essentially a superset of secrecy's.

Additionally, there's support for stack-allocated secrets which lack some of the extra protections that heap-allocated secrets have, but is often a much more appropriate approach for short-lived secrets.

A downside of this is that it relies on unsafe code in order to call into libsodium and convert back and forth between pointers. And of course it has a libsodium dependency.

1: https://docs.rs/secrets/latest/secrets/

2: https://doc.libsodium.org/memory_management

There are no comments on this comment yet.