From 75b28e9bce29c62595eaab4ac3a8458c0ffa3883 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 28 Oct 2019 11:34:00 +0700 Subject: [PATCH] Moved return inside the try branch, following up on PR review --- apps/cli/pisa-cli.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/cli/pisa-cli.py b/apps/cli/pisa-cli.py index 4d22ee7..60ea067 100644 --- a/apps/cli/pisa-cli.py +++ b/apps/cli/pisa-cli.py @@ -48,7 +48,7 @@ def generate_dummy_appointment(): # returning True or False accordingly. # 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. -def is_appointment_signature_valid(appointment, signature): +def is_appointment_signature_valid(appointment, signature) -> bool: # Load the key from disk try: 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')) data = json.dumps(appointment, sort_keys=True, separators=(',', ':')).encode("utf-8") pisa_public_key.verify(sig_bytes, data, ec.ECDSA(hashes.SHA256())) + return True except InvalidSignature: return False - return True - # Makes sure that the folder APPOINTMENTS_FOLDER_NAME exists, then saves the appointment and signature in it. def save_signed_appointment(appointment, signature):