mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 14:44:21 +01:00
Fix signature verificatio in pisa-cli
This commit is contained in:
@@ -95,8 +95,8 @@ def add_appointment(args):
|
|||||||
logger.error("The response does not contain the signature of the appointment.")
|
logger.error("The response does not contain the signature of the appointment.")
|
||||||
else:
|
else:
|
||||||
# verify that the returned signature is valid
|
# verify that the returned signature is valid
|
||||||
signature = response_json['signature']
|
sig_bytes = unhexlify(response_json['signature'].encode('utf-8'))
|
||||||
pisa_public_key.verify(signature.encode("utf-8"), data, ec.ECDSA(hashes.SHA256()))
|
pisa_public_key.verify(sig_bytes, appointment_data, ec.ECDSA(hashes.SHA256()))
|
||||||
else:
|
else:
|
||||||
if 'error' not in response_json:
|
if 'error' not in response_json:
|
||||||
logger.error("The server returned status code {}, but no error description."
|
logger.error("The server returned status code {}, but no error description."
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ def test_add_appointment(run_bitcoind, watcher):
|
|||||||
|
|
||||||
# verify the signature
|
# verify the signature
|
||||||
try:
|
try:
|
||||||
data = appointment.to_json().encode("utf-8")
|
data = appointment.to_json().encode('utf-8')
|
||||||
public_key.verify(sig, data, ec.ECDSA(hashes.SHA256()))
|
public_key.verify(sig, data, ec.ECDSA(hashes.SHA256()))
|
||||||
except InvalidSignature:
|
except InvalidSignature:
|
||||||
assert False, "The appointment's signature is not correct"
|
assert False, "The appointment's signature is not correct"
|
||||||
|
|||||||
Reference in New Issue
Block a user