Both the private key and the final shared secret in ECDH happen to be
scalars (the public key is a point). We could have a separate function
to free sensitive scalars but it's probably ok to erase all scalars
perfomance wise.
---
ell/ecc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ell/ecc.c b/ell/ecc.c
index 6b93e54..a59e8e4 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -427,5 +427,9 @@ LIB_EXPORT ssize_t l_ecc_scalar_get_data(const struct l_ecc_scalar
*c,
LIB_EXPORT void l_ecc_scalar_free(struct l_ecc_scalar *c)
{
+ if (unlikely(!c))
+ return;
+
+ memset(c->c, 0, c->curve->ndigits * 8);
l_free(c);
}
--
2.19.1