Skip to content

Commit 29a9504

Browse files
committed
Format Python code with Black
- Applied Black code formatter to all Python source files - Reformatted 19 files to conform to PEP 8 style guidelines - Fixed formatting issues in src/device_fingerprinting/ and tests/ - All files now pass 'black --check' validation - Resolves CI lint failures related to code formatting This ensures consistent code style across the entire project.
1 parent d769c73 commit 29a9504

8 files changed

Lines changed: 283 additions & 305 deletions

File tree

src/device_fingerprinting/__init__.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,38 @@
3232
AdvancedDeviceFingerprinter,
3333
FingerprintMethod,
3434
FingerprintResult,
35-
bind_token_to_device
35+
bind_token_to_device,
3636
)
3737

3838
__all__ = [
39-
'generate_fingerprint',
40-
'generate_fingerprint_async',
41-
'create_device_binding',
42-
'verify_device_binding',
43-
'reset_device_id',
44-
'set_crypto_backend',
45-
'set_crypto_backend_sha256',
46-
'set_crypto_backend_sha3_512',
47-
'set_crypto_backend_hybrid_hash',
48-
'set_storage_backend',
49-
'set_security_check',
50-
'set_logger',
51-
'enable_post_quantum_crypto',
52-
'disable_post_quantum_crypto',
53-
'get_crypto_info',
54-
'get_available_crypto_backends',
55-
'enable_anti_replay_protection',
56-
'create_server_nonce',
57-
'verify_server_nonce',
58-
'is_post_quantum_enabled',
59-
'enable_admin_mode',
60-
'lock_configuration',
61-
'unlock_configuration',
62-
'DeviceFingerprintGenerator',
63-
'AdvancedDeviceFingerprinter',
64-
'FingerprintMethod',
65-
'FingerprintResult',
66-
'bind_token_to_device'
39+
"generate_fingerprint",
40+
"generate_fingerprint_async",
41+
"create_device_binding",
42+
"verify_device_binding",
43+
"reset_device_id",
44+
"set_crypto_backend",
45+
"set_crypto_backend_sha256",
46+
"set_crypto_backend_sha3_512",
47+
"set_crypto_backend_hybrid_hash",
48+
"set_storage_backend",
49+
"set_security_check",
50+
"set_logger",
51+
"enable_post_quantum_crypto",
52+
"disable_post_quantum_crypto",
53+
"get_crypto_info",
54+
"get_available_crypto_backends",
55+
"enable_anti_replay_protection",
56+
"create_server_nonce",
57+
"verify_server_nonce",
58+
"is_post_quantum_enabled",
59+
"enable_admin_mode",
60+
"lock_configuration",
61+
"unlock_configuration",
62+
"DeviceFingerprintGenerator",
63+
"AdvancedDeviceFingerprinter",
64+
"FingerprintMethod",
65+
"FingerprintResult",
66+
"bind_token_to_device",
6767
]
6868

6969
__version__ = "2.1.2-PQC-DUALUSB-0.15.2"

src/device_fingerprinting/cloud_features.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,6 @@ def _decrypt_data(self, encrypted_data: bytes) -> Dict[str, Any]:
100100
decrypted_data = self.encryptor.decrypt(encrypted_data)
101101
return json.loads(decrypted_data)
102102

103-
def compute_data_checksum(self, data: Dict[str, Any]) -> str:
104-
"""
105-
Compute SHA-256 checksum of data for integrity verification.
106-
107-
Returns base64-encoded checksum for cloud storage metadata.
108-
"""
109-
json_data = json.dumps(data, sort_keys=True).encode("utf-8")
110-
checksum = hashlib.sha256(json_data).digest()
111-
return base64.b64encode(checksum).decode("utf-8")
112-
113-
def verify_data_integrity(self, data: Dict[str, Any], expected_checksum: str) -> bool:
114-
"""Verify data integrity using stored checksum."""
115-
actual_checksum = self.compute_data_checksum(data)
116-
return actual_checksum == expected_checksum
117-
118103
def store(self, key: str, data: Dict[str, Any]) -> bool:
119104
"""Store encrypted data in the configured cloud storage."""
120105
if not self.available:

src/device_fingerprinting/crypto.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,6 @@ def verify(self, signature: str, data: bytes) -> bool:
136136
expected_sig = self.sign(data)
137137
return hmac.compare_digest(signature, expected_sig)
138138

139-
def generate_key_pair(self) -> Tuple[bytes, bytes]:
140-
"""
141-
Generate a cryptographic key pair for asymmetric operations.
142-
143-
Returns:
144-
Tuple of (public_key_material, private_key_material) as bytes.
145-
"""
146-
# For symmetric HMAC context, return derived keys for different purposes
147-
public_material = hashlib.sha256(self.key + b"public").digest()
148-
private_material = hashlib.sha256(self.key + b"private").digest()
149-
return (public_material, private_material)
150-
151139

152140
# Global instance management
153141
_crypto_manager: Optional[CryptoManager] = None

src/device_fingerprinting/device_fingerprinting.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108

109109
def _cleanup_resources() -> None:
110110
"""Cleanup resources on module shutdown"""
111+
global _executor
111112
if _executor:
112113
_executor.shutdown(wait=False)
113114

@@ -1400,8 +1401,8 @@ def _validate_command_safety(cmd) -> bool:
14001401
"systeminfo.exe",
14011402
"systeminfo",
14021403
"reg.exe",
1403-
"reg",
1404-
} # For registry queries only
1404+
"reg", # For registry queries only
1405+
}
14051406

14061407
if base_cmd not in allowed_commands:
14071408
return False

0 commit comments

Comments
 (0)