From a73b14bf130ad59bb83667d746759d840215c247 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Fri, 18 Oct 2019 15:40:57 +0800 Subject: [PATCH] Fix signature verificatio in pisa-cli --- apps/cli/pisa-cli.py | 4 ++-- test/unit/test_watcher.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/cli/pisa-cli.py b/apps/cli/pisa-cli.py index beb7298..cba8366 100644 --- a/apps/cli/pisa-cli.py +++ b/apps/cli/pisa-cli.py @@ -95,8 +95,8 @@ def add_appointment(args): logger.error("The response does not contain the signature of the appointment.") else: # verify that the returned signature is valid - signature = response_json['signature'] - pisa_public_key.verify(signature.encode("utf-8"), data, ec.ECDSA(hashes.SHA256())) + sig_bytes = unhexlify(response_json['signature'].encode('utf-8')) + pisa_public_key.verify(sig_bytes, appointment_data, ec.ECDSA(hashes.SHA256())) else: if 'error' not in response_json: logger.error("The server returned status code {}, but no error description." diff --git a/test/unit/test_watcher.py b/test/unit/test_watcher.py index 8a6d753..411c634 100644 --- a/test/unit/test_watcher.py +++ b/test/unit/test_watcher.py @@ -106,7 +106,7 @@ def test_add_appointment(run_bitcoind, watcher): # verify the signature try: - data = appointment.to_json().encode("utf-8") + data = appointment.to_json().encode('utf-8') public_key.verify(sig, data, ec.ECDSA(hashes.SHA256())) except InvalidSignature: assert False, "The appointment's signature is not correct"