diff options
author | David Benjamin <davidben@google.com> | 2018-03-06 14:00:24 -0500 |
---|---|---|
committer | David Benjamin <davidben@google.com> | 2018-03-21 12:39:36 -0400 |
commit | ddc1caac2d6b22250f78ae9e0d392c923bc85933 (patch) | |
tree | 2df1813972ad95bed8f84e3b3fc479916b532efd /crypto/ec/ecdh_ossl.c | |
parent | 0870c8ea93929d4e123d31805707a978bc39fdf0 (diff) |
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@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5532)
Diffstat (limited to 'crypto/ec/ecdh_ossl.c')
-rw-r--r-- | crypto/ec/ecdh_ossl.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/ec/ecdh_ossl.c b/crypto/ec/ecdh_ossl.c index 3302050c87..7167af08ce 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; } |