@@ -103,21 +103,21 @@ pub use aead::{self, AeadCore, AeadInOut, Error, Key, KeyInit, KeySizeUser};
103103#[ cfg( feature = "aes" ) ]
104104pub use aes;
105105
106- use aead:: { inout:: InOutBuf , PostfixTagged } ;
106+ use aead:: { PostfixTagged , inout:: InOutBuf } ;
107107
108108use cipher:: {
109+ BlockCipherEncrypt , BlockSizeUser , InnerIvInit , StreamCipherCore ,
109110 array:: { Array , ArraySize } ,
110111 consts:: U16 ,
111- BlockCipherEncrypt , BlockSizeUser , InnerIvInit , StreamCipherCore ,
112112} ;
113113use core:: marker:: PhantomData ;
114- use ghash:: { universal_hash:: UniversalHash , GHash } ;
114+ use ghash:: { GHash , universal_hash:: UniversalHash } ;
115115
116116#[ cfg( feature = "zeroize" ) ]
117117use zeroize:: Zeroize ;
118118
119119#[ cfg( feature = "aes" ) ]
120- use aes:: { cipher:: consts:: U12 , Aes128 , Aes256 } ;
120+ use aes:: { Aes128 , Aes256 , cipher:: consts:: U12 } ;
121121
122122/// Maximum length of associated data.
123123pub const A_MAX : u64 = 1 << 36 ;
@@ -270,7 +270,7 @@ where
270270 & self ,
271271 nonce : & Nonce < NonceSize > ,
272272 associated_data : & [ u8 ] ,
273- buffer : InOutBuf < ' _ , ' _ , u8 > ,
273+ mut buffer : InOutBuf < ' _ , ' _ , u8 > ,
274274 ) -> Result < Tag < TagSize > , Error > {
275275 if buffer. len ( ) as u64 > P_MAX || associated_data. len ( ) as u64 > A_MAX {
276276 return Err ( Error ) ;
@@ -280,17 +280,17 @@ where
280280
281281 // TODO(tarcieri): interleave encryption with GHASH
282282 // See: <https://github.com/RustCrypto/AEADs/issues/74>
283- ctr. apply_keystream_partial ( buffer. into ( ) ) ;
283+ ctr. apply_keystream_partial ( buffer. reborrow ( ) ) ;
284284
285- let full_tag = self . compute_tag ( mask, associated_data, buffer) ;
285+ let full_tag = self . compute_tag ( mask, associated_data, buffer. get_in ( ) ) ;
286286 Ok ( Tag :: try_from ( & full_tag[ ..TagSize :: to_usize ( ) ] ) . expect ( "tag size mismatch" ) )
287287 }
288288
289289 fn decrypt_inout_detached (
290290 & self ,
291291 nonce : & Nonce < NonceSize > ,
292292 associated_data : & [ u8 ] ,
293- buffer : InOutBuf < ' _ , ' _ , u8 > ,
293+ mut buffer : InOutBuf < ' _ , ' _ , u8 > ,
294294 tag : & Tag < TagSize > ,
295295 ) -> Result < ( ) , Error > {
296296 if buffer. len ( ) as u64 > C_MAX || associated_data. len ( ) as u64 > A_MAX {
@@ -301,11 +301,11 @@ where
301301
302302 // TODO(tarcieri): interleave encryption with GHASH
303303 // See: <https://github.com/RustCrypto/AEADs/issues/74>
304- let expected_tag = self . compute_tag ( mask, associated_data, buffer) ;
304+ let expected_tag = self . compute_tag ( mask, associated_data, buffer. get_out ( ) ) ;
305305
306306 use subtle:: ConstantTimeEq ;
307307 if expected_tag[ ..TagSize :: to_usize ( ) ] . ct_eq ( tag) . into ( ) {
308- ctr. apply_keystream_partial ( buffer. into ( ) ) ;
308+ ctr. apply_keystream_partial ( buffer) ;
309309 Ok ( ( ) )
310310 } else {
311311 Err ( Error )
0 commit comments