halturin / applepay

a Python library for decrypting Apple Pay payment tokens.
MIT License
59 stars 15 forks source link

remove ecdsa dependency #14

Open lstorme opened 10 months ago

lstorme commented 10 months ago

Hi, we can remove ecdsa dependency by using piece of code below instead ...

# Verify that the signature matches the signed data.
my_ec = ec.EllipticCurvePublicKey.from_encoded_point(ec.SECP256R1(), leaf_cert.public_key['public_key'].native)

try:
    # leaf_cert.hash_algo is sha256
    if leaf_cert.hash_algo == 'sha256':
        my_hash = hashes.SHA256()
    my_ec.verify(sig_octets, signed_attrs_ber, ec.ECDSA(my_hash))
except InvalidSignature:
    return False