Skip to content

Commit aa51529

Browse files
committed
src: change password functionality
This commit adds changing password feature. The feature can only be used when the device is initialized. It shares a lot of the functionality with set password feature, but it requires the user to enter the old password correctly, and also does some seed handling to not cause any data loss. Signed-off-by: asi345 <[email protected]>
1 parent be2ea72 commit aa51529

File tree

17 files changed

+196
-17
lines changed

17 files changed

+196
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
1111
- Ethereum: remove deprecated Goerli network
1212
- SD card: solve backup bug when sd card is re-inserted
1313
- Cardano: allow serialization using 258-tagged sets
14+
- Add change password functionality
1415

1516
### 9.21.0
1617
- Bitcoin: add support for sending to silent payment (BIP-352) addresses

messages/bitbox02_system.proto

+3
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ message SetDeviceNameRequest {
5656
message SetPasswordRequest {
5757
bytes entropy = 1;
5858
}
59+
60+
message ChangePasswordRequest {
61+
}

messages/hww.proto

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ message Request {
6767
ElectrumEncryptionKeyRequest electrum_encryption_key = 26;
6868
CardanoRequest cardano = 27;
6969
BIP85Request bip85 = 28;
70+
ChangePasswordRequest change_password = 29;
7071
}
7172
}
7273

py/bitbox02/bitbox02/bitbox02/bitbox02.py

+11
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ def set_password(self, entropy_size: int = 32) -> bool:
190190
raise
191191
return True
192192

