diff --git a/client_encryption/encryption_utils.py b/client_encryption/encryption_utils.py index da0c0e8..0ea1ad8 100644 --- a/client_encryption/encryption_utils.py +++ b/client_encryption/encryption_utils.py @@ -1,6 +1,5 @@ from Crypto.PublicKey import RSA from Crypto.Hash import SHA1, SHA224, SHA256, SHA384, SHA512 -#from OpenSSL.crypto import load_certificate, FILETYPE_PEM, FILETYPE_ASN1, Error from client_encryption.encryption_exception import CertificateError, PrivateKeyError, HashAlgorithmError from cryptography import x509 from cryptography.hazmat.primitives.serialization import pkcs12 @@ -26,15 +25,15 @@ def load_encryption_certificate(certificate_path): raise CertificateError ("Unable to load certificate.") try: - type = __get_crypto_file_type(certificate) + cert_type = __get_crypto_file_type(certificate) - if type == FileType.FILETYPE_PEM: + if cert_type == FileType.FILETYPE_PEM: cert = x509.load_pem_x509_certificate(certificate) return cert, Encoding.PEM - if type == FileType.FILETYPE_ASN1: + if cert_type == FileType.FILETYPE_ASN1: cert = x509.load_der_x509_certificate(certificate) return cert, Encoding.DER - if type == FileType.FILETYPE_INVALID: + if cert_type == FileType.FILETYPE_INVALID: raise CertificateError("Wrong certificate format.") except ValueError: raise CertificateError ("Invalid certificate format.") diff --git a/client_encryption/field_level_encryption_config.py b/client_encryption/field_level_encryption_config.py index 240c14f..dad6cdc 100644 --- a/client_encryption/field_level_encryption_config.py +++ b/client_encryption/field_level_encryption_config.py @@ -27,7 +27,7 @@ def __init__(self, conf): if "encryptionCertificate" in json_config: x509_cert, cert_type = load_encryption_certificate(json_config["encryptionCertificate"]) self._encryption_certificate = x509_cert - #Fixed encoding is required, regardless of initial cerrtificate encoding to ensure correct calcualtion of fingerprint value + # Fixed encoding is required, regardless of initial certificate encoding to ensure correct calculation of fingerprint value self._encryption_certificate_type = Encoding.DER self._encryption_key_fingerprint = \ json_config.get("encryptionKeyFingerprint",self.__compute_fingerprint(x509_cert.public_key().public_bytes(Encoding.DER , PublicFormat.SubjectPublicKeyInfo))) diff --git a/client_encryption/jwe_encryption_config.py b/client_encryption/jwe_encryption_config.py index 6fc2b85..8e7a42c 100644 --- a/client_encryption/jwe_encryption_config.py +++ b/client_encryption/jwe_encryption_config.py @@ -28,7 +28,7 @@ def __init__(self, conf): if "encryptionCertificate" in json_config: x509_cert, cert_type = load_encryption_certificate(json_config["encryptionCertificate"]) self._encryption_certificate = x509_cert - #Fixed encoding is required, regardless of initial cerrtificate encoding to ensure correct calcualtion of fingerprint value + # Fixed encoding is required, regardless of initial certificate encoding to ensure correct calculation of fingerprint value self._encryption_certificate_type = Encoding.DER self._encryption_key_fingerprint = \ json_config.get("encryptionKeyFingerprint",self.__compute_fingerprint(x509_cert.public_key().public_bytes(Encoding.DER, PublicFormat.SubjectPublicKeyInfo))) diff --git a/setup.py b/setup.py index 31204e7..4cf6723 100644 --- a/setup.py +++ b/setup.py @@ -21,5 +21,5 @@ 'Topic :: Software Development :: Libraries :: Python Modules' ], tests_require=['coverage'], - install_requires=['pycryptodome>=3.8.1', 'setuptools>=69.1.0',"cryptography>=42.0.0" ] + install_requires=['pycryptodome>=3.8.1', 'setuptools>=69.1.0', 'cryptography>=42.0.0' ] ) diff --git a/tests/test_api_encryption_jwe.py b/tests/test_api_encryption_jwe.py index 9abf91c..1163d09 100644 --- a/tests/test_api_encryption_jwe.py +++ b/tests/test_api_encryption_jwe.py @@ -6,7 +6,7 @@ import client_encryption.api_encryption as to_test -class ApiEncryptionTest(unittest.TestCase): +class ApiEncryptionJweTest(unittest.TestCase): def setUp(self): self._json_config = json.loads(get_mastercard_config_for_test())