Ejemplo n.º 1
0
class KeyExchange(object):
    def __init__(self):
        print("New KeyExchange, initializing Diffie-Hellman")
        self.dh = DiffieHellman(group=14)

    def exchange_key(self, other_public_key):
        print("received a public key, calculating shared secret...")
        self.dh.make_shared_secret_and_key(other_public_key)
        print("setting new shared secret key.")
        global daemon
        daemon._pyroHmacKey = self.dh.key
        return self.dh.public_key
Ejemplo n.º 2
0
 def __init__(self):
     print("New KeyExchange, initializing Diffie-Hellman")
     self.dh = DiffieHellman(group=14)
Ejemplo n.º 3
0
import Pyro4
import Pyro4.errors
from diffiehellman import DiffieHellman


dh = DiffieHellman(group=14)

with Pyro4.locateNS() as ns:
    uri = ns.lookup("example.dh.secretstuff")
    print(uri)

p = Pyro4.Proxy(uri)
try:
    p.process("hey")
    raise RuntimeError("this should not be reached")
except Pyro4.errors.PyroError as x:
    print("Error occured (expected!):", x)

with Pyro4.Proxy("PYRONAME:example.dh.keyexchange") as keyex:
    print("exchange public keys...")
    other_key = keyex.exchange_key(dh.public_key)
    print("got server public key, creating shared secret key...")
    dh.make_shared_secret_and_key(other_key)
    print("setting key on proxy.")
    p._pyroHmacKey = dh.key

print("Calling proxy again...")
result = p.process("hey")
print("Got reply:", result)