catch assertion error and ecdsa error on signature verification

This commit is contained in:
Jude Nelson
2017-04-17 15:38:35 -04:00
parent d95e5d74ac
commit 23dfd947f7

View File

@@ -904,10 +904,15 @@ def verify_raw_data(raw_data, pubkey_hex, sigb64):
Return True on success.
Return False on error.
"""
sig_r, sig_s = decode_signature(sigb64)
pubk_i = decode_pubkey_hex(pubkey_hex)
res = fastecdsa.ecdsa.verify((sig_r, sig_s), raw_data, pubk_i, curve=fastecdsa.curve.secp256k1)
return res
try:
sig_r, sig_s = decode_signature(sigb64)
pubk_i = decode_pubkey_hex(pubkey_hex)
res = fastecdsa.ecdsa.verify((sig_r, sig_s), raw_data, pubk_i, curve=fastecdsa.curve.secp256k1)
return res
except (fastecdsa.ecdsa.EcdsaError, AssertionError):
# invalid signature
log.debug("Invalid signature {}".format(sigb64))
return False
def sign_digest( digest_hex, privkey_hex, curve=fastecdsa.curve.secp256k1, hashfunc=hashlib.sha256 ):