From 3b8a031569f5f209e97c6a815fcf24a2c4c05e65 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Mon, 18 Sep 2017 11:55:18 +0100 Subject: [PATCH] crypto/elliptic: fix incomplete addition used in CombinedMult on s390x This applies the amd64-specific changes from CL 42611 to the s390x P256 implementation. The s390x implementation was disabled in CL 62292 and this CL re-enables it. Adam Langley's commit message from CL 42611: The optimised P-256 includes a CombinedMult function, which doesn't do dual-scalar multiplication, but does avoid an affine conversion for ECDSA verification. However, it currently uses an assembly point addition function that doesn't handle exceptional cases. Fixes #20215. Change-Id: I2f6b532f495e85b8903475b4f64cc32a3b2f6769 Reviewed-on: https://go-review.googlesource.com/64290 Run-TryBot: Michael Munday TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/crypto/elliptic/p256_asm_s390x.s | 41 +++++++++++++++++++++++++--- src/crypto/elliptic/p256_s390x.go | 34 +++++++++++++++++------ 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/crypto/elliptic/p256_asm_s390x.s b/src/crypto/elliptic/p256_asm_s390x.s index 96b59be23fb..d0e6d09e2e3 100644 --- a/src/crypto/elliptic/p256_asm_s390x.s +++ b/src/crypto/elliptic/p256_asm_s390x.s @@ -1944,10 +1944,12 @@ TEXT ·p256PointDoubleAsm(SB), NOSPLIT, $0 #undef CAR2 // p256PointAddAsm(P3, P1, P2 *p256Point) -#define P3ptr R1 -#define P1ptr R2 -#define P2ptr R3 -#define CPOOL R4 +#define P3ptr R1 +#define P1ptr R2 +#define P2ptr R3 +#define CPOOL R4 +#define ISZERO R5 +#define TRUE R6 // Temporaries in REGs #define T1L V16 @@ -2102,6 +2104,21 @@ TEXT ·p256PointAddAsm(SB), NOSPLIT, $0 // SUB(H