[openssl-commits] [openssl] master update

davidben at google.com davidben at google.com
Wed Mar 21 16:40:50 UTC 2018


The branch master has been updated
       via  ddc1caac2d6b22250f78ae9e0d392c923bc85933 (commit)
      from  0870c8ea93929d4e123d31805707a978bc39fdf0 (commit)


- Log -----------------------------------------------------------------
commit ddc1caac2d6b22250f78ae9e0d392c923bc85933
Author: David Benjamin <davidben at google.com>
Date:   Tue Mar 6 14:00:24 2018 -0500

    Document EC_POINT_get_affine_coordinates_*.
    
    In particular, x and y may be NULL, as used in ecdsa_ossl.c. Make use of
    this in ecdh_ossl.c as well, to save an otherwise unnecessary temporary.
    
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5532)

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

Summary of changes:
 crypto/ec/ecdh_ossl.c     | 9 ++++-----
 doc/man3/EC_POINT_new.pod | 5 ++++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/crypto/ec/ecdh_ossl.c b/crypto/ec/ecdh_ossl.c
index 3302050..7167af0 100644
--- a/crypto/ec/ecdh_ossl.c
+++ b/crypto/ec/ecdh_ossl.c
@@ -40,7 +40,7 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
 {
     BN_CTX *ctx;
     EC_POINT *tmp = NULL;
-    BIGNUM *x = NULL, *y = NULL;
+    BIGNUM *x = NULL;
     const BIGNUM *priv_key;
     const EC_GROUP *group;
     int ret = 0;
@@ -51,8 +51,7 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
         goto err;
     BN_CTX_start(ctx);
     x = BN_CTX_get(ctx);
-    y = BN_CTX_get(ctx);
-    if (y == NULL) {
+    if (x == NULL) {
         ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
         goto err;
     }
@@ -86,14 +85,14 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
 
     if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
         NID_X9_62_prime_field) {
-        if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, y, ctx)) {
+        if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, NULL, ctx)) {
             ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);
             goto err;
         }
     }
 #ifndef OPENSSL_NO_EC2M
     else {
-        if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) {
+        if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, NULL, ctx)) {
             ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);
             goto err;
         }
diff --git a/doc/man3/EC_POINT_new.pod b/doc/man3/EC_POINT_new.pod
index 5ac41b3..2d86777 100644
--- a/doc/man3/EC_POINT_new.pod
+++ b/doc/man3/EC_POINT_new.pod
@@ -99,7 +99,10 @@ be at infinity by calling EC_POINT_set_to_infinity().
 The affine co-ordinates for a point describe a point in terms of its x and y
 position. The functions EC_POINT_set_affine_coordinates_GFp() and
 EC_POINT_set_affine_coordinates_GF2m() set the B<x> and B<y> co-ordinates for
-the point B<p> defined over the curve given in B<group>.
+the point B<p> defined over the curve given in B<group>. The functions
+EC_POINT_get_affine_coordinates_GFp() and
+EC_POINT_get_affine_coordinates_GF2m() set B<x> and B<y>, either of which may
+be NULL, to the corresponding coordinates of B<p>.
 
 As well as the affine co-ordinates, a point can alternatively be described in
 terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian


More information about the openssl-commits mailing list