(
local_private_key_str: str, remote_public_key_str: str, group: int = 14
)
| 250 | |
| 251 | @staticmethod |
| 252 | def generate_shared_key_static( |
| 253 | local_private_key_str: str, remote_public_key_str: str, group: int = 14 |
| 254 | ) -> str: |
| 255 | local_private_key = int(local_private_key_str, base=16) |
| 256 | remote_public_key = int(remote_public_key_str, base=16) |
| 257 | prime = primes[group]["prime"] |
| 258 | if not DiffieHellman.is_valid_public_key_static(remote_public_key, prime): |
| 259 | raise ValueError("Invalid public key") |
| 260 | shared_key = pow(remote_public_key, local_private_key, prime) |
| 261 | return sha256(str(shared_key).encode()).hexdigest() |
| 262 | |
| 263 | |
| 264 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected