Skip to content

Commit 03258b1

Browse files
committed
Throw error if recovery key is malformed
1 parent 481cb83 commit 03258b1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mautrix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.21.0b2"
1+
__version__ = "0.21.0b3"
22
__author__ = "Tulir Asokan <[email protected]>"
33
__all__ = [
44
"api",

mautrix/crypto/ssss/key.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def verify_passphrase(self, key_id: str, phrase: str) -> "Key":
6666
return self.verify_raw_key(key_id, self.passphrase.get_key(phrase))
6767

6868
def verify_recovery_key(self, key_id: str, recovery_key: str) -> "Key":
69-
return self.verify_raw_key(key_id, decode_base58_recovery_key(recovery_key))
69+
decoded_key = decode_base58_recovery_key(recovery_key)
70+
if not decoded_key:
71+
raise ValueError("Invalid recovery key syntax")
72+
return self.verify_raw_key(key_id, decoded_key)
7073

7174
def verify_raw_key(self, key_id: str, key: bytes) -> "Key":
7275
if self.mac.rstrip("=") != calculate_hash(key, self.iv):

0 commit comments

Comments
 (0)