chore(core): test aes gcm only if enabled
What changed, and why it matters
This commit is a minor build/test maintenance change. It adds a feature flag (USE_AES_GCM) so that AES-GCM tests are only run when the feature is actually enabled in a particular firmware build. There is no security fix or vulnerability being patched.
No security action needed. This is a test/build configuration change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change exposes a compile-time flag USE_AES_GCM through the trezorutils MicroPython module, updates the generated type stub, imports it in trezor.utils, and makes the AES-GCM unit test conditional on that flag. This prevents test failures on builds where AES-GCM is disabled. No cryptographic code, memory handling, or security boundary is modified.
Changed components
core/embed/upymod/modtrezorutils/modtrezorutils.ccore/mocks/generated/trezorutils.pyicore/src/trezor/utils.pycore/tests/test_trezor.crypto.aesgcm.pyInspect captured patch +13 / −1
### core/embed/upymod/modtrezorutils/modtrezorutils.c
@@ -880,6 +880,8 @@ static const mp_obj_tuple_t mod_trezorutils_version_obj = {
/// """Whether Miniscript is supported."""
/// USE_N1W1: bool
/// """Whether N1W1 is supported."""
+/// USE_AES_GCM: bool
+/// """Whether the AES-GCM is supported."""
/// MODEL: str
/// """Model name."""
/// MODEL_FULL_NAME: str
@@ -1011,6 +1013,11 @@ static const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_USE_N1W1), mp_const_true},
#else
{MP_ROM_QSTR(MP_QSTR_USE_N1W1), mp_const_false},
+#endif
+#if USE_AES_GCM
+ {MP_ROM_QSTR(MP_QSTR_USE_AES_GCM), mp_const_true},
+#else
+ {MP_ROM_QSTR(MP_QSTR_USE_AES_GCM), mp_const_false},
#endif
{MP_ROM_QSTR(MP_QSTR_zero_unused_stack),
MP_ROM_PTR(&mod_trezorutils_zero_unused_stack_obj)},
### core/mocks/generated/trezorutils.pyi
@@ -292,6 +292,8 @@ USE_MINISCRIPT: bool
"""Whether Miniscript is supported."""
USE_N1W1: bool
"""Whether N1W1 is supported."""
+USE_AES_GCM: bool
+"""Whether the AES-GCM is supported."""
MODEL: str
"""Model name."""
MODEL_FULL_NAME: str
### core/src/trezor/utils.py
@@ -21,6 +21,7 @@
NOTIFY_WIPE,
SCM_REVISION_XOR2,
UI_LAYOUT,
+ USE_AES_GCM,
USE_APP_LOADING,
USE_BACKLIGHT,
USE_BLE,
### core/tests/test_trezor.crypto.aesgcm.py
@@ -1,9 +1,11 @@
# flake8: noqa: F403,F405
from common import * # isort:skip
-from trezor.crypto import AuthenticationError, aesgcm_decrypt, aesgcm_encrypt
+if utils.USE_AES_GCM:
+ from trezor.crypto import AuthenticationError, aesgcm_decrypt, aesgcm_encrypt
+@unittest.skipUnless(utils.USE_AES_GCM, "AES-GCM not supported")
class TestCryptoAes(unittest.TestCase):
# test vectors from
# https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/mac/gcmtestvectors.zipWhy 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.