Skip to content

Commit

Permalink
lib: [ZUC] fix LFSR update in 1 buffer implementation
Browse files Browse the repository at this point in the history
For a specific scenario, LFSR was incorrectly updated when
generating single buffer keystream, updating one of the LFSRs
to 0, instead of 0x7fffffff.

Fixes #144.

Signed-off-by: Pablo de Lara <[email protected]>
  • Loading branch information
pablodelara authored and mdcornu committed Feb 19, 2024
1 parent dad3dfb commit e1526ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/x86_64/zuc_common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ mksection .text
shr rbx, 31
add rax, rbx

mov rbx, rax
sub rbx, 0x7FFFFFFF
cmovns rax, rbx
mov rbx, rax
and rax, 0x7FFFFFFF
shr rbx, 31
add rax, rbx

; LFSR_S16 = (LFSR_S15++) = eax
mov [rsi + (( 0 + %1) % 16)*4], eax
Expand Down

0 comments on commit e1526ab

Please sign in to comment.