1
1
import json
2
2
from Crypto .Hash import SHA256
3
- from client_encryption import encoding_utils
4
- from client_encryption .encryption_utils import load_encryption_certificate , load_decryption_key , validate_hash_algorithm
5
3
from cryptography .hazmat .primitives .serialization import PublicFormat , Encoding
6
4
5
+ from client_encryption import encoding_utils
6
+ from client_encryption .encryption_utils import load_encryption_certificate , load_decryption_key , validate_hash_algorithm
7
7
8
8
9
9
class FieldLevelEncryptionConfig (object ):
@@ -28,12 +28,14 @@ def __init__(self, conf):
28
28
x509_cert , cert_type = load_encryption_certificate (json_config ["encryptionCertificate" ])
29
29
self ._encryption_certificate = x509_cert
30
30
# Fixed encoding is required, regardless of initial certificate encoding to ensure correct calculation of fingerprint value
31
- self ._encryption_certificate_type = Encoding .DER
31
+ self ._encryption_certificate_type = Encoding .DER
32
32
self ._encryption_key_fingerprint = \
33
- json_config .get ("encryptionKeyFingerprint" ,self .__compute_fingerprint (x509_cert .public_key ().public_bytes (Encoding .DER , PublicFormat .SubjectPublicKeyInfo )))
33
+ json_config .get ("encryptionKeyFingerprint" , self .__compute_fingerprint (
34
+ x509_cert .public_key ().public_bytes (Encoding .DER , PublicFormat .SubjectPublicKeyInfo )))
34
35
self ._encryption_certificate_fingerprint = \
35
- json_config .get ("encryptionCertificateFingerprint" , self .__compute_fingerprint (x509_cert .public_bytes (Encoding .DER )))
36
-
36
+ json_config .get ("encryptionCertificateFingerprint" ,
37
+ self .__compute_fingerprint (x509_cert .public_bytes (Encoding .DER )))
38
+
37
39
else :
38
40
self ._encryption_certificate = None
39
41
self ._encryption_key_fingerprint = None
@@ -54,11 +56,11 @@ def __init__(self, conf):
54
56
self ._encrypted_key_field_name = json_config ["encryptedKeyFieldName" ]
55
57
self ._encrypted_value_field_name = json_config ["encryptedValueFieldName" ]
56
58
57
- self ._encryption_certificate_fingerprint_field_name = \
59
+ self ._encryption_certificate_fingerprint_field_name = \
58
60
json_config .get ("encryptionCertificateFingerprintFieldName" , None )
59
- self ._encryption_key_fingerprint_field_name = \
61
+ self ._encryption_key_fingerprint_field_name = \
60
62
json_config .get ("encryptionKeyFingerprintFieldName" , None )
61
- self ._oaep_padding_digest_algorithm_field_name = \
63
+ self ._oaep_padding_digest_algorithm_field_name = \
62
64
json_config .get ("oaepPaddingDigestAlgorithmFieldName" , None )
63
65
64
66
self ._use_http_headers = json_config .get ("useHttpHeaders" , False )
@@ -74,6 +76,7 @@ def encryption_certificate(self):
74
76
@property
75
77
def encryption_certificate_type (self ):
76
78
return self ._encryption_certificate_type
79
+
77
80
@property
78
81
def encryption_key_fingerprint (self ):
79
82
return self ._encryption_key_fingerprint
0 commit comments