refactor(core): simplify entropy module, relocate/rename to storage_salt
What changed, and why it matters
This commit is a code cleanup: it renames the 'entropy' module to 'storage_salt' and moves it into the storage subsystem. The same device-unique salt logic (CPU ID plus one-time-programmable randomness block, or a master-key-derived salt on newer devices) is preserved, just called at a different point during storage setup rather than at boot. There is no indication this fixes a security bug or changes cryptographic behavior.
No security action required. Treat as ordinary maintenance/refactoring. If reviewing for release, verify that storage_salt_get() is invoked exactly once before storage_init() and that the OTP randomness block write/lock behavior on first boot remains unchanged.
Security signals we found
No security-relevant behavioral change observed
Refactor only: rename and relocation of module
Salt derivation logic preserved verbatim
No changelog entry requested by commit message
Evidence from the diff
The patch deletes core/embed/sec/entropy/{inc,stm32f4,stm32u5,unix} and introduces core/embed/sec/storage/{storage_salt.h,stm32f4/storage_salt.c,stm32u5/storage_salt.c,unix/storage_salt.c}. The previous entropy_init()/entropy_get() API is replaced by storage_salt_get(). The boot-time entropy_init() calls in kernel, secmon, and unix main.c are removed; the salt is now fetched inside storage_setup() immediately before storage_init(). Functionally, the salt derivation paths remain identical: STM32F4 uses UID words + FLASH_OTP_BLOCK_RANDOMNESS (writing/locking it if not already locked); STM32U5 either derives from secret_key_storage_salt() when SECRET_PRIVILEGED_MASTER_KEY_SLOT is defined or falls back to UID + OTP; the unix emulator returns a zeroed salt of the expected size. Build files are updated to remove the old include/source paths and add the new ones. The change is purely architectural refactoring.
Changed components
core/embed/sec/entropy (removed)core/embed/sec/storage/storage_salt (new)core/embed/sec/storage/storage_setup.ccore/embed/projects/kernel/main.ccore/embed/projects/secmon/main.ccore/embed/projects/unix/main.ccore/site_scons/models/stm32f4_common.pycore/site_scons/models/stm32u5_common.pycore/site_scons/models/unix_common.pycore/embed/rust/build.rsInspect captured patch +241 / −272
diff --git a/core/embed/projects/kernel/main.c b/core/embed/projects/kernel/main.c
index fcb0a537..1ca91e69 100644
--- a/core/embed/projects/kernel/main.c
+++ b/core/embed/projects/kernel/main.c
@@ -21,7 +21,6 @@
#include <gfx/gfx_bitblt.h>
#include <io/display.h>
-#include <sec/entropy.h>
#include <sec/random_delays.h>
#include <sec/secret.h>
#include <sec/secure_aes.h>
@@ -106,7 +105,6 @@ void drivers_init() {
#ifdef USE_STORAGE_HWKEY
secure_aes_init();
#endif
- entropy_init();
#ifdef USE_TAMPER
tamper_init();
#if PRODUCTION
diff --git a/core/embed/projects/secmon/main.c b/core/embed/projects/secmon/main.c
index 850307d0..6db0f54a 100644
--- a/core/embed/projects/secmon/main.c
+++ b/core/embed/projects/secmon/main.c
@@ -20,7 +20,6 @@
#include <trezor_bsp.h>
#include <trezor_model.h>
-#include <sec/entropy.h>
#include <sec/random_delays.h>
#include <sec/secure_aes.h>
#include <sys/bootutils.h>
@@ -62,7 +61,6 @@ static void drivers_init(void) {
#ifdef USE_STORAGE_HWKEY
secure_aes_init();
#endif
- entropy_init();
#ifdef USE_TAMPER
tamper_init();
diff --git a/core/embed/projects/unix/main.c b/core/embed/projects/unix/main.c
index 5f6d8f68..6d3d61aa 100644
--- a/core/embed/projects/unix/main.c
+++ b/core/embed/projects/unix/main.c
@@ -37,7 +37,6 @@
#include <unistd.h>
#include <io/display.h>
-#include <sec/entropy.h>
#include <sec/secret.h>
#include <sys/system.h>
#include <sys/systimer.h>
@@ -508,8 +507,6 @@ void drivers_init() {
flash_init();
flash_otp_init();
- entropy_init();
-
unit_properties_init();
display_init(DISPLAY_RESET_CONTENT);
diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs
index 8d0c547b..39d9b08d 100644
--- a/core/embed/rust/build.rs
+++ b/core/embed/rust/build.rs
@@ -44,7 +44,6 @@ const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[
"-I../io/touch/inc",
"-I../io/rgb_led/inc",
"-I../io/usb/inc",
- "-I../sec/entropy/inc",
"-I../sec/storage/inc",
"-I../sys/time/inc",
"-I../sys/task/inc",
diff --git a/core/embed/sec/entropy/inc/sec/entropy.h b/core/embed/sec/entropy/inc/sec/entropy.h
deleted file mode 100644
index 2046a579..00000000
--- a/core/embed/sec/entropy/inc/sec/entropy.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <trezor_types.h>
-
-#ifdef SECURE_MODE
-
-/**
- * Initializes the entropy module.
- * If entropy has not yet been generated for the device, it is generated now.
- */
-void entropy_init(void);
-
-#endif // SECURE_MODE
-
-/**
- * Maximum size of generated entropy (minimum is 32 bytes).
- * Newer devices derive entropy from the master key - 32 bytes.
- * Older devices derive entropy from CPUID and OTP - 32 + 12 bytes.
- */
-#define ENTROPY_MAX_SIZE (32 + 12)
-
-typedef struct {
- /** Number of valid bytes in the bytes array */
- size_t size;
- /** Generated entropy bytes */
- uint8_t bytes[ENTROPY_MAX_SIZE];
-} entropy_data_t;
-
-/**
- * Retrieves the generated entropy buffer.
- * @param entropy structure filled with the generated data.
- */
-void entropy_get(entropy_data_t* entropy);
diff --git a/core/embed/sec/entropy/stm32f4/entropy.c b/core/embed/sec/entropy/stm32f4/entropy.c
deleted file mode 100644
index 53712729..00000000
--- a/core/embed/sec/entropy/stm32f4/entropy.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <trezor_model.h>
-#include <trezor_rtl.h>
-
-#include <sec/entropy.h>
-#include <sys/mpu.h>
-#include <util/flash_otp.h>
-#include "rand.h"
-
-#include "stm32f4xx_ll_utils.h"
-
-#ifdef SECURE_MODE
-
-static entropy_data_t g_entropy = {0};
-
-void entropy_init(void) {
- mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
-
- entropy_data_t* ent = &g_entropy;
-
- // collect entropy from UUID
- uint32_t w = LL_GetUID_Word0();
- memcpy(&ent->bytes[0], &w, 4);
- w = LL_GetUID_Word1();
- memcpy(&ent->bytes[4], &w, 4);
- w = LL_GetUID_Word2();
- memcpy(&ent->bytes[8], &w, 4);
-
- mpu_restore(mpu_mode);
-
- // set entropy in the OTP randomness block
- if (secfalse == flash_otp_is_locked(FLASH_OTP_BLOCK_RANDOMNESS)) {
- uint8_t rnd_bytes[FLASH_OTP_BLOCK_SIZE];
- random_buffer(rnd_bytes, FLASH_OTP_BLOCK_SIZE);
- ensure(flash_otp_write(FLASH_OTP_BLOCK_RANDOMNESS, 0, rnd_bytes,
- FLASH_OTP_BLOCK_SIZE),
- NULL);
- ensure(flash_otp_lock(FLASH_OTP_BLOCK_RANDOMNESS), NULL);
- }
- // collect entropy from OTP randomness block
- ensure(flash_otp_read(FLASH_OTP_BLOCK_RANDOMNESS, 0, &ent->bytes[12],
- FLASH_OTP_BLOCK_SIZE),
- NULL);
-
- ent->size = 12 + FLASH_OTP_BLOCK_SIZE;
-}
-
-void entropy_get(entropy_data_t* entropy) { *entropy = g_entropy; }
-
-#endif // SECURE_MODE
diff --git a/core/embed/sec/entropy/stm32u5/entropy.c b/core/embed/sec/entropy/stm32u5/entropy.c
deleted file mode 100644
index 8720649e..00000000
--- a/core/embed/sec/entropy/stm32u5/entropy.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef SECURE_MODE
-
-#include <trezor_model.h>
-#include <trezor_rtl.h>
-
-#include <sec/entropy.h>
-#include <sec/secret_keys.h>
-#include <sys/mpu.h>
-#include <util/flash_otp.h>
-#include <util/image.h>
-#include "rand.h"
-
-#include "stm32u5xx_ll_utils.h"
-
-static entropy_data_t g_entropy = {0};
-
-#ifdef SECRET_PRIVILEGED_MASTER_KEY_SLOT
-
-// Entropy derived from master key
-void entropy_init(void) {
- entropy_data_t* ent = &g_entropy;
-
- vendor_header vhdr = {0};
- ensure(read_vendor_header((const uint8_t*)FIRMWARE_START, &vhdr), NULL);
-
- _Static_assert(SECRET_KEY_STORAGE_SALT_SIZE <= sizeof(ent->bytes));
- secbool retval = secret_key_storage_salt(vhdr.fw_type, ent->bytes);
-
-#if PRODUCTION
- ensure(retval, "Failed to get storage salt");
-#else
- // In non-production builds, we allow failure to retrieve the storage salt,
- // so we don't need to set up the master key every time the flash is erased.
- (void)retval;
-#endif
-
- ent->size = SECRET_KEY_STORAGE_SALT_SIZE;
-}
-
-#else
-
-// Legacy entropy generated from CPUID & radnom data in OTP
-void entropy_init(void) {
- mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
-
- entropy_data_t* ent = &g_entropy;
-
- // collect entropy from UUID
- uint32_t w = LL_GetUID_Word0();
- memcpy(&ent->bytes[0], &w, 4);
- w = LL_GetUID_Word1();
- memcpy(&ent->bytes[4], &w, 4);
- w = LL_GetUID_Word2();
- memcpy(&ent->bytes[8], &w, 4);
-
- mpu_restore(mpu_mode);
-
- // set entropy in the OTP randomness block
- if (secfalse == flash_otp_is_locked(FLASH_OTP_BLOCK_RANDOMNESS)) {
- uint8_t rnd_bytes[FLASH_OTP_BLOCK_SIZE];
- random_buffer(rnd_bytes, FLASH_OTP_BLOCK_SIZE);
- ensure(flash_otp_write(FLASH_OTP_BLOCK_RANDOMNESS, 0, rnd_bytes,
- FLASH_OTP_BLOCK_SIZE),
- NULL);
- }
- // collect entropy from OTP randomness block
- ensure(flash_otp_read(FLASH_OTP_BLOCK_RANDOMNESS, 0, &ent->bytes[12],
- FLASH_OTP_BLOCK_SIZE),
- NULL);
-
- ent->size = 12 + FLASH_OTP_BLOCK_SIZE;
-}
-
-#endif
-
-void entropy_get(entropy_data_t* entropy) { *entropy = g_entropy; }
-
-#endif // SECURE_MODE
diff --git a/core/embed/sec/entropy/unix/entropy.c b/core/embed/sec/entropy/unix/entropy.c
deleted file mode 100644
index 416cc231..00000000
--- a/core/embed/sec/entropy/unix/entropy.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <trezor_model.h>
-#include <trezor_rtl.h>
-
-#include <sec/entropy.h>
-
-static entropy_data_t g_entropy = {0};
-
-void entropy_init(void) {
- entropy_data_t* ent = &g_entropy;
-#ifdef SECRET_PRIVILEGED_MASTER_KEY_SLOT
- ent->size = 32;
-#else
- ent->size = 32 + 12; // Legacy
-#endif
-}
-
-void entropy_get(entropy_data_t* entropy) { *entropy = g_entropy; }
diff --git a/core/embed/sec/storage/stm32f4/storage_salt.c b/core/embed/sec/storage/stm32f4/storage_salt.c
new file mode 100644
index 00000000..ce3038fc
--- /dev/null
+++ b/core/embed/sec/storage/stm32f4/storage_salt.c
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef SECURE_MODE
+
+#include <trezor_model.h>
+#include <trezor_rtl.h>
+
+#include <sys/mpu.h>
+#include <util/flash_otp.h>
+
+#include "rand.h"
+#include "stm32f4xx_ll_utils.h"
+
+#include "../storage_salt.h"
+
+void storage_salt_get(storage_salt_t* salt) {
+ mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
+
+ // collect entropy from UUID
+ uint32_t w = LL_GetUID_Word0();
+ memcpy(&salt->bytes[0], &w, 4);
+ w = LL_GetUID_Word1();
+ memcpy(&salt->bytes[4], &w, 4);
+ w = LL_GetUID_Word2();
+ memcpy(&salt->bytes[8], &w, 4);
+
+ mpu_restore(mpu_mode);
+
+ // set entropy in the OTP randomness block
+ if (secfalse == flash_otp_is_locked(FLASH_OTP_BLOCK_RANDOMNESS)) {
+ uint8_t rnd_bytes[FLASH_OTP_BLOCK_SIZE];
+ random_buffer(rnd_bytes, FLASH_OTP_BLOCK_SIZE);
+ ensure(flash_otp_write(FLASH_OTP_BLOCK_RANDOMNESS, 0, rnd_bytes,
+ FLASH_OTP_BLOCK_SIZE),
+ NULL);
+ ensure(flash_otp_lock(FLASH_OTP_BLOCK_RANDOMNESS), NULL);
+ }
+ // collect entropy from OTP randomness block
+ ensure(flash_otp_read(FLASH_OTP_BLOCK_RANDOMNESS, 0, &salt->bytes[12],
+ FLASH_OTP_BLOCK_SIZE),
+ NULL);
+
+ salt->size = 12 + FLASH_OTP_BLOCK_SIZE;
+}
+
+#endif // SECURE_MODE
diff --git a/core/embed/sec/storage/stm32u5/storage_salt.c b/core/embed/sec/storage/stm32u5/storage_salt.c
new file mode 100644
index 00000000..d511676c
--- /dev/null
+++ b/core/embed/sec/storage/stm32u5/storage_salt.c
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef SECURE_MODE
+
+#include <trezor_model.h>
+#include <trezor_rtl.h>
+
+#include <sec/secret_keys.h>
+#include <sys/mpu.h>
+#include <util/flash_otp.h>
+#include <util/image.h>
+#include "rand.h"
+
+#include "stm32u5xx_ll_utils.h"
+
+#include "../storage_salt.h"
+
+#ifdef SECRET_PRIVILEGED_MASTER_KEY_SLOT
+
+void storage_salt_get(storage_salt_t* salt) {
+ memset(salt, 0, sizeof(*salt));
+
+ vendor_header vhdr = {0};
+ ensure(read_vendor_header((const uint8_t*)FIRMWARE_START, &vhdr), NULL);
+
+ _Static_assert(SECRET_KEY_STORAGE_SALT_SIZE <= sizeof(salt->bytes));
+ secbool retval = secret_key_storage_salt(vhdr.fw_type, salt->bytes);
+
+#if PRODUCTION
+ ensure(retval, "Failed to get storage salt");
+#else
+ // In non-production builds, we allow failure to retrieve the storage salt,
+ // so we don't need to set up the master key every time the flash is erased.
+ (void)retval;
+#endif
+
+ salt->size = SECRET_KEY_STORAGE_SALT_SIZE;
+}
+
+#else
+
+// Legacy entropy generated from CPUID & radnom data in OTP
+void storage_salt_get(storage_salt_t* salt) {
+ mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
+
+ // collect entropy from UUID
+ uint32_t w = LL_GetUID_Word0();
+ memcpy(&salt->bytes[0], &w, 4);
+ w = LL_GetUID_Word1();
+ memcpy(&salt->bytes[4], &w, 4);
+ w = LL_GetUID_Word2();
+ memcpy(&salt->bytes[8], &w, 4);
+
+ mpu_restore(mpu_mode);
+
+ // set entropy in the OTP randomness block
+ if (secfalse == flash_otp_is_locked(FLASH_OTP_BLOCK_RANDOMNESS)) {
+ uint8_t rnd_bytes[FLASH_OTP_BLOCK_SIZE];
+ random_buffer(rnd_bytes, FLASH_OTP_BLOCK_SIZE);
+ ensure(flash_otp_write(FLASH_OTP_BLOCK_RANDOMNESS, 0, rnd_bytes,
+ FLASH_OTP_BLOCK_SIZE),
+ NULL);
+ }
+ // collect entropy from OTP randomness block
+ ensure(flash_otp_read(FLASH_OTP_BLOCK_RANDOMNESS, 0, &salt->bytes[12],
+ FLASH_OTP_BLOCK_SIZE),
+ NULL);
+
+ salt->size = 12 + FLASH_OTP_BLOCK_SIZE;
+}
+
+#endif
+
+#endif // SECURE_MODE
diff --git a/core/embed/sec/storage/storage_salt.h b/core/embed/sec/storage/storage_salt.h
new file mode 100644
index 00000000..21065612
--- /dev/null
+++ b/core/embed/sec/storage/storage_salt.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <trezor_types.h>
+
+/**
+ * Maximum size of generated salt (minimum is 32 bytes).
+ * Newer devices derive salt from the master key - 32 bytes.
+ * Older devices derive salt from CPUID and OTP - 32 + 12 bytes.
+ */
+#define STORAGE_SALT_MAX_SIZE (32 + 12)
+
+typedef struct {
+ /** Number of valid bytes in the bytes array */
+ size_t size;
+ /** Generated salt bytes */
+ uint8_t bytes[STORAGE_SALT_MAX_SIZE];
+} storage_salt_t;
+
+/**
+ * Retrieves the generated buffer with storage salt.
+ *
+ * If storage salt has not yet been generated for the device, it is
+ * generated now.
+ *
+ * @param salt structure filled with the generated data.
+ */
+void storage_salt_get(storage_salt_t* salt);
diff --git a/core/embed/sec/storage/storage_setup.c b/core/embed/sec/storage/storage_setup.c
index 34532975..f86502b5 100644
--- a/core/embed/sec/storage/storage_setup.c
+++ b/core/embed/sec/storage/storage_setup.c
@@ -19,16 +19,16 @@
#ifdef SECURE_MODE
-#include <sec/entropy.h>
#include <sec/storage.h>
#include "memzero.h"
+#include "storage_salt.h"
void storage_setup(PIN_UI_WAIT_CALLBACK callback) {
- entropy_data_t entropy;
- entropy_get(&entropy);
- storage_init(callback, entropy.bytes, entropy.size);
- memzero(&entropy, sizeof(entropy));
+ storage_salt_t salt;
+ storage_salt_get(&salt);
+ storage_init(callback, salt.bytes, salt.size);
+ memzero(&salt, sizeof(salt));
}
#endif // SECURE_MODE
diff --git a/core/embed/sec/storage/unix/storage_salt.c b/core/embed/sec/storage/unix/storage_salt.c
new file mode 100644
index 00000000..1f8ecdb4
--- /dev/null
+++ b/core/embed/sec/storage/unix/storage_salt.c
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <trezor_model.h>
+#include <trezor_rtl.h>
+
+#include "../storage_salt.h"
+
+void storage_salt_get(storage_salt_t* salt) {
+ memset(salt, 0, sizeof(*salt));
+
+#ifdef SECRET_PRIVILEGED_MASTER_KEY_SLOT
+ salt->size = 32;
+#else
+ salt->size = 32 + 12; // Legacy
+#endif
+}
diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py
index fc46c2b8..c6b7238d 100644
--- a/core/site_scons/models/stm32f4_common.py
+++ b/core/site_scons/models/stm32f4_common.py
@@ -10,7 +10,6 @@ def stm32f4_common_files(env, defines, sources, paths):
]
paths += [
- "embed/sec/entropy/inc",
"embed/sec/monoctr/inc",
"embed/sec/random_delays/inc",
"embed/sec/rng/inc",
@@ -64,12 +63,12 @@ def stm32f4_common_files(env, defines, sources, paths):
]
sources += [
- "embed/sec/entropy/stm32f4/entropy.c",
"embed/sec/monoctr/stm32f4/monoctr.c",
"embed/sec/random_delays/stm32/random_delays.c",
"embed/sec/rng/stm32/rng.c",
"embed/sec/secret/stm32f4/secret.c",
"embed/sec/secret/stm32f4/secret_keys.c",
+ "embed/sec/storage/stm32f4/storage_salt.c",
"embed/sec/time_estimate/stm32/time_estimate.c",
"embed/sys/dbg/stm32/dbg_printf.c",
"embed/sys/irq/stm32/irq.c",
diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py
index 9600013b..a8697252 100644
--- a/core/site_scons/models/stm32u5_common.py
+++ b/core/site_scons/models/stm32u5_common.py
@@ -10,7 +10,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
]
paths += [
- "embed/sec/entropy/inc",
"embed/sec/hash_processor/inc",
"embed/sec/monoctr/inc",
"embed/sec/random_delays/inc",
@@ -82,7 +81,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
]
sources += [
- "embed/sec/entropy/stm32u5/entropy.c",
"embed/sec/hash_processor/stm32u5/hash_processor.c",
"embed/sec/monoctr/stm32u5/monoctr.c",
"embed/sec/random_delays/stm32/random_delays.c",
@@ -91,6 +89,7 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/secret/stm32u5/secret_keys.c",
"embed/sec/secure_aes/stm32u5/secure_aes.c",
"embed/sec/secure_aes/stm32u5/secure_aes_unpriv.c",
+ "embed/sec/storage/stm32u5/storage_salt.c",
"embed/sec/time_estimate/stm32/time_estimate.c",
"embed/sys/dbg/stm32/dbg_printf.c",
"embed/sys/irq/stm32/irq.c",
diff --git a/core/site_scons/models/unix_common.py b/core/site_scons/models/unix_common.py
index 7b33206c..e875d6fb 100644
--- a/core/site_scons/models/unix_common.py
+++ b/core/site_scons/models/unix_common.py
@@ -11,7 +11,6 @@ def unix_common_files(env, defines, sources, paths):
paths += [
"embed/io/display/inc",
"embed/io/usb/inc",
- "embed/sec/entropy/inc",
"embed/sec/random_delays/inc",
"embed/sec/time_estimate/inc",
"embed/sys/bsp/inc",
@@ -33,10 +32,10 @@ def unix_common_files(env, defines, sources, paths):
sources += [
"embed/io/display/unix/display_driver.c",
"embed/io/usb/unix/usb.c",
- "embed/sec/entropy/unix/entropy.c",
"embed/sec/random_delays/unix/random_delays.c",
"embed/sec/secret/unix/secret.c",
"embed/sec/secret/unix/secret_keys.c",
+ "embed/sec/storage/unix/storage_salt.c",
"embed/sec/monoctr/unix/monoctr.c",
"embed/sec/rng/unix/rng.c",
"embed/sec/time_estimate/unix/time_estimate.c",
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.