base64.b64decode: always set validate=True
Notably verifymessage and decrypt(message) were silently ignoring trailing garbage or inserted non-base64 characters present in signatures/ciphertext. (both the CLI commands and in the GUI) I think it is much cleaner and preferable to treat such signatures/ciphertext as invalid. In fact I find it surprising that base64.b64decode(validate=False) is the default. Perhaps we should create a helper function for it that set validate=True and use that.
This commit is contained in:
@@ -473,7 +473,7 @@ def ecies_decrypt_message(
|
||||
*,
|
||||
magic: bytes = b'BIE1',
|
||||
) -> bytes:
|
||||
encrypted = base64.b64decode(encrypted) # type: bytes
|
||||
encrypted = base64.b64decode(encrypted, validate=True) # type: bytes
|
||||
if len(encrypted) < 85:
|
||||
raise Exception('invalid ciphertext: length')
|
||||
magic_found = encrypted[:4]
|
||||
|
||||
Reference in New Issue
Block a user