Skip to content

Commit f30b120

Browse files
authored
hww: add change password workflow
Currently, changing the device password requires a full device reset and restoration from a backup. This process is cumbersome and increases the risk of user error or seed exposure during the restoration process. This patch introduces a native "Change Password" workflow that allows the user to rotate their device password without resetting the device. The workflow: 1. Forces the user to re-enter the current password for security, even if the device is already unlocked. 2. Prompts for the new password (entered twice). 3. Re-encrypts the stored seed and BIP39 entropy with the new password using the Secure Chip for key stretching. The implementation ensures that the wallet identity (Root Fingerprint and BIP39 seed) is preserved, so the device remains paired and functional with the same accounts (including passphrase) after the password change.
1 parent 7665b7f commit f30b120

File tree

14 files changed

+494
-23
lines changed

14 files changed

+494
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
99
### [Unreleased]
1010
- Fix bug that BLE was turned off when iOS device is unlocked
1111
- simulator-graphical: a new simulator with a graphical user interface
12+
- Add ability to change the device password after initial setup
1213

1314
### v9.24.0
1415
- Change title when entering recovery words to `1 of 24`, `2 of 24`, etc.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ endif()
9696
#
9797
# Versions MUST contain three parts and start with lowercase 'v'.
9898
# Example 'v1.0.0'. They MUST not contain a pre-release label such as '-beta'.
99-
set(FIRMWARE_VERSION "v9.24.0")
99+
set(FIRMWARE_VERSION "v9.25.0")
100100
set(BOOTLOADER_VERSION "v1.1.2")
101101

102102
find_package(PythonInterp 3.6 REQUIRED)

messages/bitbox02_system.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ message SetDeviceNameRequest {
6666
message SetPasswordRequest {
6767
bytes entropy = 1;
6868
}
69+
70+
message ChangePasswordRequest{
71+
}

messages/hww.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ message Request {
6969
CardanoRequest cardano = 27;
7070
BIP85Request bip85 = 28;
7171
BluetoothRequest bluetooth = 29;
72+
ChangePasswordRequest change_password = 30;
7273
}
7374
}
7475

py/bitbox02/bitbox02/bitbox02/bitbox02.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ def set_password(self, entropy_size: int = 32) -> bool:
212212
raise
213213
return True
214214

215+
def change_password(self) -> None:
216+
"""
217+
Changes the device password. The user must unlock with the old password
218+
and enter and confirm the new password.
219+
Raises a Bitbox02Exception on failure.
220+
"""
221+
# pylint: disable=no-member
222+
request = hww.Request()
223+
request.change_password.CopyFrom(bitbox02_system.ChangePasswordRequest())
224+
self._msg_query(request, expected_response="success")
225+
215226
def create_backup(self) -> bool:
216227
"""
217228
Returns True if the backup was created successfully.

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

Lines changed: 3 additions & 1 deletion
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,13 @@ class SetPasswordRequest(google.protobuf.message.Message):
208208
def ClearField(self, field_name: typing.Literal["entropy", b"entropy"]) -> None: ...
209209

210210
global___SetPasswordRequest = SetPasswordRequest
211+
212+
@typing.final
213+
class ChangePasswordRequest(google.protobuf.message.Message):
214+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
215+
216+
def __init__(
217+
self,
218+
) -> None: ...
219+
220+
global___ChangePasswordRequest = ChangePasswordRequest

py/bitbox02/bitbox02/communication/generated/hww_pb2.py

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

0 commit comments

Comments
 (0)