aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util/crypto_ecc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/crypto_ecc.c')
-rw-r--r--src/lib/util/crypto_ecc.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/lib/util/crypto_ecc.c b/src/lib/util/crypto_ecc.c
index 11c3e50d4..8ea17fda0 100644
--- a/src/lib/util/crypto_ecc.c
+++ b/src/lib/util/crypto_ecc.c
@@ -411,24 +411,39 @@ GNUNET_CRYPTO_eddsa_private_key_from_string (
411} 411}
412 412
413 413
414static void
415buffer_clear (void *buf, size_t len)
416{
417#if HAVE_MEMSET_S
418 memset_s (buf, len, 0, len);
419#elif HAVE_EXPLICIT_BZERO
420 explicit_bzero (buf, len);
421#else
422 volatile unsigned char *p = buf;
423 while (len--)
424 *p++ = 0;
425#endif
426}
427
428
414void 429void
415GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) 430GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
416{ 431{
417 memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey)); 432 buffer_clear (pk, sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey));
418} 433}
419 434
420 435
421void 436void
422GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) 437GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
423{ 438{
424 memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)); 439 buffer_clear (pk, sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
425} 440}
426 441
427 442
428void 443void
429GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) 444GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
430{ 445{
431 memset (pk, 0, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey)); 446 buffer_clear (pk, sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey));
432} 447}
433 448
434 449