diff options
Diffstat (limited to 'src/lib/util/crypto_ecc.c')
-rw-r--r-- | src/lib/util/crypto_ecc.c | 21 |
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 | ||
414 | static void | ||
415 | buffer_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 | |||
414 | void | 429 | void |
415 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 430 | GNUNET_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 | ||
421 | void | 436 | void |
422 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 437 | GNUNET_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 | ||
428 | void | 443 | void |
429 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 444 | GNUNET_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 | ||