MCPcopy
hub / github.com/trailofbits/algo / derive_pubkey_from_same_key

Function derive_pubkey_from_same_key

tests/unit/test_wireguard_key_generation.py:279–311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

277 try:
278
279 def derive_pubkey_from_same_key():
280 class MockModule:
281 def __init__(self, params):
282 self.params = params
283 self.result = {}
284
285 def fail_json(self, **kwargs):
286 raise Exception(f"Module failed: {kwargs}")
287
288 def exit_json(self, **kwargs):
289 self.result = kwargs
290
291 import x25519_pubkey
292 from x25519_pubkey import run_module
293
294 original_AnsibleModule = x25519_pubkey.AnsibleModule
295
296 try:
297 mock_module = MockModule(
298 {
299 "private_key_b64": b64_key, # SAME key each time
300 "private_key_path": None,
301 "public_key_path": None,
302 }
303 )
304
305 x25519_pubkey.AnsibleModule = lambda **kwargs: mock_module
306 run_module()
307
308 return mock_module.result["public_key"]
309
310 finally:
311 x25519_pubkey.AnsibleModule = original_AnsibleModule
312
313 # Derive public key multiple times from same private key
314 pubkey1 = derive_pubkey_from_same_key()

Callers 1

test_key_consistencyFunction · 0.85

Calls 2

run_moduleFunction · 0.90
MockModuleClass · 0.85

Tested by

no test coverage detected