summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-06-20 10:40:14 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-06-20 10:40:14 +0000
commitb7e6615a9d7c035fde5e02170ff95d49454a7e3d (patch)
tree05e98bed9009c874305dcdef16a69da4a59dd1a0
parentf3cdfb4ce2276706248abf4f65d96a6ecc75e220 (diff)
Fix incorrect bounds check in amd64 assembly version of bn_mul_mont();
noticed and fix by Fedor Indutny of Joyent ( https://github.com/joyent/node/issues/7704 )
-rwxr-xr-xlib/libcrypto/bn/asm/x86_64-mont.pl4
-rwxr-xr-xlib/libcrypto/bn/asm/x86_64-mont5.pl11
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/libcrypto/bn/asm/x86_64-mont.pl b/lib/libcrypto/bn/asm/x86_64-mont.pl
index 90c717f1152..c35493e80ad 100755
--- a/lib/libcrypto/bn/asm/x86_64-mont.pl
+++ b/lib/libcrypto/bn/asm/x86_64-mont.pl
@@ -138,7 +138,7 @@ $code.=<<___;
mulq $m1 # np[j]*m1
cmp $num,$j
- jne .L1st
+ jl .L1st
add %rax,$hi1
mov ($ap),%rax # ap[0]
@@ -204,7 +204,7 @@ $code.=<<___;
mulq $m1 # np[j]*m1
cmp $num,$j
- jne .Linner
+ jl .Linner
add %rax,$hi1
mov ($ap),%rax # ap[0]
diff --git a/lib/libcrypto/bn/asm/x86_64-mont5.pl b/lib/libcrypto/bn/asm/x86_64-mont5.pl
index 057cda28aae..9c88884d424 100755
--- a/lib/libcrypto/bn/asm/x86_64-mont5.pl
+++ b/lib/libcrypto/bn/asm/x86_64-mont5.pl
@@ -28,7 +28,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
die "can't locate x86_64-xlate.pl";
-open STDOUT,"| $^X $xlate $flavour $output";
+open OUT,"| \"$^X\" $xlate $flavour $output";
+*STDOUT=*OUT;
# int bn_mul_mont_gather5(
$rp="%rdi"; # BN_ULONG *rp,
@@ -180,7 +181,7 @@ $code.=<<___;
mulq $m1 # np[j]*m1
cmp $num,$j
- jne .L1st
+ jl .L1st
movq %xmm0,$m0 # bp[1]
@@ -263,7 +264,7 @@ $code.=<<___;
mulq $m1 # np[j]*m1
cmp $num,$j
- jne .Linner
+ jl .Linner
movq %xmm0,$m0 # bp[i+1]
@@ -900,8 +901,8 @@ $code.=<<___;
jnz .Lgather
___
$code.=<<___ if ($win64);
- movaps %xmm6,(%rsp)
- movaps %xmm7,0x10(%rsp)
+ movaps (%rsp),%xmm6
+ movaps 0x10(%rsp),%xmm7
lea 0x28(%rsp),%rsp
___
$code.=<<___;