Skip to content

Commit 80e74bc

Browse files
review comments
1 parent b14177e commit 80e74bc

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

client_encryption/encryption_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from Crypto.PublicKey import RSA
22
from Crypto.Hash import SHA1, SHA224, SHA256, SHA384, SHA512
3-
#from OpenSSL.crypto import load_certificate, FILETYPE_PEM, FILETYPE_ASN1, Error
43
from client_encryption.encryption_exception import CertificateError, PrivateKeyError, HashAlgorithmError
54
from cryptography import x509
65
from cryptography.hazmat.primitives.serialization import pkcs12
@@ -26,15 +25,15 @@ def load_encryption_certificate(certificate_path):
2625
raise CertificateError ("Unable to load certificate.")
2726

2827
try:
29-
type = __get_crypto_file_type(certificate)
28+
cert_type = __get_crypto_file_type(certificate)
3029

31-
if type == FileType.FILETYPE_PEM:
30+
if cert_type == FileType.FILETYPE_PEM:
3231
cert = x509.load_pem_x509_certificate(certificate)
3332
return cert, Encoding.PEM
34-
if type == FileType.FILETYPE_ASN1:
33+
if cert_type == FileType.FILETYPE_ASN1:
3534
cert = x509.load_der_x509_certificate(certificate)
3635
return cert, Encoding.DER
37-
if type == FileType.FILETYPE_INVALID:
36+
if cert_type == FileType.FILETYPE_INVALID:
3837
raise CertificateError("Wrong certificate format.")
3938
except ValueError:
4039
raise CertificateError ("Invalid certificate format.")

client_encryption/field_level_encryption_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, conf):
2727
if "encryptionCertificate" in json_config:
2828
x509_cert, cert_type = load_encryption_certificate(json_config["encryptionCertificate"])
2929
self._encryption_certificate = x509_cert
30-
#Fixed encoding is required, regardless of initial cerrtificate encoding to ensure correct calcualtion of fingerprint value
30+
# Fixed encoding is required, regardless of initial certificate encoding to ensure correct calculation of fingerprint value
3131
self._encryption_certificate_type = Encoding.DER
3232
self._encryption_key_fingerprint = \
3333
json_config.get("encryptionKeyFingerprint",self.__compute_fingerprint(x509_cert.public_key().public_bytes(Encoding.DER , PublicFormat.SubjectPublicKeyInfo)))

client_encryption/jwe_encryption_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, conf):
2828
if "encryptionCertificate" in json_config:
2929
x509_cert, cert_type = load_encryption_certificate(json_config["encryptionCertificate"])
3030
self._encryption_certificate = x509_cert
31-
#Fixed encoding is required, regardless of initial cerrtificate encoding to ensure correct calcualtion of fingerprint value
31+
# Fixed encoding is required, regardless of initial certificate encoding to ensure correct calculation of fingerprint value
3232
self._encryption_certificate_type = Encoding.DER
3333
self._encryption_key_fingerprint = \
3434
json_config.get("encryptionKeyFingerprint",self.__compute_fingerprint(x509_cert.public_key().public_bytes(Encoding.DER, PublicFormat.SubjectPublicKeyInfo)))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
'Topic :: Software Development :: Libraries :: Python Modules'
2222
],
2323
tests_require=['coverage'],
24-
install_requires=['pycryptodome>=3.8.1', 'setuptools>=69.1.0',"cryptography>=42.0.0" ]
24+
install_requires=['pycryptodome>=3.8.1', 'setuptools>=69.1.0', 'cryptography>=42.0.0' ]
2525
)

tests/test_api_encryption_jwe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import client_encryption.api_encryption as to_test
77

88

9-
class ApiEncryptionTest(unittest.TestCase):
9+
class ApiEncryptionJweTest(unittest.TestCase):
1010

1111
def setUp(self):
1212
self._json_config = json.loads(get_mastercard_config_for_test())

0 commit comments

Comments
 (0)