diff options
author | Stuart Stock <stuart@int08h.com> | 2019-08-11 18:09:26 -0500 |
---|---|---|
committer | Stuart Stock <stuart@int08h.com> | 2019-08-11 18:09:26 -0500 |
commit | 266f1adc99f780edab22096ed13f624bfdcb6674 (patch) | |
tree | 8185063cc9653105067c1e9caaf2495c289054bc /src/kms | |
parent | a0165c01946efbedd2f274bad02a33ab52c01e32 (diff) | |
download | roughenough-266f1adc99f780edab22096ed13f624bfdcb6674.zip |
Address clippy lints
* More consistent use of `dyn`
* Add default implementations
* Misc clippy changes
Diffstat (limited to 'src/kms')
-rw-r--r-- | src/kms/envelope.rs | 4 | ||||
-rw-r--r-- | src/kms/mod.rs | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/kms/envelope.rs b/src/kms/envelope.rs index d83aa64..5533450 100644 --- a/src/kms/envelope.rs +++ b/src/kms/envelope.rs @@ -62,7 +62,7 @@ pub struct EnvelopeEncryption; impl EnvelopeEncryption { /// Decrypt a seed previously encrypted with `encrypt_seed()` - pub fn decrypt_seed(kms: &KmsProvider, ciphertext_blob: &[u8]) -> Result<Vec<u8>, KmsError> { + pub fn decrypt_seed(kms: &dyn KmsProvider, ciphertext_blob: &[u8]) -> Result<Vec<u8>, KmsError> { if ciphertext_blob.len() < MIN_PAYLOAD_SIZE { return Err(KmsError::InvalidData(format!( "ciphertext too short: min {}, found {}", @@ -121,7 +121,7 @@ impl EnvelopeEncryption { /// /// The returned encrypted byte blob is safe to store on unsecured media. /// - pub fn encrypt_seed(kms: &KmsProvider, plaintext_seed: &[u8]) -> Result<Vec<u8>, KmsError> { + pub fn encrypt_seed(kms: &dyn KmsProvider, plaintext_seed: &[u8]) -> Result<Vec<u8>, KmsError> { // Generate random DEK and nonce let rng = SystemRandom::new(); let mut dek = [0u8; DEK_SIZE_BYTES]; diff --git a/src/kms/mod.rs b/src/kms/mod.rs index 96d732c..37793e8 100644 --- a/src/kms/mod.rs +++ b/src/kms/mod.rs @@ -144,7 +144,7 @@ pub use crate::kms::awskms::inner::AwsKms; /// the plaintext seed value. /// #[cfg(feature = "awskms")] -pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> { +pub fn load_seed(config: &dyn ServerConfig) -> Result<Vec<u8>, error::Error> { match config.kms_protection() { KmsProtection::Plaintext => Ok(config.seed()), KmsProtection::AwsKmsEnvelope(key_id) => { @@ -178,7 +178,7 @@ pub use crate::kms::gcpkms::inner::GcpKms; /// the plaintext seed value. /// #[cfg(feature = "gcpkms")] -pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> { +pub fn load_seed(config: &dyn ServerConfig) -> Result<Vec<u8>, error::Error> { match config.kms_protection() { KmsProtection::Plaintext => Ok(config.seed()), KmsProtection::GoogleKmsEnvelope(resource_id) => { @@ -205,7 +205,7 @@ pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> { /// * `config.seed()` is used as-is and assumed to be a 32-byte hexadecimal value /// #[cfg(not(any(feature = "awskms", feature = "gcpkms")))] -pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> { +pub fn load_seed(config: &dyn ServerConfig) -> Result<Vec<u8>, error::Error> { match config.kms_protection() { KmsProtection::Plaintext => Ok(config.seed()), v => Err(error::Error::InvalidConfiguration(format!( |