Wipe (some) secrets from memory after use
authorKirill Isakov <bootctl@gmail.com>
Fri, 22 Apr 2022 12:33:52 +0000 (18:33 +0600)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 22 Apr 2022 20:22:18 +0000 (22:22 +0200)
commitc44b08613508c993e7fd9f625e0b1b4775efffed
treea159738da3903a4aae2259f8ef67890f9d5fa1cc
parentefca41606d4083eade90047d57cb963eb3b7e731
Wipe (some) secrets from memory after use

to lessen the amount of sensitive information ending up in swap, core
dumps, or in the hands of any remote attackers.

While there still remaings a lot interesting data in configuration trees,
connection_t structs, etc, this is considered a good practice nevertheless.

Some bedtime reading:

- http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
- http://www.daemonology.net/blog/2014-09-06-zeroing-buffers-is-insufficient.html
- https://github.com/jedisct1/libsodium/blob/be58b2e6664389d9c7993b55291402934b43b3ca/src/libsodium/sodium/utils.c#L78:L101
33 files changed:
src/chacha-poly1305/chacha-poly1305.c
src/chacha-poly1305/chacha-poly1305.h
src/conf.c
src/ed25519/ecdh.c
src/ed25519/ecdsa.c
src/ed25519/ecdsagen.c
src/edge.c
src/gcrypt/cipher.c
src/gcrypt/digest.c
src/gcrypt/rsa.c
src/gcrypt/rsagen.c
src/have.h
src/invitation.c
src/keys.c
src/meson.build
src/net_setup.c
src/node.c
src/openssl/rsa.c
src/protocol.c
src/protocol_auth.c
src/protocol_key.c
src/script.c
src/sptps.c
src/sptps.h
src/sptps_keypair.c
src/sptps_test.c
src/utils.c
src/utils.h
src/xalloc.h
test/unit/meson.build
test/unit/test_memzero_null.c [new file with mode: 0644]
test/unit/test_random_noinit.c
test/unit/test_xalloc.c [new file with mode: 0644]