File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -309,6 +309,8 @@ mod recprot {
309309 . len ( )
310310 . checked_sub ( super :: TAG_LEN )
311311 . ok_or_else ( || Error :: from ( SEC_ERROR_BAD_DATA ) ) ?;
312+ let mut tag = [ 0u8 ; super :: TAG_LEN ] ;
313+ tag. copy_from_slice ( & data[ ct_len..] ) ;
312314 let data_ptr = data. as_mut_ptr ( ) ;
313315 let out_len = unsafe {
314316 aead_op (
@@ -318,7 +320,7 @@ mod recprot {
318320 aad,
319321 data_ptr,
320322 data. len ( ) ,
321- data_ptr . add ( ct_len ) ,
323+ tag . as_mut_ptr ( ) ,
322324 data_ptr. cast_const ( ) ,
323325 ct_len,
324326 )
Original file line number Diff line number Diff line change @@ -163,6 +163,13 @@ fn roundtrip(cipher: Cipher) {
163163 . decrypt ( 42 , AAD , ct, & mut pt_buf[ ..ct. len ( ) ] )
164164 . expect ( "decrypt" ) ;
165165 assert_eq ! ( pt, PLAINTEXT ) ;
166+
167+ let mut ip_buf = Vec :: from ( PLAINTEXT ) ;
168+ ip_buf. resize ( PLAINTEXT . len ( ) + aead. expansion ( ) , 0 ) ;
169+ let enc_len = aead. encrypt_in_place ( 42 , AAD , & mut ip_buf) . unwrap ( ) ;
170+ assert_eq ! ( enc_len, ip_buf. len( ) ) ;
171+ let dec_len = aead. decrypt_in_place ( 42 , AAD , & mut ip_buf) . unwrap ( ) ;
172+ assert_eq ! ( & ip_buf[ ..dec_len] , PLAINTEXT ) ;
166173}
167174
168175#[ test]
You can’t perform that action at this time.
0 commit comments