Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

Commit 4443cf7

Browse files
Andy Polyakovmattcaswell
authored andcommitted
bn/asm/x86_64-mont5.pl: fix carry bug in bn_sqrx8x_internal.
Credit to OSS-Fuzz for finding this. CVE-2017-3736 Reviewed-by: Rich Salz <rsalz@openssl.org>
1 parent b701fa8 commit 4443cf7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crypto/bn/asm/x86_64-mont5.pl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,11 +3099,19 @@
30993099
31003100
.align 32
31013101
.Lsqrx8x_break:
3102-
sub 16+8(%rsp),%r8 # consume last carry
3102+
xor $zero,$zero
3103+
sub 16+8(%rsp),%rbx # mov 16(%rsp),%cf
3104+
adcx $zero,%r8
31033105
mov 24+8(%rsp),$carry # initial $tptr, borrow $carry
3106+
adcx $zero,%r9
31043107
mov 0*8($aptr),%rdx # a[8], modulo-scheduled
3105-
xor %ebp,%ebp # xor $zero,$zero
3108+
adc \$0,%r10
31063109
mov %r8,0*8($tptr)
3110+
adc \$0,%r11
3111+
adc \$0,%r12
3112+
adc \$0,%r13
3113+
adc \$0,%r14
3114+
adc \$0,%r15
31073115
cmp $carry,$tptr # cf=0, of=0
31083116
je .Lsqrx8x_outer_loop
31093117

0 commit comments

Comments
 (0)