Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto/ec
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2016-03-26 03:22:40 +0300
committerDavid Benjamin <davidben@google.com>2016-04-21 01:53:46 +0300
commita7aa2bb8f86f9891bba9d05544e2b9796b2da864 (patch)
treecab8f59cfaf3ddc3f4274a51f5fa266ca197f7a4 /crypto/ec
parentd860b7b1cdefa22b2d42074aa5c8ce2a8ec1da5c (diff)
Avoid a multiplication in |ecp_nistz256_get_affine| when |x| is NULL.
This is purely hypothetical, as in real life nobody cares about the |y| component without also caring about the |x| component, but it clarifies the code and makes a future change clearer. Change-Id: Icaa4de83c87b82a8e68cd2942779a06e5db300c3 Reviewed-on: https://boringssl-review.googlesource.com/7588 Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/p256-x86_64.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/ec/p256-x86_64.c b/crypto/ec/p256-x86_64.c
index 17ab91b3..b11e37fd 100644
--- a/crypto/ec/p256-x86_64.c
+++ b/crypto/ec/p256-x86_64.c
@@ -502,8 +502,6 @@ static int ecp_nistz256_get_affine(const EC_GROUP *group, const EC_POINT *point,
BIGNUM *x, BIGNUM *y, BN_CTX *ctx) {
BN_ULONG z_inv2[P256_LIMBS];
BN_ULONG z_inv3[P256_LIMBS];
- BN_ULONG x_aff[P256_LIMBS];
- BN_ULONG y_aff[P256_LIMBS];
BN_ULONG point_x[P256_LIMBS], point_y[P256_LIMBS], point_z[P256_LIMBS];
if (EC_POINT_is_at_infinity(group, point)) {
@@ -520,9 +518,11 @@ static int ecp_nistz256_get_affine(const EC_GROUP *group, const EC_POINT *point,
ecp_nistz256_mod_inverse(z_inv3, point_z);
ecp_nistz256_sqr_mont(z_inv2, z_inv3);
- ecp_nistz256_mul_mont(x_aff, z_inv2, point_x);
if (x != NULL) {
+ BN_ULONG x_aff[P256_LIMBS];
+
+ ecp_nistz256_mul_mont(x_aff, z_inv2, point_x);
if (bn_wexpand(x, P256_LIMBS) == NULL) {
OPENSSL_PUT_ERROR(EC, ERR_R_MALLOC_FAILURE);
return 0;
@@ -534,6 +534,8 @@ static int ecp_nistz256_get_affine(const EC_GROUP *group, const EC_POINT *point,
}
if (y != NULL) {
+ BN_ULONG y_aff[P256_LIMBS];
+
ecp_nistz256_mul_mont(z_inv3, z_inv3, z_inv2);
ecp_nistz256_mul_mont(y_aff, z_inv3, point_y);
if (bn_wexpand(y, P256_LIMBS) == NULL) {