Skip to content

Commit 6c0ed9f

Browse files
committed
srp: remove 'pysrp' dependency
'pysrp' library includes 2 modules to implement SRP: * _ctsrp: Using OS libraries to implement SRP. * _pysrp: Pure Python implementation of SRP. The first option is always '_ctsrp'. If there is any problem loading the required libraries or looking for required methods inside, '_pysrp' is loaded. This last module, '_pysrp' has a bug in the generation of the verifier for certain combination of username and password (for example, user=apiservice, password=1257c) See cocagne/pysrp#55. This commit removes the dependency to 'pysrp' to avoid this bug and includes the required implementation to calculate a salt and the corresponding verifier to configure XBee Bluetooth password. Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
1 parent f95e0fa commit 6c0ed9f

File tree

9 files changed

+432
-24
lines changed

9 files changed

+432
-24
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,18 @@ v1.4.2 - XX/XX/202X
1818
* Send/receive explicit data in 802.15.4.
1919
(XBee 3 modules support this feature)
2020
* Support for local and remote firmware update of XBee XR 868 and 900.
21+
* Remove 'pysrp' dependency:
22+
23+
* The library includes support to generate salt and verifier required to
24+
configure '$S', '$V', '$W', '$X', and '$Y' XBee parameters to establish
25+
Bluetooth password.
2126
* Bug fixing:
2227

2328
* Fix order of nodes when creating a Zigbee source route (#278)
29+
* Salt/verifier generation using 'pysrp' was not working with certain
30+
passwords (see https://github.com/cocagne/pysrp/issues/55)
31+
Solved by removing 'pysrp' dependency and implementing the code to
32+
generate them.
2433

2534
v1.4.1 - 12/22/2021
2635
-------------------

digi/xbee/devices.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-2022, Digi International Inc.
1+
# Copyright 2017-2024, Digi International Inc.
22
#
33
# This Source Code Form is subject to the terms of the Mozilla Public
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -1780,12 +1780,10 @@ def update_bluetooth_password(self, new_password, apply=True, save=True):
17801780
if not isinstance(new_password, (str, bytes, bytearray)):
17811781
raise ValueError("Password must be a string, bytes, or bytearray")
17821782

1783-
import srp
1784-
1785-
# Generate the salt and verifier using the SRP library.
1786-
salt, verifier = srp.create_salted_verification_key(
1787-
self._BLE_API_USERNAME, new_password, hash_alg=srp.SHA256,
1788-
ng_type=srp.NG_1024, salt_len=4)
1783+
import digi.xbee.util.srp
1784+
salt, verifier = digi.xbee.util.srp.create_salted_verification_key(
1785+
self._BLE_API_USERNAME, new_password, hash_alg=digi.xbee.util.srp.HAType.SHA256,
1786+
ng_type=digi.xbee.util.srp.NgGroupParams.NG_1024, salt_len=4)
17891787

17901788
self.update_bluetooth_salt_verifier(salt, verifier, apply=apply, save=save)
17911789

0 commit comments

Comments
 (0)