File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,15 +73,10 @@ where
7373{
7474 /// Decrypt data using `InOutBuf`.
7575 pub fn decrypt_inout ( & mut self , data : InOutBuf < ' _ , ' _ , u8 > ) {
76- let ( blocks, mut tail) = data. into_chunks ( ) ;
76+ let ( blocks, tail) = data. into_chunks ( ) ;
77+ // Block size is equal to 1 byte, so the tail must be always empty
78+ assert ! ( tail. is_empty( ) ) ;
7779 self . decrypt_blocks_inout ( blocks) ;
78- let n = tail. len ( ) ;
79- if n != 0 {
80- let mut block = Block :: < Self > :: default ( ) ;
81- block[ ..n] . copy_from_slice ( tail. get_in ( ) ) ;
82- self . decrypt_block ( & mut block) ;
83- tail. get_out ( ) . copy_from_slice ( & block[ ..n] ) ;
84- }
8580 }
8681
8782 /// Decrypt data in place.
Original file line number Diff line number Diff line change @@ -73,15 +73,10 @@ where
7373{
7474 /// Encrypt data using `InOutBuf`.
7575 pub fn encrypt_inout ( & mut self , data : InOutBuf < ' _ , ' _ , u8 > ) {
76- let ( blocks, mut tail) = data. into_chunks ( ) ;
76+ let ( blocks, tail) = data. into_chunks ( ) ;
77+ // Block size is equal to 1 byte, so the tail must be always empty
78+ assert ! ( tail. is_empty( ) ) ;
7779 self . encrypt_blocks_inout ( blocks) ;
78- let n = tail. len ( ) ;
79- if n != 0 {
80- let mut block = Block :: < Self > :: default ( ) ;
81- block[ ..n] . copy_from_slice ( tail. get_in ( ) ) ;
82- self . encrypt_block ( & mut block) ;
83- tail. get_out ( ) . copy_from_slice ( & block[ ..n] ) ;
84- }
8580 }
8681
8782 /// Encrypt data in place.
You can’t perform that action at this time.
0 commit comments