mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Moved return inside the try branch, following up on PR review
This commit is contained in:
@@ -48,7 +48,7 @@ def generate_dummy_appointment():
|
|||||||
# returning True or False accordingly.
|
# returning True or False accordingly.
|
||||||
# Will raise NotFoundError or IOError if the attempts to open and read the public key file fail.
|
# Will raise NotFoundError or IOError if the attempts to open and read the public key file fail.
|
||||||
# Will raise ValueError if it the public key file was present but it failed to be deserialized.
|
# Will raise ValueError if it the public key file was present but it failed to be deserialized.
|
||||||
def is_appointment_signature_valid(appointment, signature):
|
def is_appointment_signature_valid(appointment, signature) -> bool:
|
||||||
# Load the key from disk
|
# Load the key from disk
|
||||||
try:
|
try:
|
||||||
with open(PISA_PUBLIC_KEY, "r") as key_file:
|
with open(PISA_PUBLIC_KEY, "r") as key_file:
|
||||||
@@ -61,11 +61,10 @@ def is_appointment_signature_valid(appointment, signature):
|
|||||||
sig_bytes = unhexlify(signature.encode('utf-8'))
|
sig_bytes = unhexlify(signature.encode('utf-8'))
|
||||||
data = json.dumps(appointment, sort_keys=True, separators=(',', ':')).encode("utf-8")
|
data = json.dumps(appointment, sort_keys=True, separators=(',', ':')).encode("utf-8")
|
||||||
pisa_public_key.verify(sig_bytes, data, ec.ECDSA(hashes.SHA256()))
|
pisa_public_key.verify(sig_bytes, data, ec.ECDSA(hashes.SHA256()))
|
||||||
|
return True
|
||||||
except InvalidSignature:
|
except InvalidSignature:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
# Makes sure that the folder APPOINTMENTS_FOLDER_NAME exists, then saves the appointment and signature in it.
|
# Makes sure that the folder APPOINTMENTS_FOLDER_NAME exists, then saves the appointment and signature in it.
|
||||||
def save_signed_appointment(appointment, signature):
|
def save_signed_appointment(appointment, signature):
|
||||||
|
|||||||
Reference in New Issue
Block a user