From 658056aee65aacb27c3f08fb2f0517d7d140f56d Mon Sep 17 00:00:00 2001 From: xnumad <34810600+xnumad@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:18:26 +0100 Subject: [PATCH] Generate secret_key at compilation Requires Python >=3.6, which is already EOL, so not noteworthy https://github.com/RIOT-OS/RIOT/pull/20370#discussion_r1498370589 --- sys/net/gnrc/Makefile.dep | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/net/gnrc/Makefile.dep b/sys/net/gnrc/Makefile.dep index 8e36e56ecdb29..f521fec1a3efa 100644 --- a/sys/net/gnrc/Makefile.dep +++ b/sys/net/gnrc/Makefile.dep @@ -441,6 +441,21 @@ ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE))) USEMODULE += random endif +#This checks if the option is being set via Kconfig or CFLAGS +ifneq (,$(or $(CONFIG_GNRC_IPV6_STABLE_PRIVACY),$(filter -DCONFIG_GNRC_IPV6_STABLE_PRIVACY=1,$(CFLAGS)))) + # Set another macro that is needed for this option. + + ##prepare value + stable_privacy_secret_key != python3 -c "import secrets; print(','.join([f'0x{byte:02x}' for byte in secrets.token_bytes(16)]))" + + ##set macro + CFLAGS += -DSTABLE_PRIVACY_SECRET_KEY=$(stable_privacy_secret_key) + + # dependencies + USEMODULE += hashes ##include "hashes/sha256.h" + USEMODULE += ztimer_msec +endif + ifneq (,$(filter gnrc_udp,$(USEMODULE))) DEFAULT_MODULE += auto_init_gnrc_udp USEMODULE += gnrc_nettype_udp