All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ecc: Clear point coordinates, use explicit_bzero
@ 2019-03-19  0:48 Andrew Zaborowski
  2019-03-19  0:48 ` [PATCH 2/4] pkcs5: Memzero copies of secrets Andrew Zaborowski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andrew Zaborowski @ 2019-03-19  0:48 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]

We would only zero out memory used by the scalar type because
Diffie-Hellman secrets are scalars, but in PWD the PWD and PK values may
be points so also clear those.  Update l_ecc_scalar_free to use
explicit_bzero too.
---
 ell/ecc.c  | 7 ++++++-
 ell/ecdh.c | 2 --
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/ell/ecc.c b/ell/ecc.c
index 88c8373..5fa91a8 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -541,6 +541,11 @@ LIB_EXPORT ssize_t l_ecc_point_get_data(const struct l_ecc_point *p, void *buf,
 
 LIB_EXPORT void l_ecc_point_free(struct l_ecc_point *p)
 {
+	if (unlikely(!p))
+		return;
+
+	explicit_bzero(p->x, p->curve->ndigits * 8);
+	explicit_bzero(p->y, p->curve->ndigits * 8);
 	l_free(p);
 }
 
@@ -612,7 +617,7 @@ LIB_EXPORT void l_ecc_scalar_free(struct l_ecc_scalar *c)
 	if (unlikely(!c))
 		return;
 
-	memset(c->c, 0, c->curve->ndigits * 8);
+	explicit_bzero(c->c, c->curve->ndigits * 8);
 	l_free(c);
 }
 
diff --git a/ell/ecdh.c b/ell/ecdh.c
index 5ecbd44..a10189f 100644
--- a/ell/ecdh.c
+++ b/ell/ecdh.c
@@ -100,8 +100,6 @@ LIB_EXPORT bool l_ecdh_generate_shared_secret(
 
 	*secret = _ecc_constant_new(curve, product->x, curve->ndigits * 8);
 
-	memset(product->x, 0, curve->ndigits * 8);
-	memset(product->y, 0, curve->ndigits * 8);
 	l_ecc_point_free(product);
 	l_ecc_scalar_free(z);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-19 19:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19  0:48 [PATCH 1/4] ecc: Clear point coordinates, use explicit_bzero Andrew Zaborowski
2019-03-19  0:48 ` [PATCH 2/4] pkcs5: Memzero copies of secrets Andrew Zaborowski
2019-03-19  0:48 ` [PATCH 3/4] settings: Clear values in unescape_value on error Andrew Zaborowski
2019-03-19  0:48 ` [PATCH 4/4] all: Replace uses of memset with explicit_bzero Andrew Zaborowski
2019-03-19 19:19 ` [PATCH 1/4] ecc: Clear point coordinates, use explicit_bzero Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.