Skip to content

Commit b3dfe43

Browse files
fixing security issues
1 parent 01cb223 commit b3dfe43

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

client_encryption/encryption_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from Crypto.Hash import SHA1, SHA224, SHA256, SHA384, SHA512
33
from OpenSSL.crypto import load_certificate, load_pkcs12, dump_privatekey, FILETYPE_PEM, FILETYPE_ASN1, Error
44
from client_encryption.encryption_exception import CertificateError, PrivateKeyError, HashAlgorithmError
5-
5+
from cryptography.hazmat.primitives.serialization import pkcs12
66

77
_SUPPORTED_HASH = {"SHA1": SHA1, "SHA224": SHA224, "SHA256": SHA256, "SHA384": SHA384, "SHA512": SHA512}
88

@@ -43,8 +43,10 @@ def load_decryption_key(key_file_path, decryption_key_password=None):
4343
def __load_pkcs12_private_key(pkcs12_key, password):
4444
"""Load a private key in ASN1 format out of a PKCS#12 container."""
4545

46-
pkcs12 = load_pkcs12(pkcs12_key, password.encode("utf-8")).get_privatekey()
47-
return dump_privatekey(FILETYPE_ASN1, pkcs12)
46+
#pkcs12 = load_pkcs12(pkcs12_key, password.encode("utf-8")).get_privatekey()
47+
with open(key_file_path, "rb") as f:
48+
private_key = pkcs12.load_pkcs12(pkcs12_key, password)
49+
return dump_privatekey(FILETYPE_ASN1, private_key)
4850

4951

5052
def __get_crypto_file_type(file_content):

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pycryptodome==3.8.1
2-
pyOpenSSL>=22.1.0,<=23.2.0
1+
pycryptodome==3.19.1
2+
pyOpenSSL>=23.3.0
33
setuptools>=39.0.1
44
coverage>=4.5.3
55
cryptography>=39.0.0

0 commit comments

Comments
 (0)