mirror of
https://github.com/aljazceru/python-teos.git
synced 2026-02-04 22:24:23 +01:00
Modifies behaviour towards a failed EncryptedBlob decrpytion
The decryption for the `EncryptedBlob` using AES-GCM-128 (the only cipher available atm) raises an `InvalidTag` exception. This was not properly captured by the watcher making it crash. This behavior was already discovered during the `EncryptedBlob` unit testing and left to be fixed in the `Watcher` unit testing. However, making the EncryptedBlob raise such an exception may not be a good practice, since other ciphers may run into different exceptions. Therefore, the `EncryptedBlob` has been modified to return None upon facing a decryption issue, the `BlockProcessor` will detect that and return a None justice_txm and justice_txid. Upon receiving a None `justice_txid` the `Watcher` will delete the appointment without notifiying the `Responder`.
This commit is contained in:
@@ -19,13 +19,10 @@ def test_decrypt():
|
||||
encrypted_data = urandom(64).hex()
|
||||
encrypted_blob = EncryptedBlob(encrypted_data)
|
||||
|
||||
# Trying to decrypt random data (in AES_GCM-128) should result in an InvalidTag exception
|
||||
try:
|
||||
encrypted_blob.decrypt(key)
|
||||
assert False, "Able to decrypt random data with random key"
|
||||
|
||||
except InvalidTag:
|
||||
assert True
|
||||
# Trying to decrypt random data (in AES_GCM-128) should result in an InvalidTag exception. Our decrypt function
|
||||
# returns None
|
||||
hex_tx = encrypted_blob.decrypt(key)
|
||||
assert hex_tx is None
|
||||
|
||||
# Valid data should run with no InvalidTag and verify
|
||||
data = "6097cdf52309b1b2124efeed36bd34f46dc1c25ad23ac86f28380f746254f777"
|
||||
|
||||
Reference in New Issue
Block a user