Skip to content

Commit

Permalink
chore(Python): Fix unused ECDSA externs (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmcdonald3 authored Dec 13, 2024
1 parent c939f3a commit 9c0547b
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
decode_dss_signature,
encode_dss_signature
)
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed

from collections import namedtuple
import _dafny
Expand Down Expand Up @@ -48,7 +49,7 @@ def ExternKeyGen(signature_algorithm):
return Wrappers.Result_Failure(maybe_signature_algorithm.error)

private_key = ec.generate_private_key(
maybe_signature_algorithm.value.value.curve
maybe_signature_algorithm.value.value.curve()
)

private_key_pem_bytes = private_key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())
Expand Down Expand Up @@ -101,9 +102,9 @@ def Verify(signature_algorithm, verification_key, message, signature):

message_digest_algorithm = maybe_signature_algorithm.value.value.message_digest_algorithm
if message_digest_algorithm.is_SHA__256:
sign_algo = ec.ECDSA(hashes.SHA256())
sign_algo = ec.ECDSA(Prehashed(hashes.SHA256()))
elif message_digest_algorithm.is_SHA__384:
sign_algo = ec.ECDSA(hashes.SHA384())
sign_algo = ec.ECDSA(Prehashed(hashes.SHA384()))
else:
return Wrappers.Result_Failure(Error_AwsCryptographicPrimitivesError(
message=f"Requested Digest Algorithm is not supported. Requested {message_digest_algorithm}"
Expand Down Expand Up @@ -242,9 +243,9 @@ def _ecc_static_length_signature(key, algorithm, digest):
:rtype: bytes
"""
if algorithm.message_digest_algorithm.is_SHA__256:
sign_algo = ec.ECDSA(hashes.SHA256())
sign_algo = ec.ECDSA(Prehashed(hashes.SHA256()))
elif algorithm.message_digest_algorithm.is_SHA__384:
sign_algo = ec.ECDSA(hashes.SHA384())
sign_algo = ec.ECDSA(Prehashed(hashes.SHA384()))
pre_hashed_algorithm = sign_algo
signature = b""
while len(signature) != algorithm.expected_signature_length:
Expand Down

0 comments on commit 9c0547b

Please sign in to comment.