What changed, and why it matters
This commit removes an unused header file called keystore.h and updates the code that previously included it. The two constants that were defined in that header (KEYSTORE_U2F_SEED_LENGTH and XPUB_ENCODED_LEN) are no longer referenced through the header. In the U2F code, the seed length is now taken directly from the size of the local seed variable using sizeof(seed), which is functionally equivalent because the seed is a fixed-size array of the same length. There is no security-relevant change here—this is a cleanup refactor.
No security action required. Treat as routine code hygiene. If reviewing, verify that no other translation units still depend on the removed constants and that the Rust bindgen build succeeds without the removed allowlist entries.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes src/keystore.h, which only contained two macro definitions: KEYSTORE_U2F_SEED_LENGTH (equal to SHA256_LEN) and XPUB_ENCODED_LEN (113). It removes #include directives from common_main.c, hww.c, reset.c, u2f.c, and the Rust bindgen wrapper.h. It also removes XPUB_ENCODED_LEN from the bindgen allowlist. In src/u2f.c, two calls to rust_hmac_sha256 that previously passed KEYSTORE_U2F_SEED_LENGTH now pass sizeof(seed). Since seed is declared locally as a fixed-size byte array of length SHA256_LEN, the behavior is unchanged. No functional logic, cryptography, or memory safety properties are altered.
Changed components
src/keystore.hsrc/common_main.csrc/hww.csrc/reset.csrc/u2f.csrc/rust/bitbox02-sys/build.rssrc/rust/bitbox02-sys/wrapper.hInspect captured patch +2 / −33
diff --git a/src/common_main.c b/src/common_main.c
index 3825de6..5ee6fc0 100644
--- a/src/common_main.c
+++ b/src/common_main.c
@@ -16,7 +16,6 @@
#include "driver_init.h"
#include "flags.h"
#include "hardfault.h"
-#include "keystore.h"
#include "memory/memory.h"
#include "memory/mpu.h"
#include "memory/smarteeprom.h"
diff --git a/src/hww.c b/src/hww.c
index 390027b..fb95727 100644
--- a/src/hww.c
+++ b/src/hww.c
@@ -15,7 +15,6 @@
#include "hww.h"
#include <hardfault.h>
-#include <keystore.h>
#include <memory/memory.h>
#include <version.h>
diff --git a/src/keystore.h b/src/keystore.h
deleted file mode 100644
index 6e83152..0000000
--- a/src/keystore.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2019 Shift Cryptosecurity AG
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef _KEYSTORE_H_
-#define _KEYSTORE_H_
-
-#include "compiler_util.h"
-
-#define KEYSTORE_U2F_SEED_LENGTH SHA256_LEN
-
-// Max. length of an xpub string, including the null terminator.
-#define XPUB_ENCODED_LEN 113
-
-#endif
diff --git a/src/reset.c b/src/reset.c
index 1535b16..ecbfc2e 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -16,7 +16,6 @@
#include "da14531/da14531.h"
#include "hardfault.h"
-#include "keystore.h"
#include "memory/memory.h"
#include "memory/memory_shared.h"
#include "system.h"
diff --git a/src/rust/bitbox02-sys/build.rs b/src/rust/bitbox02-sys/build.rs
index a761f82..1b95113 100644
--- a/src/rust/bitbox02-sys/build.rs
+++ b/src/rust/bitbox02-sys/build.rs
@@ -46,7 +46,6 @@ const ALLOWLIST_VARS: &[&str] = &[
"secfalse_u8",
"SD_MAX_FILE_SIZE",
"SLIDER_POSITION_TWO_THIRD",
- "XPUB_ENCODED_LEN",
];
const ALLOWLIST_TYPES: &[&str] = &[
diff --git a/src/rust/bitbox02-sys/wrapper.h b/src/rust/bitbox02-sys/wrapper.h
index 6f6aaef..40d1d4a 100644
--- a/src/rust/bitbox02-sys/wrapper.h
+++ b/src/rust/bitbox02-sys/wrapper.h
@@ -14,7 +14,6 @@
#include <communication_mode.h>
#include <delay.h>
-#include <keystore.h>
#include <memory/bitbox02_smarteeprom.h>
#include <memory/memory.h>
#include <memory/memory_shared.h>
diff --git a/src/u2f.c b/src/u2f.c
index a4c9d0e..61e0e29 100644
--- a/src/u2f.c
+++ b/src/u2f.c
@@ -17,7 +17,6 @@
#include <string.h>
#include <hardfault.h>
-#include <keystore.h>
#include <memory/memory.h>
#include <random.h>
#include <rust/rust.h>
@@ -264,11 +263,11 @@ USE_RESULT static bool _keyhandle_gen(
// Concatenate AppId and Nonce as input for the first HMAC round
memcpy(hmac_in, appId, U2F_APPID_SIZE);
memcpy(hmac_in + U2F_APPID_SIZE, nonce, U2F_NONCE_LENGTH);
- rust_hmac_sha256(seed, KEYSTORE_U2F_SEED_LENGTH, hmac_in, sizeof(hmac_in), privkey);
+ rust_hmac_sha256(seed, sizeof(seed), hmac_in, sizeof(hmac_in), privkey);
// Concatenate AppId and privkey for the second HMAC round
memcpy(hmac_in + U2F_APPID_SIZE, privkey, HMAC_SHA256_LEN);
- rust_hmac_sha256(seed, KEYSTORE_U2F_SEED_LENGTH, hmac_in, sizeof(hmac_in), mac);
+ rust_hmac_sha256(seed, sizeof(seed), hmac_in, sizeof(hmac_in), mac);
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.