Skip to content

Commit f1d41a8

Browse files
committed
Merge remote-tracking branch 'benma/securechip_model'
2 parents 2fd10c8 + 0365f72 commit f1d41a8

File tree

13 files changed

+87
-25
lines changed

13 files changed

+87
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44
- Attempt to fix flaky SD behavior
5+
- Add securechip_model to DeviceInfo: ATECCC608A or ATECC608B.
56

67
## 9.5.0 [released 2021-03-10]
78
- RestoreFrommnemonic: ported to Rust. Will now return UserAbortError on user abort instead of GenericError.

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ endif()
8989
#
9090
# Versions MUST contain three parts and start with lowercase 'v'.
9191
# Example 'v1.0.0'. They MUST not contain a pre-release label such as '-beta'.
92-
set(FIRMWARE_VERSION "v9.5.0")
93-
set(FIRMWARE_BTC_ONLY_VERSION "v9.5.0")
94-
set(FIRMWARE_BITBOXBASE_VERSION "v9.5.0")
92+
set(FIRMWARE_VERSION "v9.6.0")
93+
set(FIRMWARE_BTC_ONLY_VERSION "v9.6.0")
94+
set(FIRMWARE_BITBOXBASE_VERSION "v9.6.0")
9595
set(BOOTLOADER_VERSION "v1.0.3")
9696

9797
find_package(PythonInterp 3.6 REQUIRED)

messages/bitbox02_system.proto

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ message DeviceInfoRequest {
2626
}
2727

2828
message DeviceInfoResponse {
29-
string name = 1;
30-
bool initialized = 2;
31-
string version = 3;
32-
bool mnemonic_passphrase_enabled = 4;
33-
uint32 monotonic_increments_remaining = 5;
29+
string name = 1;
30+
bool initialized = 2;
31+
string version = 3;
32+
bool mnemonic_passphrase_enabled = 4;
33+
uint32 monotonic_increments_remaining = 5;
34+
// From v9.6.0: "ATECC608A" or "ATECC608B".
35+
string securechip_model = 6;
3436
}
3537

