Skip to content

Commit

Permalink
add EC verify support
Browse files Browse the repository at this point in the history
  • Loading branch information
schorschii committed Dec 23, 2023
1 parent ceebbbd commit 4ddcd64
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions endesive/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,7 @@
from certvalidator import CertificateValidator, ValidationContext

from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric import padding, ec
from cryptography import x509 as cx509
from cryptography.hazmat.backends import default_backend

Expand Down Expand Up @@ -67,7 67,17 @@ def verify(self, datas, datau):
sigalgo = signed_data["signer_infos"][0]["signature_algorithm"]
# sigalgo.debug()
sigalgoname = sigalgo.signature_algo
if sigalgoname == "rsassa_pss":
if isinstance(public_key, ec.EllipticCurvePublicKey):
try:
public_key.verify(
signature,
signedData,
ec.ECDSA(getattr(hashes, algo.upper())()),
)
signatureok = True
except Exception as e:
signatureok = False
elif sigalgoname == "rsassa_pss":
parameters = sigalgo["parameters"]
# parameters.debug()
# print(parameters.native)
Expand Down

0 comments on commit 4ddcd64

Please sign in to comment.