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

Consider zeroing memory on drop for key #3791

Open
touilleMan opened this issue Dec 26, 2022 · 2 comments
Open

Consider zeroing memory on drop for key #3791

touilleMan opened this issue Dec 26, 2022 · 2 comments

Comments

@touilleMan
Copy link
Member

Now that all crypto is implemented in Rust, we may be able to use zeroise (but maybe not: RustCrypto/AEADs#65)

I guess we should use zeroize:

  • On bytes buffer that receive decrypted data (given decrypted data often contains key in cleartext)
  • On structures deserialize the bytes buffer: I guess Zeorizing is transparent from serde/serde_as point of view
  • On final Key object (both for sodiumoxide and RustCrypto), this is what we should check first as it is very possible they work as opaque objects where we cannot simply ensure no copy of sensitive data occurs or that zeroing on drop is possible1

Footnotes

  1. My current guess is this is possible given we have wrapped the Sodiumoxide/RustCrypto key structure in our own key structure, so we could do something like struct MyPrivateKey { key: Zeroizing<SodiumOxidePrivateKey> } which should do the trick (well unless the key is actually stored on the head, or is copied during decryption :/)

@touilleMan touilleMan mentioned this issue Dec 26, 2022
1 task
@FirelightFlagboy
Copy link
Contributor

FirelightFlagboy commented Sep 1, 2023

Currently the codebase seems to partially use Zeroise. what need to add zeroise support:

  • rustcrypto::private::PrivateKey
  • rustcrypto::secret::SecretKey
  • rustcrypto::sequester::SequesterPrivateKeyDer
  • rustcrypto::sequester::SequesterSigningKeyDer
  • rustcrypto::sign::SigningKey
  • sodiumoxide::private::PrivateKey
  • sodiumoxide::secret::SecretKey
  • sodiumoxide::sequester::SequesterPrivateKeyDer
  • sodiumoxide::sequester::SequesterSigningKeyDer
  • sodiumoxide::sign::SigningKey

@TimeEngineer
Copy link
Contributor

TimeEngineer commented Feb 15, 2024

Some keys have zeroize support already.

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

3 participants