Skip to content

Commit

Permalink
Per Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Apr 25, 2024
1 parent e5c3e8a commit 1e50e90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions aws-lc-rs/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl Debug for EncryptingKey {
f.debug_struct("EncryptingKey")
.field("algorithm", self.algorithm)
.field("mode", &self.mode)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -532,7 +532,7 @@ impl Debug for DecryptingKey {
f.debug_struct("DecryptingKey")
.field("algorithm", &self.algorithm)
.field("mode", &self.mode)
.finish()
.finish_non_exhaustive()
}
}

Expand All @@ -556,14 +556,10 @@ fn encrypt(

match mode {
OperatingMode::CBC => match algorithm.id() {
AlgorithmId::Aes128 | AlgorithmId::Aes256 => {
encrypt_aes_cbc_mode(&key, context, in_out)
}
AlgorithmId::Aes128 | AlgorithmId::Aes256 => encrypt_aes_cbc_mode(key, context, in_out),
},
OperatingMode::CTR => match algorithm.id() {
AlgorithmId::Aes128 | AlgorithmId::Aes256 => {
encrypt_aes_ctr_mode(&key, context, in_out)
}
AlgorithmId::Aes128 | AlgorithmId::Aes256 => encrypt_aes_ctr_mode(key, context, in_out),
},
}
}
Expand Down Expand Up @@ -757,28 +753,28 @@ mod tests {
UnboundCipherKey::new(&AES_128, key_bytes).unwrap(),
)
.unwrap();
assert_eq!("PaddedBlockEncryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CBC, padding: PKCS7 }", format!("{key:?}"));
assert_eq!("PaddedBlockEncryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CBC, padding: PKCS7, .. }", format!("{key:?}"));
let mut data = vec![0u8; 16];
let context = key.encrypt(&mut data).unwrap();
assert_eq!("Iv128", format!("{context:?}"));
let key = PaddedBlockDecryptingKey::cbc_pkcs7(
UnboundCipherKey::new(&AES_128, key_bytes).unwrap(),
)
.unwrap();
assert_eq!("PaddedBlockDecryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CBC, padding: PKCS7 }", format!("{key:?}"));
assert_eq!("PaddedBlockDecryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CBC, padding: PKCS7, .. }", format!("{key:?}"));
}

{
let key_bytes = &[0u8; 16];
let key =
EncryptingKey::ctr(UnboundCipherKey::new(&AES_128, key_bytes).unwrap()).unwrap();
assert_eq!("EncryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CTR }", format!("{key:?}"));
assert_eq!("EncryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CTR, .. }", format!("{key:?}"));
let mut data = vec![0u8; 16];
let context = key.encrypt(&mut data).unwrap();
assert_eq!("Iv128", format!("{context:?}"));
let key =
DecryptingKey::ctr(UnboundCipherKey::new(&AES_128, key_bytes).unwrap()).unwrap();
assert_eq!("DecryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CTR }", format!("{key:?}"));
assert_eq!("DecryptingKey { algorithm: Algorithm { id: Aes128, key_len: 16, block_len: 16 }, mode: CTR, .. }", format!("{key:?}"));
}
}

Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/cipher/padded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Debug for PaddedBlockEncryptingKey {
.field("algorithm", &self.algorithm)
.field("mode", &self.mode)
.field("padding", &self.padding)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -252,7 +252,7 @@ impl Debug for PaddedBlockDecryptingKey {
.field("algorithm", &self.algorithm)
.field("mode", &self.mode)
.field("padding", &self.padding)
.finish()
.finish_non_exhaustive()
}
}

Expand Down

0 comments on commit 1e50e90

Please sign in to comment.