-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sensitive types to SymmetricCryptoKey (#672)
## Type of change ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective This is a small subset of #536, which only contains the minimum code to protect the import/export functions on SymmetricCryptoKey. It also enables the from_base64 test on SymmetricCryptoKey as that passes now. After this PR is merged I'll be expanding the use of Sensitive to other parts of the codebase while adding some extra memory testing checks to validate that it works for them.
- Loading branch information
1 parent
9cd9a15
commit 538b9f2
Showing
26 changed files
with
381 additions
and
105 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use zeroize::Zeroize; | ||
|
||
use crate::{CryptoError, CryptoKey, KeyEncryptable, Sensitive}; | ||
|
||
/// Type alias for a [`Sensitive`] value to denote decrypted data. | ||
pub type Decrypted<V> = Sensitive<V>; | ||
pub type DecryptedVec = Decrypted<Vec<u8>>; | ||
pub type DecryptedString = Decrypted<String>; | ||
|
||
impl<T: KeyEncryptable<Key, Output> + Zeroize + Clone, Key: CryptoKey, Output> | ||
KeyEncryptable<Key, Output> for Decrypted<T> | ||
{ | ||
fn encrypt_with_key(self, key: &Key) -> Result<Output, CryptoError> { | ||
self.value.clone().encrypt_with_key(key) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[allow(clippy::module_inception)] | ||
mod sensitive; | ||
pub use sensitive::{Sensitive, SensitiveString, SensitiveVec}; | ||
mod decrypted; | ||
pub use decrypted::{Decrypted, DecryptedString, DecryptedVec}; |
Oops, something went wrong.