@@ -213,7 +213,7 @@ where
213213 // TODO(tarcieri): add offset param to `encrypt_inout_detached`
214214 buffer. as_mut ( ) . copy_within ( ..pt_len, IV_SIZE ) ;
215215
216- let tag = self . encrypt_inout_detached ( headers, & mut buffer. as_mut ( ) [ IV_SIZE ..] ) ?;
216+ let tag = self . encrypt_inout_detached ( headers, ( & mut buffer. as_mut ( ) [ IV_SIZE ..] ) . into ( ) ) ?;
217217 buffer. as_mut ( ) [ ..IV_SIZE ] . copy_from_slice ( tag. as_slice ( ) ) ;
218218 Ok ( ( ) )
219219 }
@@ -227,15 +227,15 @@ where
227227 pub fn encrypt_inout_detached < I , T > (
228228 & mut self ,
229229 headers : I ,
230- plaintext : InOutBuf < ' _ , ' _ , u8 > ,
230+ mut plaintext : InOutBuf < ' _ , ' _ , u8 > ,
231231 ) -> Result < Tag , Error >
232232 where
233233 I : IntoIterator < Item = T > ,
234234 T : AsRef < [ u8 ] > ,
235235 {
236236 // Compute the synthetic IV for this plaintext
237- let siv_tag = s2v ( & mut self . mac , headers, plaintext) ?;
238- self . xor_with_keystream ( siv_tag, plaintext) ;
237+ let siv_tag = s2v ( & mut self . mac , headers, plaintext. get_in ( ) ) ?;
238+ self . xor_with_keystream ( siv_tag, plaintext. get_out ( ) ) ;
239239 Ok ( siv_tag)
240240 }
241241
@@ -271,7 +271,7 @@ where
271271 }
272272
273273 let siv_tag = Tag :: try_from ( & buffer. as_ref ( ) [ ..IV_SIZE ] ) . expect ( "tag size mismatch" ) ;
274- self . decrypt_inout_detached ( headers, & mut buffer. as_mut ( ) [ IV_SIZE ..] , & siv_tag) ?;
274+ self . decrypt_inout_detached ( headers, ( & mut buffer. as_mut ( ) [ IV_SIZE ..] ) . into ( ) , & siv_tag) ?;
275275
276276 let pt_len = buffer. len ( ) - IV_SIZE ;
277277
@@ -290,22 +290,22 @@ where
290290 pub fn decrypt_inout_detached < I , T > (
291291 & mut self ,
292292 headers : I ,
293- ciphertext : InOutBuf < ' _ , ' _ , u8 > ,
293+ mut ciphertext : InOutBuf < ' _ , ' _ , u8 > ,
294294 siv_tag : & Tag ,
295295 ) -> Result < ( ) , Error >
296296 where
297297 I : IntoIterator < Item = T > ,
298298 T : AsRef < [ u8 ] > ,
299299 {
300- self . xor_with_keystream ( * siv_tag, ciphertext) ;
301- let computed_siv_tag = s2v ( & mut self . mac , headers, ciphertext) ?;
300+ self . xor_with_keystream ( * siv_tag, ciphertext. get_out ( ) ) ;
301+ let computed_siv_tag = s2v ( & mut self . mac , headers, ciphertext. get_in ( ) ) ?;
302302
303303 // Note: `CtOutput` provides constant-time equality
304304 if CtOutput :: < M > :: new ( computed_siv_tag) == CtOutput :: new ( * siv_tag) {
305305 Ok ( ( ) )
306306 } else {
307307 // Re-encrypt the decrypted plaintext to avoid revealing it
308- self . xor_with_keystream ( * siv_tag, ciphertext) ;
308+ self . xor_with_keystream ( * siv_tag, ciphertext. get_out ( ) ) ;
309309 Err ( Error )
310310 }
311311 }
0 commit comments