Skip to content

Commit 5ffaae4

Browse files
committed
rust/bitbox02: add get_securechip_type()
Will be needed to decide if they keyboard in the password entry should default to digits.
1 parent e66abab commit 5ffaae4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/rust/bitbox02-sys/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const ALLOWLIST_VARS: &[&str] = &[
4040
"MEMORY_SPI_BLE_FIRMWARE_2_ADDR",
4141
"MEMORY_PLATFORM_BITBOX02",
4242
"MEMORY_PLATFORM_BITBOX02_PLUS",
43+
"MEMORY_SECURECHIP_TYPE_ATECC",
44+
"MEMORY_SECURECHIP_TYPE_OPTIGA",
4345
];
4446

4547
const ALLOWLIST_TYPES: &[&str] = &[
@@ -110,6 +112,7 @@ const ALLOWLIST_FNS: &[&str] = &[
110112
"memory_get_ble_metadata",
111113
"memory_set_ble_metadata",
112114
"memory_get_platform",
115+
"memory_get_securechip_type",
113116
"memory_spi_get_active_ble_firmware_version",
114117
"spi_mem_write",
115118
"menu_create",

src/rust/bitbox02/src/memory.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ pub fn get_platform() -> Result<Platform, ()> {
175175
}
176176
}
177177

178+
pub enum SecurechipType {
179+
Atecc,
180+
Optiga,
181+
}
182+
183+
pub fn get_securechip_type() -> Result<SecurechipType, ()> {
184+
match unsafe { bitbox02_sys::memory_get_securechip_type() as u32 } {
185+
bitbox02_sys::MEMORY_SECURECHIP_TYPE_ATECC => Ok(SecurechipType::Atecc),
186+
bitbox02_sys::MEMORY_SECURECHIP_TYPE_OPTIGA => Ok(SecurechipType::Optiga),
187+
_ => Err(()),
188+
}
189+
}
190+
178191
pub fn get_ble_metadata() -> BleMetadata {
179192
let mut metadata = core::mem::MaybeUninit::uninit();
180193

0 commit comments

Comments
 (0)