3638
message InsertRemoveSDCardRequest {

py/bitbox02/bitbox02/bitbox02/bitbox02.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,17 @@ def device_info(self) -> Dict[str, Any]:
135135
device_info_request = bitbox02_system.DeviceInfoRequest()
136136
request.device_info.CopyFrom(device_info_request)
137137
response = self._msg_query(request, expected_response="device_info")
138-
return {
138+
result = {
139139
"name": response.device_info.name,
140140
"version": response.device_info.version,
141141
"initialized": response.device_info.initialized,
142142
"mnemonic_passphrase_enabled": response.device_info.mnemonic_passphrase_enabled,
143143
"monotonic_increments_remaining": response.device_info.monotonic_increments_remaining,
144144
}
145+
if self.version >= semver.VersionInfo(9, 6, 0):
146+
result["securechip_model"] = response.device_info.securechip_model
147+
148+
return result
145149

146150
def set_device_name(self, device_name: str) -> None:
147151
# pylint: disable=no-member

py/bitbox02/bitbox02/communication/generated/bitbox02_system_pb2.py

Lines changed: 21 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py/bitbox02/bitbox02/communication/generated/bitbox02_system_pb2.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class DeviceInfoResponse(google___protobuf___message___Message):
6161
version = ... # type: typing___Text
6262
mnemonic_passphrase_enabled = ... # type: bool
6363
monotonic_increments_remaining = ... # type: int
64+
securechip_model = ... # type: typing___Text
6465

6566
def __init__(self,
6667
*,
@@ -69,15 +70,16 @@ class DeviceInfoResponse(google___protobuf___message___Message):
6970
version : typing___Optional[typing___Text] = None,
7071
mnemonic_passphrase_enabled : typing___Optional[bool] = None,
7172
monotonic_increments_remaining : typing___Optional[int] = None,
73+
securechip_model : typing___Optional[typing___Text] = None,
7274
) -> None: ...
7375
@classmethod
7476
def FromString(cls, s: bytes) -> DeviceInfoResponse: ...
7577
def MergeFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
7678
def CopyFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
7779
if sys.version_info >= (3,):
78-
def ClearField(self, field_name: typing_extensions___Literal[u"initialized",u"mnemonic_passphrase_enabled",u"monotonic_increments_remaining",u"name",u"version"]) -> None: ...
80+
def ClearField(self, field_name: typing_extensions___Literal[u"initialized",u"mnemonic_passphrase_enabled",u"monotonic_increments_remaining",u"name",u"securechip_model",u"version"]) -> None: ...
7981
else:
80-
def ClearField(self, field_name: typing_extensions___Literal[u"initialized",b"initialized",u"mnemonic_passphrase_enabled",b"mnemonic_passphrase_enabled",u"monotonic_increments_remaining",b"monotonic_increments_remaining",u"name",b"name",u"version",b"version"]) -> None: ...
82+
def ClearField(self, field_name: typing_extensions___Literal[u"initialized",b"initialized",u"mnemonic_passphrase_enabled",b"mnemonic_passphrase_enabled",u"monotonic_increments_remaining",b"monotonic_increments_remaining",u"name",b"name",u"securechip_model",b"securechip_model",u"version",b"version"]) -> None: ...
8183

8284
class InsertRemoveSDCardRequest(google___protobuf___message___Message):
8385
class SDCardAction(int):

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ add_custom_target(rust-bindgen
344344
--whitelist-function securechip_attestation_sign
345345
--whitelist-function securechip_monotonic_increments_remaining
346346
--whitelist-function securechip_u2f_counter_set
347+
--whitelist-function securechip_model
348+
--rustified-enum securechip_model_t
347349
--whitelist-function keystore_is_locked
348350
--whitelist-function keystore_unlock
349351
--whitelist-function keystore_unlock_bip39

src/rust/bitbox02-rust/src/hww/api/device_info.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ pub fn process() -> Result<Response, Error> {
2626
version: bitbox02::version_short().into(),
2727
mnemonic_passphrase_enabled: memory::is_mnemonic_passphrase_enabled(),
2828
monotonic_increments_remaining: securechip::monotonic_increments_remaining()?,
29+
securechip_model: match securechip::model()? {
30+
securechip::Model::SECURECHIP_ATECC608A => "ATECC608A".into(),
31+
securechip::Model::SECURECHIP_ATECC608B => "ATECC608B".into(),
32+
},
2933
}))
3034
}

src/rust/bitbox02-rust/src/shiftcrypto.bitbox02.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ pub struct DeviceInfoResponse {
9494
pub mnemonic_passphrase_enabled: bool,
9595
#[prost(uint32, tag="5")]
9696
pub monotonic_increments_remaining: u32,
97+
/// From v9.6.0: "ATECC608A" or "ATECC608B".
98+
#[prost(string, tag="6")]
99+
pub securechip_model: ::prost::alloc::string::String,
97100
}
98101
#[derive(Clone, PartialEq, ::prost::Message)]
99102
pub struct InsertRemoveSdCardRequest {

src/rust/bitbox02/src/securechip.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
pub use bitbox02_sys::securechip_model_t as Model;
16+
1517
pub fn attestation_sign(challenge: &[u8; 32], signature: &mut [u8; 64]) -> Result<(), ()> {
1618
match unsafe {
1719
bitbox02_sys::securechip_attestation_sign(challenge.as_ptr(), signature.as_mut_ptr())
@@ -49,3 +51,11 @@ pub fn u2f_counter_set(counter: u32) -> Result<(), ()> {
4951
pub fn u2f_counter_set(_counter: u32) -> Result<(), ()> {
5052
unimplemented!();
5153
}
54+
55+
pub fn model() -> Result<Model, ()> {
56+
let mut ver = core::mem::MaybeUninit::uninit();
57+
match unsafe { bitbox02_sys::securechip_model(ver.as_mut_ptr()) } {
58+
true => Ok(unsafe { ver.assume_init() }),
59+
false => Err(()),
60+
}
61+
}

0 commit comments

Comments
 (0)