193+
def change_password(self) -> bool:
194+
request = hww.Request()
195+
request.change_password.CopyFrom(bitbox02_system.ChangePasswordRequest())
196+
try:
197+
self._msg_query(request, expected_response="success")
198+
except Bitbox02Exception as err:
199+
if err.code == ERR_GENERIC:
200+
return False
201+
raise
202+
return True
203+
193204
def create_backup(self) -> bool:
194205
"""
195206
Returns True if the backup was created successfully.

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

+3-1
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

+6
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,9 @@ class SetPasswordRequest(google.protobuf.message.Message):
124124
) -> None: ...
125125
def ClearField(self, field_name: typing_extensions.Literal["entropy",b"entropy"]) -> None: ...
126126
global___SetPasswordRequest = SetPasswordRequest
127+
128+
class ChangePasswordRequest(google.protobuf.message.Message):
129+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
130+
def __init__(self,
131+
) -> None: ...
132+
global___ChangePasswordRequest = ChangePasswordRequest

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

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Request(google.protobuf.message.Message):
6868
ELECTRUM_ENCRYPTION_KEY_FIELD_NUMBER: builtins.int
6969
CARDANO_FIELD_NUMBER: builtins.int
7070
BIP85_FIELD_NUMBER: builtins.int
71+
CHANGE_PASSWORD_FIELD_NUMBER: builtins.int
7172
@property
7273
def device_name(self) -> bitbox02_system_pb2.SetDeviceNameRequest:
7374
"""removed: RandomNumberRequest random_number = 1;"""
@@ -124,6 +125,8 @@ class Request(google.protobuf.message.Message):
124125
def cardano(self) -> cardano_pb2.CardanoRequest: ...
125126
@property
126127
def bip85(self) -> keystore_pb2.BIP85Request: ...
128+
@property
129+
def change_password(self) -> bitbox02_system_pb2.ChangePasswordRequest: ...
127130
def __init__(self,
128131
*,
129132
device_name: typing.Optional[bitbox02_system_pb2.SetDeviceNameRequest] = ...,
@@ -152,10 +155,11 @@ class Request(google.protobuf.message.Message):
152155
electrum_encryption_key: typing.Optional[keystore_pb2.ElectrumEncryptionKeyRequest] = ...,
153156
cardano: typing.Optional[cardano_pb2.CardanoRequest] = ...,
154157
bip85: typing.Optional[keystore_pb2.BIP85Request] = ...,
158+
change_password: typing.Optional[bitbox02_system_pb2.ChangePasswordRequest] = ...,
155159
) -> None: ...
156-
def HasField(self, field_name: typing_extensions.Literal["bip85",b"bip85","btc",b"btc","btc_pub",b"btc_pub","btc_sign_init",b"btc_sign_init","btc_sign_input",b"btc_sign_input","btc_sign_output",b"btc_sign_output","cardano",b"cardano","check_backup",b"check_backup","check_sdcard",b"check_sdcard","create_backup",b"create_backup","device_info",b"device_info","device_language",b"device_language","device_name",b"device_name","electrum_encryption_key",b"electrum_encryption_key","eth",b"eth","fingerprint",b"fingerprint","insert_remove_sdcard",b"insert_remove_sdcard","list_backups",b"list_backups","perform_attestation",b"perform_attestation","reboot",b"reboot","request",b"request","reset",b"reset","restore_backup",b"restore_backup","restore_from_mnemonic",b"restore_from_mnemonic","set_mnemonic_passphrase_enabled",b"set_mnemonic_passphrase_enabled","set_password",b"set_password","show_mnemonic",b"show_mnemonic"]) -> builtins.bool: ...
157-
def ClearField(self, field_name: typing_extensions.Literal["bip85",b"bip85","btc",b"btc","btc_pub",b"btc_pub","btc_sign_init",b"btc_sign_init","btc_sign_input",b"btc_sign_input","btc_sign_output",b"btc_sign_output","cardano",b"cardano","check_backup",b"check_backup","check_sdcard",b"check_sdcard","create_backup",b"create_backup","device_info",b"device_info","device_language",b"device_language","device_name",b"device_name","electrum_encryption_key",b"electrum_encryption_key","eth",b"eth","fingerprint",b"fingerprint","insert_remove_sdcard",b"insert_remove_sdcard","list_backups",b"list_backups","perform_attestation",b"perform_attestation","reboot",b"reboot","request",b"request","reset",b"reset","restore_backup",b"restore_backup","restore_from_mnemonic",b"restore_from_mnemonic","set_mnemonic_passphrase_enabled",b"set_mnemonic_passphrase_enabled","set_password",b"set_password","show_mnemonic",b"show_mnemonic"]) -> None: ...
158-
def WhichOneof(self, oneof_group: typing_extensions.Literal["request",b"request"]) -> typing.Optional[typing_extensions.Literal["device_name","device_language","device_info","set_password","create_backup","show_mnemonic","btc_pub","btc_sign_init","btc_sign_input","btc_sign_output","insert_remove_sdcard","check_sdcard","set_mnemonic_passphrase_enabled","list_backups","restore_backup","perform_attestation","reboot","check_backup","eth","reset","restore_from_mnemonic","fingerprint","btc","electrum_encryption_key","cardano","bip85"]]: ...
160+
def HasField(self, field_name: typing_extensions.Literal["bip85",b"bip85","btc",b"btc","btc_pub",b"btc_pub","btc_sign_init",b"btc_sign_init","btc_sign_input",b"btc_sign_input","btc_sign_output",b"btc_sign_output","cardano",b"cardano","change_password",b"change_password","check_backup",b"check_backup","check_sdcard",b"check_sdcard","create_backup",b"create_backup","device_info",b"device_info","device_language",b"device_language","device_name",b"device_name","electrum_encryption_key",b"electrum_encryption_key","eth",b"eth","fingerprint",b"fingerprint","insert_remove_sdcard",b"insert_remove_sdcard","list_backups",b"list_backups","perform_attestation",b"perform_attestation","reboot",b"reboot","request",b"request","reset",b"reset","restore_backup",b"restore_backup","restore_from_mnemonic",b"restore_from_mnemonic","set_mnemonic_passphrase_enabled",b"set_mnemonic_passphrase_enabled","set_password",b"set_password","show_mnemonic",b"show_mnemonic"]) -> builtins.bool: ...
161+
def ClearField(self, field_name: typing_extensions.Literal["bip85",b"bip85","btc",b"btc","btc_pub",b"btc_pub","btc_sign_init",b"btc_sign_init","btc_sign_input",b"btc_sign_input","btc_sign_output",b"btc_sign_output","cardano",b"cardano","change_password",b"change_password","check_backup",b"check_backup","check_sdcard",b"check_sdcard","create_backup",b"create_backup","device_info",b"device_info","device_language",b"device_language","device_name",b"device_name","electrum_encryption_key",b"electrum_encryption_key","eth",b"eth","fingerprint",b"fingerprint","insert_remove_sdcard",b"insert_remove_sdcard","list_backups",b"list_backups","perform_attestation",b"perform_attestation","reboot",b"reboot","request",b"request","reset",b"reset","restore_backup",b"restore_backup","restore_from_mnemonic",b"restore_from_mnemonic","set_mnemonic_passphrase_enabled",b"set_mnemonic_passphrase_enabled","set_password",b"set_password","show_mnemonic",b"show_mnemonic"]) -> None: ...
162+
def WhichOneof(self, oneof_group: typing_extensions.Literal["request",b"request"]) -> typing.Optional[typing_extensions.Literal["device_name","device_language","device_info","set_password","create_backup","show_mnemonic","btc_pub","btc_sign_init","btc_sign_input","btc_sign_output","insert_remove_sdcard","check_sdcard","set_mnemonic_passphrase_enabled","list_backups","restore_backup","perform_attestation","reboot","check_backup","eth","reset","restore_from_mnemonic","fingerprint","btc","electrum_encryption_key","cardano","bip85","change_password"]]: ...
159163
global___Request = Request
160164

161165
class Response(google.protobuf.message.Message):

0 commit comments

Comments
 (0)