feat(core): implement missing drivers in emulator
What changed, and why it matters
This commit adds software 'stubs' that let the Trezor firmware emulator (a simulated version used for development/testing) compile and run on a regular computer. These stubs replace real hardware security features—such as tamper detection, secure memory, hardware encryption, and the secure chip (Optiga)—with no-op or always-success placeholders. There is no indication this code is meant for real Trezor devices, and the commit message explicitly frames it as emulator-only driver implementation. It does not appear to be a security fix or vulnerability patch.
No security action required. Treat as normal emulator build-support commit. If reviewing for release integrity, verify that TREZOR_EMULATOR remains undefined in production firmware builds and that these stubs are not accidentally linked into hardware images.
Security signals we found
Emulator-only code paths guarded by TREZOR_EMULATOR / unix/ directory placement
Security-sensitive hardware drivers replaced with stub implementations in emulator
No production hardware driver logic modified
No changelog entry, consistent with non-security feature
Evidence from the diff
The diff introduces emulator-specific (unix/) implementations for multiple hardware abstraction layers: haptic, nrf, backup_ram, consumption_mask, hw_revision, iwdg, optiga_commands/transport, secret, secure_aes, tamper, pvd, and rtc. Most functions are empty, return success/sectrue, or return fixed false/zero values. A single real file change wraps an address adjustment in boot_ucb.c with #ifndef TREZOR_EMULATOR so the emulator does not perform secure-flash address translation. The commit is tagged [no changelog] and titled as a feature for the emulator. No security-relevant behavior is changed on production hardware builds.
Changed components
core/embed/io/haptic/unix/haptic.ccore/embed/io/nrf/unix/nrf.ccore/embed/sec/backup_ram/unix/backup_ram.ccore/embed/sec/consumption_mask/unix/consumption_mask.ccore/embed/sec/hw_revision/unix/hw_revision.ccore/embed/sec/image/boot_ucb.ccore/embed/sec/iwdg/unix/iwdg.ccore/embed/sec/optiga/unix/optiga_commands.ccore/embed/sec/optiga/unix/optiga_transport.ccore/embed/sec/secret/unix/secret.ccore/embed/sec/secure_aes/unix/secure_aes.ccore/embed/sec/tamper/unix/tamper.ccore/embed/sys/pvd/inc/sys/pvd.hcore/embed/sys/pvd/unix/pvd.ccore/embed/sys/time/unix/rtc.cInspect captured patch +380 / −4
diff --git a/core/embed/io/haptic/unix/haptic.c b/core/embed/io/haptic/unix/haptic.c
new file mode 100644
index 00000000..ff114d4a
--- /dev/null
+++ b/core/embed/io/haptic/unix/haptic.c
@@ -0,0 +1,94 @@
+/*
+ * 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_rtl.h>
+
+#include <io/haptic.h>
+
+typedef struct {
+ bool initialized;
+ bool enabled;
+} haptic_driver_t;
+
+static haptic_driver_t g_haptic_driver = {
+ .initialized = false,
+};
+
+ts_t __wur haptic_init(void) {
+ haptic_driver_t *drv = &g_haptic_driver;
+
+ if (drv->initialized) {
+ return TS_OK;
+ }
+
+ memset(drv, 0, sizeof(*drv));
+ drv->initialized = true;
+
+ return TS_OK;
+}
+
+void haptic_deinit(void) {
+ haptic_driver_t *drv = &g_haptic_driver;
+ memset(drv, 0, sizeof(*drv));
+}
+
+ts_t haptic_set_enabled(bool enabled) {
+ TSH_DECLARE;
+
+ haptic_driver_t *drv = &g_haptic_driver;
+
+ TSH_CHECK(drv->initialized, TS_ENOINIT);
+
+ drv->enabled = enabled;
+
+cleanup:
+ TSH_RETURN;
+}
+
+bool haptic_get_enabled(void) {
+ haptic_driver_t *drv = &g_haptic_driver;
+
+ if (!drv->initialized) {
+ return false;
+ }
+
+ return drv->enabled;
+}
+
+ts_t haptic_play(haptic_effect_t effect) {
+ TSH_DECLARE;
+
+ haptic_driver_t *drv = &g_haptic_driver;
+
+ TSH_CHECK(drv->initialized, TS_ENOINIT);
+
+cleanup:
+ TSH_RETURN;
+}
+
+ts_t haptic_play_custom(int8_t amplitude_pct, uint16_t duration_ms) {
+ TSH_DECLARE;
+
+ haptic_driver_t *drv = &g_haptic_driver;
+
+ TSH_CHECK(drv->initialized, TS_ENOINIT);
+
+cleanup:
+ TSH_RETURN;
+}
diff --git a/core/embed/io/nrf/unix/nrf.c b/core/embed/io/nrf/unix/nrf.c
new file mode 100644
index 00000000..9595f1b7
--- /dev/null
+++ b/core/embed/io/nrf/unix/nrf.c
@@ -0,0 +1,24 @@
+/*
+ * 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 <io/nrf.h>
+
+void nrf_reboot(void) {}
+
+uint32_t nrf_get_version(void) { return 0; }
diff --git a/core/embed/sec/backup_ram/unix/backup_ram.c b/core/embed/sec/backup_ram/unix/backup_ram.c
new file mode 100644
index 00000000..c6f96f9b
--- /dev/null
+++ b/core/embed/sec/backup_ram/unix/backup_ram.c
@@ -0,0 +1,44 @@
+/*
+ * 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 <sec/backup_ram.h>
+
+bool backup_ram_init(void) { return true; }
+
+void backup_ram_deinit(void) {}
+
+bool backup_ram_erase(void) { return false; }
+
+bool backup_ram_erase_protected(void) { return false; }
+
+bool backup_ram_erase_item(uint16_t key) { return false; }
+
+uint16_t backup_ram_search(uint16_t min_key) { return BACKUP_RAM_INVALID_KEY; }
+
+bool backup_ram_write(uint16_t key, backup_ram_item_type_t type,
+ const void* data, size_t data_size) {
+ return false;
+}
+
+bool backup_ram_read(uint16_t key, void* buffer, size_t buffer_size,
+ size_t* data_size) {
+ return false;
+}
+
+bool backup_ram_kernel_accessible(uint16_t key) { return false; }
diff --git a/core/embed/sec/consumption_mask/unix/consumption_mask.c b/core/embed/sec/consumption_mask/unix/consumption_mask.c
new file mode 100644
index 00000000..235d78d9
--- /dev/null
+++ b/core/embed/sec/consumption_mask/unix/consumption_mask.c
@@ -0,0 +1,24 @@
+/*
+ * 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 <sec/consumption_mask.h>
+
+void consumption_mask_init(void) {}
+
+void consumption_mask_randomize() {}
diff --git a/core/embed/sec/hw_revision/unix/hw_revision.c b/core/embed/sec/hw_revision/unix/hw_revision.c
new file mode 100644
index 00000000..13bc9b3e
--- /dev/null
+++ b/core/embed/sec/hw_revision/unix/hw_revision.c
@@ -0,0 +1,26 @@
+/*
+ * 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 <sec/hw_revision.h>
+
+void hw_revision_init(void) {}
+
+void hw_revision_deinit(void) {}
+
+uint8_t hw_revision_get(void) { return 0; }
diff --git a/core/embed/sec/image/boot_ucb.c b/core/embed/sec/image/boot_ucb.c
index f1b75675..bed3875b 100644
--- a/core/embed/sec/image/boot_ucb.c
+++ b/core/embed/sec/image/boot_ucb.c
@@ -34,11 +34,13 @@
#if defined(BOOTLOADER) || defined(BOARDLOADER)
void adjust_to_secure_flash(uint32_t* address) {
+#ifndef TREZOR_EMULATOR
if (*address < FLASH_BASE_S) {
// Address is in the non-secure flash region, adjust it to point to the
// secure flash region.
*address += FLASH_BASE_S - FLASH_BASE_NS;
}
+#endif
}
#endif
diff --git a/core/embed/sec/iwdg/unix/iwdg.c b/core/embed/sec/iwdg/unix/iwdg.c
new file mode 100644
index 00000000..5b059c28
--- /dev/null
+++ b/core/embed/sec/iwdg/unix/iwdg.c
@@ -0,0 +1,22 @@
+/*
+ * 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 <sec/iwdg.h>
+
+void iwdg_start(uint32_t time_s) {}
diff --git a/core/embed/sec/optiga/unix/optiga_commands.c b/core/embed/sec/optiga/unix/optiga_commands.c
new file mode 100644
index 00000000..32b1f2db
--- /dev/null
+++ b/core/embed/sec/optiga/unix/optiga_commands.c
@@ -0,0 +1,22 @@
+/*
+ * 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 <sec/optiga_commands.h>
+
+optiga_result optiga_open_application(void) { return OPTIGA_SUCCESS; }
diff --git a/core/embed/sec/optiga/unix/optiga_transport.c b/core/embed/sec/optiga/unix/optiga_transport.c
new file mode 100644
index 00000000..c079783c
--- /dev/null
+++ b/core/embed/sec/optiga/unix/optiga_transport.c
@@ -0,0 +1,24 @@
+/*
+ * 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 <sec/optiga_transport.h>
+
+void optiga_transport_power_up(void) {}
+
+optiga_result optiga_transport_open_channel(void) { return OPTIGA_SUCCESS; }
diff --git a/core/embed/sec/secret/unix/secret.c b/core/embed/sec/secret/unix/secret.c
index f4d277c3..c7c943b7 100644
--- a/core/embed/sec/secret/unix/secret.c
+++ b/core/embed/sec/secret/unix/secret.c
@@ -191,4 +191,6 @@ secbool secret_lock(void) {
#endif
+void secret_bhk_regenerate(void) {}
+
#endif // KERNEL_MODE
diff --git a/core/embed/sec/secure_aes/unix/secure_aes.c b/core/embed/sec/secure_aes/unix/secure_aes.c
new file mode 100644
index 00000000..b241d96a
--- /dev/null
+++ b/core/embed/sec/secure_aes/unix/secure_aes.c
@@ -0,0 +1,23 @@
+
+/*
+ * 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 <sec/secure_aes.h>
+
+secbool secure_aes_init(void) { return sectrue; }
diff --git a/core/embed/sec/tamper/unix/tamper.c b/core/embed/sec/tamper/unix/tamper.c
new file mode 100644
index 00000000..21f47a99
--- /dev/null
+++ b/core/embed/sec/tamper/unix/tamper.c
@@ -0,0 +1,28 @@
+/*
+ * 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 <sec/tamper.h>
+
+bool tamper_init(void) {}
+
+uint8_t tamper_external_read(void) { return 0; }
+
+void tamper_external_enable(void) {}
+
+void tamper_external_disable(void) {}
diff --git a/core/embed/sys/pvd/inc/sys/pvd.h b/core/embed/sys/pvd/inc/sys/pvd.h
index 74e28870..760d28d1 100644
--- a/core/embed/sys/pvd/inc/sys/pvd.h
+++ b/core/embed/sys/pvd/inc/sys/pvd.h
@@ -17,8 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef TREZORHAL_PVD_H
-#define TREZORHAL_PVD_H
+#pragma once
#ifdef KERNEL_MODE
@@ -29,5 +28,3 @@
void pvd_init(void);
#endif // KERNEL_MODE
-
-#endif // TREZORHAL_PVD_H
diff --git a/core/embed/sys/pvd/unix/pvd.c b/core/embed/sys/pvd/unix/pvd.c
new file mode 100644
index 00000000..2a42a8b4
--- /dev/null
+++ b/core/embed/sys/pvd/unix/pvd.c
@@ -0,0 +1,22 @@
+/*
+ * 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/>.
+ */
+
+void pvd_init(void) {
+ // Not implemented in emulator
+}
diff --git a/core/embed/sys/time/unix/rtc.c b/core/embed/sys/time/unix/rtc.c
new file mode 100644
index 00000000..745d4c81
--- /dev/null
+++ b/core/embed/sys/time/unix/rtc.c
@@ -0,0 +1,22 @@
+/*
+ * 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 <sys/rtc.h>
+
+bool rtc_init(void) { return true; }
Why this scored 15/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.