def calc_rendezvous_point_data(rendezvous_point):
    # print rendezvous_point #testing,currently not being passed, no item error
    rp_ip = consensus.getRouter(rendezvous_point)["ip"]
    rp_or_port = consensus.getRouter(rendezvous_point)["orport"]
    rp_id = consensus.getRouter(rendezvous_point)["identity"]
    router_descriptor = consensus.getRouterDescriptor((consensus.getRouter(rendezvous_point))["identityhash"])
    onion_key = consensus.getRouterOnionKey(router_descriptor)
    return rp_id, rp_ip, rp_or_port, onion_key
def remoteKeyX (on):
    r = consensus.getRouter(on)
    x = numunpack(os.urandom(DH_SEC_LEN))
    X = pow(DH_G,x,DH_P)
    X = numpack(X,DH_LEN)
    router_descriptor = consensus.getRouterDescriptor(r['identityhash'])
    router_onion_key = consensus.getRouterOnionKey(router_descriptor)
    remoteKey = RSA.importKey(router_onion_key)
    payload = hybridEncrypt(remoteKey, X)
    return (x, payload)
Example #3
0
def buildCreatePayload(nm):
#get router rsa onion key
    r = consensus.getRouter(nm)
    rd = consensus.getRouterDescriptor(r['identity'])
    rdk = consensus.getRouterOnionKey(rd)
    rsa = RSA.importKey(rdk)

#generate diffie helman secret
    x = numunpack(os.urandom(DH_SEC_LEN))
#DH pub key X
    X = pow(DH_G, x, DH_P)
#encrypt X to remote
    createpayload = hybridEncrypt(rsa,numpack(X, DH_LEN))
#pack packet
    #pkt = struct.pack(">HB", circId, cellTypeToId("CREATE")) + createpayload + "\x00" * (509-len(createpayload))
    return (x, createpayload)