@@ -358,7 +358,7 @@ where
358358 let mut i = 1 ;
359359
360360 let mut offset_i = [ Block :: default ( ) ; WIDTH ] ;
361- offset_i[ offset_i . len ( ) - 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
361+ offset_i[ 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
362362 let mut checksum_i = Block :: default ( ) ;
363363
364364 let ( wide_blocks, tail) : ( InOutBuf < ' _ , ' _ , DoubleBlock > , _ ) = buffer. into_chunks ( ) ;
@@ -370,12 +370,10 @@ where
370370 }
371371
372372 // offset_i = offset_{i-1} xor L_{ntz(i)}
373- offset_i[ 0 ] = offset_i[ offset_i . len ( ) - 1 ] ;
373+ offset_i[ 0 ] = offset_i[ 1 ] ;
374374 inplace_xor ( & mut offset_i[ 0 ] , & self . ll [ ntz ( i) ] ) ;
375- for j in 1 ..p_i. len ( ) {
376- offset_i[ j] = offset_i[ j - 1 ] ;
377- inplace_xor ( & mut offset_i[ j] , & self . ll [ ntz ( i + j) ] ) ;
378- }
375+ offset_i[ 1 ] = offset_i[ 0 ] ;
376+ inplace_xor ( & mut offset_i[ 1 ] , & self . ll [ ntz ( i + 1 ) ] ) ;
379377
380378 // c_i = offset_i xor ENCIPHER(K, p_i xor offset_i)
381379 for j in 0 ..p_i. len ( ) {
@@ -403,20 +401,18 @@ where
403401 let mut i = 1 ;
404402
405403 let mut offset_i = [ Block :: default ( ) ; WIDTH ] ;
406- offset_i[ offset_i . len ( ) - 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
404+ offset_i[ 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
407405 let mut checksum_i = Block :: default ( ) ;
408406
409407 let ( wide_blocks, tail) : ( InOutBuf < ' _ , ' _ , DoubleBlock > , _ ) = buffer. into_chunks ( ) ;
410408 for wide_block in wide_blocks. into_iter ( ) {
411409 let mut c_i = split_into_two_blocks ( wide_block) ;
412410
413411 // offset_i = offset_{i-1} xor L_{ntz(i)}
414- offset_i[ 0 ] = offset_i[ offset_i . len ( ) - 1 ] ;
412+ offset_i[ 0 ] = offset_i[ 1 ] ;
415413 inplace_xor ( & mut offset_i[ 0 ] , & self . ll [ ntz ( i) ] ) ;
416- for j in 1 ..c_i. len ( ) {
417- offset_i[ j] = offset_i[ j - 1 ] ;
418- inplace_xor ( & mut offset_i[ j] , & self . ll [ ntz ( i + j) ] ) ;
419- }
414+ offset_i[ 1 ] = offset_i[ 0 ] ;
415+ inplace_xor ( & mut offset_i[ 1 ] , & self . ll [ ntz ( i + 1 ) ] ) ;
420416
421417 // p_i = offset_i xor DECIPHER(K, c_i xor offset_i)
422418 // checksum_i = checksum_{i-1} xor p_i
0 commit comments