diff --git a/mbedtls/src/cipher/mod.rs b/mbedtls/src/cipher/mod.rs index 53622d845..afa4e9817 100644 --- a/mbedtls/src/cipher/mod.rs +++ b/mbedtls/src/cipher/mod.rs @@ -458,13 +458,11 @@ fn aes_kwp() { assert_eq!(p, &p_out[..out_len]); } - #[test] fn aes_gcm() { let k = [ - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, - 0x4f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, - 0x4e, 0x4f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x40, 0x41, 0x42, 0x43, + 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, ]; let iv = [0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16]; @@ -475,23 +473,14 @@ fn aes_gcm() { let mut p_out = [0u8; 4]; let mut c_out = [0u8; 8]; - let cipher = Cipher::::new( - raw::CipherId::Aes, - raw::CipherMode::GCM, - (k.len() * 8) as _, - ) - .unwrap(); + let cipher = + Cipher::::new(raw::CipherId::Aes, raw::CipherMode::GCM, (k.len() * 8) as _).unwrap(); let cipher = cipher.set_key_iv(&k, &iv).unwrap(); cipher.encrypt_auth(&ad, &p, &mut c_out, 4).unwrap(); assert_eq!(c, c_out[0..4]); assert_eq!(t, c_out[4..8]); - let cipher = Cipher::<_, Authenticated, _>::new( - raw::CipherId::Aes, - raw::CipherMode::GCM, - (k.len() * 8) as _, - ) - .unwrap(); + let cipher = Cipher::<_, Authenticated, _>::new(raw::CipherId::Aes, raw::CipherMode::GCM, (k.len() * 8) as _).unwrap(); let cipher = cipher.set_key_iv(&k, &iv).unwrap(); cipher.decrypt_auth(&ad, &c_out, &mut p_out, 4).unwrap(); assert_eq!(p, p_out); diff --git a/mbedtls/src/cipher/raw/mod.rs b/mbedtls/src/cipher/raw/mod.rs index 8e414c86d..3b1a944f5 100644 --- a/mbedtls/src/cipher/raw/mod.rs +++ b/mbedtls/src/cipher/raw/mod.rs @@ -330,13 +330,7 @@ impl Cipher { self.do_crypto(cipher, plain) } - pub fn encrypt_auth( - &mut self, - ad: &[u8], - plain: &[u8], - cipher_and_tag: &mut [u8], - tag_len: usize, - ) -> Result { + pub fn encrypt_auth(&mut self, ad: &[u8], plain: &[u8], cipher_and_tag: &mut [u8], tag_len: usize) -> Result { if cipher_and_tag .len() .checked_sub(tag_len) @@ -402,12 +396,7 @@ impl Cipher { Ok(plain_len) } - pub fn encrypt_auth_inplace( - &mut self, - ad: &[u8], - data: &mut [u8], - tag: &mut [u8], - ) -> Result { + pub fn encrypt_auth_inplace(&mut self, ad: &[u8], data: &mut [u8], tag: &mut [u8]) -> Result { let iv = self.inner.iv; let iv_len = self.inner.iv_size; let mut olen = data.len(); @@ -431,12 +420,7 @@ impl Cipher { Ok(olen) } - pub fn decrypt_auth_inplace( - &mut self, - ad: &[u8], - data: &mut [u8], - tag: &[u8], - ) -> Result { + pub fn decrypt_auth_inplace(&mut self, ad: &[u8], data: &mut [u8], tag: &[u8]) -> Result { let iv = self.inner.iv; let iv_len = self.inner.iv_size; let mut plain_len = data.len(); @@ -538,8 +522,5 @@ fn cmac_test() { &mut out, ) .expect("Success in CMAC"); - assert_eq!( - &out, - b"\x38\x7b\x36\x22\x8b\xa7\x77\x44\x5b\xaf\xa0\x36\x45\xb9\x40\x10" - ); + assert_eq!(&out, b"\x38\x7b\x36\x22\x8b\xa7\x77\x44\x5b\xaf\xa0\x36\x45\xb9\x40\x10"); }