2929class ComplianceAgent :
3030 """Compliance agent class."""
3131
32- AGENTS_DIR = ' agents'
33- PUBLIC_KEYS_EVIDENCE_PATH = ' raw/auditree/agent_public_keys.json'
32+ AGENTS_DIR = " agents"
33+ PUBLIC_KEYS_EVIDENCE_PATH = " raw/auditree/agent_public_keys.json"
3434
3535 def __init__ (self , name = None , use_agent_dir = True ):
3636 """Construct and initialize the agent object."""
@@ -126,10 +126,9 @@ def hash_and_sign(self, data_bytes):
126126 signature = self .private_key .sign (
127127 hashed .digest (),
128128 padding .PSS (
129- mgf = padding .MGF1 (hashes .SHA256 ()),
130- salt_length = padding .PSS .MAX_LENGTH
129+ mgf = padding .MGF1 (hashes .SHA256 ()), salt_length = padding .PSS .MAX_LENGTH
131130 ),
132- Prehashed (hashes .SHA256 ())
131+ Prehashed (hashes .SHA256 ()),
133132 )
134133 return hashed .hexdigest (), base64 .b64encode (signature ).decode ()
135134
@@ -150,9 +149,9 @@ def verify(self, data_bytes, signature_b64):
150149 data_bytes ,
151150 padding .PSS (
152151 mgf = padding .MGF1 (hashes .SHA256 ()),
153- salt_length = padding .PSS .MAX_LENGTH
152+ salt_length = padding .PSS .MAX_LENGTH ,
154153 ),
155- hashes .SHA256 ()
154+ hashes .SHA256 (),
156155 )
157156 return True
158157 except InvalidSignature :
@@ -163,19 +162,19 @@ def from_config(cls):
163162 """Load agent from configuration."""
164163 config = get_config ()
165164 agent = cls (
166- name = config .get (' agent_name' ),
167- use_agent_dir = config .get (' use_agent_dir' , True )
165+ name = config .get (" agent_name" ),
166+ use_agent_dir = config .get (" use_agent_dir" , True ),
168167 )
169- private_key_path = config .get (' agent_private_key' )
170- public_key_path = config .get (' agent_public_key' )
168+ private_key_path = config .get (" agent_private_key" )
169+ public_key_path = config .get (" agent_public_key" )
171170 if private_key_path :
172- with open (private_key_path , 'rb' ) as key_file :
171+ with open (private_key_path , "rb" ) as key_file :
173172 agent .private_key = key_file .read ()
174173 agent .public_key = agent .private_key .public_key ().public_bytes (
175174 encoding = serialization .Encoding .PEM ,
176- format = serialization .PublicFormat .SubjectPublicKeyInfo
175+ format = serialization .PublicFormat .SubjectPublicKeyInfo ,
177176 )
178177 elif public_key_path :
179- with open (public_key_path , 'rb' ) as key_file :
178+ with open (public_key_path , "rb" ) as key_file :
180179 agent .public_key = key_file .read ()
181180 return agent
0 commit comments