rust-keyutils
rust-keyutils copied to clipboard
Secure the payload with mlock
Also probably offer a structure for locking it down on its way in as well.
http://ironframework.io/doc/libc/funcs/posix88/mman/fn.munlock.html
I would propose a different approach here and in #8. Rust crates like secstr https://crates.io/crates/secstr already do this. You could either take a dependency on them, or just make keyutils compatible with secstr by just always taking data by reference.
Hmm. It seems that by using Cow<[u8]> in the KeyPayload, the "take by reference" is always up to the user. I do see some potential holes:
keytypes::encrypted::Payload::Loadis aVec<u8>of data to load into the key. This is then placed into aStringwhich takes it out of any secure storagekeytypes::rxrpc::Payload::session_keymight warrant being in a secure array.keytypes::rxrpc_s::Payload::keyprobably needs to be in one as well.keytypes::trusted::Payloadhas some potentially sensitive information stored in aVec.
Hmm. The caller using SecBox around the entire payload should be sufficient for rxrpc's bits (since they're static-sized arrays). The ticket in rxrpc::Payload and other Vec<u8> bits should probably be SecVec<u8> now. Thoughts?
Hrm. Returning a Cow::Owned moves the struct data back into a blob not in a zero-ing block of memory.