@@ -357,7 +357,7 @@ where
357357 let mut i = 1 ;
358358
359359 let mut offset_i = [ Block :: default ( ) ; WIDTH ] ;
360- offset_i[ offset_i . len ( ) - 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
360+ offset_i[ 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
361361 let mut checksum_i = Block :: default ( ) ;
362362
363363 let ( wide_blocks, tail) : ( InOutBuf < ' _ , ' _ , DoubleBlock > , _ ) = buffer. into_chunks ( ) ;
@@ -369,12 +369,10 @@ where
369369 }
370370
371371 // offset_i = offset_{i-1} xor L_{ntz(i)}
372- offset_i[ 0 ] = offset_i[ offset_i . len ( ) - 1 ] ;
372+ offset_i[ 0 ] = offset_i[ 1 ] ;
373373 inplace_xor ( & mut offset_i[ 0 ] , & self . ll [ ntz ( i) ] ) ;
374- for j in 1 ..p_i. len ( ) {
375- offset_i[ j] = offset_i[ j - 1 ] ;
376- inplace_xor ( & mut offset_i[ j] , & self . ll [ ntz ( i + j) ] ) ;
377- }
374+ offset_i[ 1 ] = offset_i[ 0 ] ;
375+ inplace_xor ( & mut offset_i[ 1 ] , & self . ll [ ntz ( i + 1 ) ] ) ;
378376
379377 // c_i = offset_i xor ENCIPHER(K, p_i xor offset_i)
380378 for j in 0 ..p_i. len ( ) {
@@ -402,20 +400,18 @@ where
402400 let mut i = 1 ;
403401
404402 let mut offset_i = [ Block :: default ( ) ; WIDTH ] ;
405- offset_i[ offset_i . len ( ) - 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
403+ offset_i[ 1 ] = initial_offset ( & self . cipher , nonce, TagSize :: to_u32 ( ) ) ;
406404 let mut checksum_i = Block :: default ( ) ;
407405
408406 let ( wide_blocks, tail) : ( InOutBuf < ' _ , ' _ , DoubleBlock > , _ ) = buffer. into_chunks ( ) ;
409407 for wide_block in wide_blocks. into_iter ( ) {
410408 let mut c_i = split_into_two_blocks ( wide_block) ;
411409
412410 // offset_i = offset_{i-1} xor L_{ntz(i)}
413- offset_i[ 0 ] = offset_i[ offset_i . len ( ) - 1 ] ;
411+ offset_i[ 0 ] = offset_i[ 1 ] ;
414412 inplace_xor ( & mut offset_i[ 0 ] , & self . ll [ ntz ( i) ] ) ;
415- for j in 1 ..c_i. len ( ) {
416- offset_i[ j] = offset_i[ j - 1 ] ;
417- inplace_xor ( & mut offset_i[ j] , & self . ll [ ntz ( i + j) ] ) ;
418- }
413+ offset_i[ 1 ] = offset_i[ 0 ] ;
414+ inplace_xor ( & mut offset_i[ 1 ] , & self . ll [ ntz ( i + 1 ) ] ) ;
419415
420416 // p_i = offset_i xor DECIPHER(K, c_i xor offset_i)
421417 // checksum_i = checksum_{i-1} xor p_i
0 commit comments