-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a feature which transitively enables zeroization support in various dependencies. `ssh-key` now activates it by default.
- Loading branch information
Showing
4 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,9 @@ use cipher::{KeyIvInit, StreamCipher, StreamCipherSeek}; | |
use poly1305::Poly1305; | ||
use subtle::ConstantTimeEq; | ||
|
||
#[cfg(feature = "zeroize")] | ||
use zeroize::{Zeroize, ZeroizeOnDrop}; | ||
|
||
/// Key for `[email protected]`. | ||
pub type ChaChaKey = chacha20::Key; | ||
|
||
|
@@ -29,7 +32,6 @@ pub type ChaChaNonce = chacha20::LegacyNonce; | |
/// [RFC8439]: https://datatracker.ietf.org/doc/html/rfc8439 | ||
#[derive(Clone)] | ||
pub struct ChaCha20Poly1305 { | ||
// TODO(tarcieri): zeroize on drop | ||
key: ChaChaKey, | ||
} | ||
|
||
|
@@ -93,6 +95,16 @@ impl ChaCha20Poly1305 { | |
} | ||
} | ||
|
||
impl Drop for ChaCha20Poly1305 { | ||
fn drop(&mut self) { | ||
#[cfg(feature = "zeroize")] | ||
self.key.zeroize(); | ||
} | ||
} | ||
|
||
#[cfg(feature = "zeroize")] | ||
impl ZeroizeOnDrop for ChaCha20Poly1305 {} | ||
|
||
/// Internal type representing a cipher instance. | ||
struct Cipher { | ||
cipher: ChaCha20, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters