Skip to content

Commit 9c0547b

Browse files
chore(Python): Fix unused ECDSA externs (#1124)
1 parent c939f3a commit 9c0547b

File tree

1 file changed

+6
-5
lines changed
  • AwsCryptographyPrimitives/runtimes/python/src/aws_cryptography_primitives/internaldafny/extern

1 file changed

+6
-5
lines changed

AwsCryptographyPrimitives/runtimes/python/src/aws_cryptography_primitives/internaldafny/extern/Signature.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
decode_dss_signature,
2222
encode_dss_signature
2323
)
24+
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
2425

2526
from collections import namedtuple
2627
import _dafny
@@ -48,7 +49,7 @@ def ExternKeyGen(signature_algorithm):
4849
return Wrappers.Result_Failure(maybe_signature_algorithm.error)
4950

5051
private_key = ec.generate_private_key(
51-
maybe_signature_algorithm.value.value.curve
52+
maybe_signature_algorithm.value.value.curve()
5253
)
5354

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

102103
message_digest_algorithm = maybe_signature_algorithm.value.value.message_digest_algorithm
103104
if message_digest_algorithm.is_SHA__256:
104-
sign_algo = ec.ECDSA(hashes.SHA256())
105+
sign_algo = ec.ECDSA(Prehashed(hashes.SHA256()))
105106
elif message_digest_algorithm.is_SHA__384:
106-
sign_algo = ec.ECDSA(hashes.SHA384())
107+
sign_algo = ec.ECDSA(Prehashed(hashes.SHA384()))
107108
else:
108109
return Wrappers.Result_Failure(Error_AwsCryptographicPrimitivesError(
109110
message=f"Requested Digest Algorithm is not supported. Requested {message_digest_algorithm}"
@@ -242,9 +243,9 @@ def _ecc_static_length_signature(key, algorithm, digest):
242243
:rtype: bytes
243244
"""
244245
if algorithm.message_digest_algorithm.is_SHA__256:
245-
sign_algo = ec.ECDSA(hashes.SHA256())
246+
sign_algo = ec.ECDSA(Prehashed(hashes.SHA256()))
246247
elif algorithm.message_digest_algorithm.is_SHA__384:
247-
sign_algo = ec.ECDSA(hashes.SHA384())
248+
sign_algo = ec.ECDSA(Prehashed(hashes.SHA384()))
248249
pre_hashed_algorithm = sign_algo
249250
signature = b""
250251
while len(signature) != algorithm.expected_signature_length:

0 commit comments

Comments
 (0)