[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Sun Feb 14 20:23:00 UTC 2016


The branch master has been updated
       via  622a531c18187e3c59a7ab2d32ab990b397aafc2 (commit)
      from  29880e97104e5c88887e502a1d0ff570b646ec1b (commit)


- Log -----------------------------------------------------------------
commit 622a531c18187e3c59a7ab2d32ab990b397aafc2
Author: Andy Polyakov <appro at openssl.org>
Date:   Sat Feb 13 17:13:53 2016 +0100

    chacha/asm/chacha*: ensure that zero length is handled (without crash).
    
    RT#4305
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/chacha/asm/chacha-armv4.pl  | 7 +++++++
 crypto/chacha/asm/chacha-s390x.pl  | 2 ++
 crypto/chacha/asm/chacha-x86.pl    | 4 ++++
 crypto/chacha/asm/chacha-x86_64.pl | 3 +++
 4 files changed, 16 insertions(+)

diff --git a/crypto/chacha/asm/chacha-armv4.pl b/crypto/chacha/asm/chacha-armv4.pl
index 4d234b7..55ebc9e 100755
--- a/crypto/chacha/asm/chacha-armv4.pl
+++ b/crypto/chacha/asm/chacha-armv4.pl
@@ -200,6 +200,12 @@ ChaCha20_ctr32:
 #else
 	adr	r14,.LChaCha20_ctr32
 #endif
+	cmp	r2,#0			@ len==0?
+#ifdef	__thumb2__
+	itt	eq
+#endif
+	addeq	sp,sp,#4*3
+	beq	.Lno_data
 #if __ARM_MAX_ARCH__>=7
 	cmp	r2,#192			@ test len
 	bls	.Lshort
@@ -605,6 +611,7 @@ $code.=<<___;
 
 .Ldone:
 	add	sp,sp,#4*(32+3)
+.Lno_data:
 	ldmia	sp!,{r4-r11,pc}
 .size	ChaCha20_ctr32,.-ChaCha20_ctr32
 ___
diff --git a/crypto/chacha/asm/chacha-s390x.pl b/crypto/chacha/asm/chacha-s390x.pl
index 8a09706..e637dc2 100755
--- a/crypto/chacha/asm/chacha-s390x.pl
+++ b/crypto/chacha/asm/chacha-s390x.pl
@@ -140,6 +140,7 @@ $code.=<<___;
 .type	ChaCha20_ctr32,\@function
 .align	32
 ChaCha20_ctr32:
+	cl${g}ije	$len,0,.Lno_data	# $len==0?
 	a${g}hi	$len,-64
 	l${g}hi	%r1,-$frame
 	stm${g}	%r6,%r15,`6*$SIZE_T`($sp)
@@ -271,6 +272,7 @@ $code.=<<___;
 	stmg	%r0,%r3,$stdframe+4*12($sp)
 
 	lm${g}	%r6,%r15,`$frame+6*$SIZE_T`($sp)
+.Lno_data:
 	br	%r14
 
 .align	16
diff --git a/crypto/chacha/asm/chacha-x86.pl b/crypto/chacha/asm/chacha-x86.pl
index e2019aa..850c917 100755
--- a/crypto/chacha/asm/chacha-x86.pl
+++ b/crypto/chacha/asm/chacha-x86.pl
@@ -123,6 +123,9 @@ my ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_-1)&3),($ai,$bi,$ci,$di));	# previous
 &static_label("pic_point");
 
 &function_begin("ChaCha20_ctr32");
+	&xor	("eax","eax");
+	&cmp	("eax",&wparam(2));		# len==0?
+	&je	(&label("no_data"));
 if ($xmm) {
 	&call	(&label("pic_point"));
 &set_label("pic_point");
@@ -356,6 +359,7 @@ if ($xmm) {
 
 &set_label("done");
 	&stack_pop(33);
+&set_label("no_data");
 &function_end("ChaCha20_ctr32");
 
 if ($xmm) {
diff --git a/crypto/chacha/asm/chacha-x86_64.pl b/crypto/chacha/asm/chacha-x86_64.pl
index 1a87cf8..107fc70 100755
--- a/crypto/chacha/asm/chacha-x86_64.pl
+++ b/crypto/chacha/asm/chacha-x86_64.pl
@@ -219,6 +219,8 @@ $code.=<<___;
 .type	ChaCha20_ctr32,\@function,5
 .align	64
 ChaCha20_ctr32:
+	cmp	\$0,$len
+	je	.Lno_data
 	mov	OPENSSL_ia32cap_P+4(%rip),%r10
 	test	\$`1<<(41-32)`,%r10d
 	jnz	.LChaCha20_ssse3
@@ -375,6 +377,7 @@ $code.=<<___;
 	pop	%r12
 	pop	%rbp
 	pop	%rbx
+.Lno_data:
 	ret
 .size	ChaCha20_ctr32,.-ChaCha20_ctr32
 ___


More information about the openssl-commits mailing list