Added exception when trying to remember an invalid public key
This commit is contained in:
parent
d68cfaa8f7
commit
ad67c553d7
@ -50,6 +50,9 @@ class Identity:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remember(packet_hash, destination_hash, public_key, app_data = None):
|
def remember(packet_hash, destination_hash, public_key, app_data = None):
|
||||||
|
if len(public_key) != Identity.KEYSIZE//8:
|
||||||
|
raise TypeError("Can't remember "+RNS.prettyhexrep(destination_hash)+", the public key size of "+str(len(public_key))+" is not valid.", RNS.LOG_ERROR)
|
||||||
|
else:
|
||||||
Identity.known_destinations[destination_hash] = [time.time(), packet_hash, public_key, app_data]
|
Identity.known_destinations[destination_hash] = [time.time(), packet_hash, public_key, app_data]
|
||||||
|
|
||||||
|
|
||||||
@ -339,7 +342,7 @@ class Identity:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with open(path, "wb") as key_file:
|
with open(path, "wb") as key_file:
|
||||||
key_file.write(self.prv_bytes)
|
key_file.write(self.get_public_key())
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user