From 2dfae9f33daefc7c1fcb39cf50420a087cd45d5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Thu, 4 Apr 2013 16:28:40 +0200
Subject: [PATCH] ecc_point_get: Allow NULL x or y.

---
 ChangeLog   | 3 +++
 ecc-point.c | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d3ca0def..ad89c2ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-04-04  Niels Möller  <nisse@lysator.liu.se>
 
+	* ecc-point.c (ecc_point_get): Allow NULL x or y, ignore
+	corresponding coordinate.
+
 	* nettle.texinfo (Elliptic curves): Document high-level ECDSA
 	support.
 
diff --git a/ecc-point.c b/ecc-point.c
index 4d3489c4..82645a79 100644
--- a/ecc-point.c
+++ b/ecc-point.c
@@ -84,6 +84,8 @@ void
 ecc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y)
 {
   mp_size_t size = p->ecc->size;
-  mpz_set_n (x, p->p, size);
-  mpz_set_n (y, p->p + size, size);
+  if (x)
+    mpz_set_n (x, p->p, size);
+  if (y)
+    mpz_set_n (y, p->p + size, size);
 }
-- 
GitLab