What changed, and why it matters
This commit is a small internal cleanup in the BitBox02 firmware's code for talking to the Optiga secure chip. It removes an unused callback pointer and simplifies how some factory-only data is written. There is no indication this fixes a security bug or introduces a vulnerability; it appears to be ordinary maintenance.
No security action required. Treat as routine refactoring. If desired, verify downstream callers no longer pass `ifs` to `optiga_setup()` and that `SC_ERR_IFS` is no longer referenced.
Security signals we found
No security-relevant keywords in commit title or message
No bug-fix language or CVE references present
Change is purely a reduction/removal of unused interface state
Factory-setup-only code paths affected, not normal runtime
Evidence from the diff
The patch removes the securechip_interface_functions_t (ifs) parameter from optiga_setup() because it was stored but never used. It also replaces a packed union (arbitrary_data_t) used only in factory-setup paths with a plain uint8_t buffer plus length, and updates the Rust call site accordingly. No functional behavior changes are visible beyond removing dead code and a now-unnecessary error path (SC_ERR_IFS).
Changed components
src/optiga/optiga.csrc/optiga/optiga.hsrc/rust/bitbox02/src/securechip/imp.rsInspect captured patch +7 / −31
diff --git a/src/optiga/optiga.c b/src/optiga/optiga.c
index 6fb7842..ad54515 100644
--- a/src/optiga/optiga.c
+++ b/src/optiga/optiga.c
@@ -30,23 +30,9 @@
#define VERIFY_METADATA 0
#endif
-// Struct stored in the arbitrary data object.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpacked"
-#pragma GCC diagnostic ignored "-Wattributes"
-typedef union {
- struct __attribute__((__packed__)) {
- uint32_t u2f_counter;
- } fields;
- uint8_t bytes[ARBITRARY_DATA_OBJECT_TYPE_3_MAX_SIZE];
-} arbitrary_data_t;
-#pragma GCC diagnostic pop
-
static optiga_util_t* _util;
static optiga_crypt_t* _crypt;
-static const securechip_interface_functions_t* _ifs = NULL;
-
#define TAG_LCSO 0xC0
#if FACTORYSETUP == 1 || FACTORY_DURING_PROD == 1 || VERIFY_METADATA == 1
@@ -469,15 +455,10 @@ static int _reset_counter(uint16_t oid, uint32_t limit)
#endif
#if FACTORYSETUP == 1 || FACTORY_DURING_PROD == 1
-static int _write_arbitrary_data(const arbitrary_data_t* data)
+static int _write_arbitrary_data(const uint8_t* data, size_t data_len)
{
optiga_lib_status_t res = optiga_ops_util_write_data_sync(
- _util,
- OID_ARBITRARY_DATA,
- OPTIGA_UTIL_ERASE_AND_WRITE,
- 0,
- &data->bytes[0],
- sizeof(data->bytes));
+ _util, OID_ARBITRARY_DATA, OPTIGA_UTIL_ERASE_AND_WRITE, 0, data, data_len);
if (res != OPTIGA_LIB_SUCCESS) {
util_log("could not write arbitrary %x", res);
}
@@ -695,8 +676,8 @@ static int _configure_object_arbitrary_data(void)
}
// Initialize arbitrary data, all zeroes.
- const arbitrary_data_t arbitrary_data = {0};
- int write_res = _write_arbitrary_data(&arbitrary_data);
+ const uint8_t arbitrary_data[ARBITRARY_DATA_OBJECT_TYPE_3_MAX_SIZE] = {0};
+ int write_res = _write_arbitrary_data(arbitrary_data, sizeof(arbitrary_data));
if (write_res != OPTIGA_LIB_SUCCESS) {
util_log("could not initialize arbitrary data");
return write_res;
@@ -1180,13 +1161,8 @@ static int _verify_metadata_config(void)
}
#endif
-int optiga_setup(const securechip_interface_functions_t* ifs)
+int optiga_setup(void)
{
- if (ifs == NULL) {
- return SC_ERR_IFS;
- }
- _ifs = ifs;
-
util_log("optiga_setup");
// A timer is used to provide the OPTIGA library with the ability to schedule work on the main
diff --git a/src/optiga/optiga.h b/src/optiga/optiga.h
index 078ac7f..ce13699 100644
--- a/src/optiga/optiga.h
+++ b/src/optiga/optiga.h
@@ -90,7 +90,7 @@ typedef struct optiga_crypt optiga_crypt_t;
// Two extra bytes for the `0x20 <len>` header bytes.
#define METADATA_MAX_SIZE (44 + 2)
-USE_RESULT int optiga_setup(const securechip_interface_functions_t* ifs);
+USE_RESULT int optiga_setup(void);
USE_RESULT bool optiga_gen_attestation_key(uint8_t* pubkey_out);
USE_RESULT optiga_util_t* optiga_util_instance(void);
USE_RESULT optiga_crypt_t* optiga_crypt_instance(void);
diff --git a/src/rust/bitbox02/src/securechip/imp.rs b/src/rust/bitbox02/src/securechip/imp.rs
index 1b043cb..79bd313 100644
--- a/src/rust/bitbox02/src/securechip/imp.rs
+++ b/src/rust/bitbox02/src/securechip/imp.rs
@@ -130,7 +130,7 @@ pub unsafe extern "C" fn rust_securechip_setup(
) -> c_int {
match backend() {
Backend::Atecc => unsafe { bitbox_securechip_sys::atecc_setup(ifs) },
- Backend::Optiga => unsafe { bitbox_securechip_sys::optiga_setup(ifs) },
+ Backend::Optiga => unsafe { bitbox_securechip_sys::optiga_setup() },
}
}
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.