Exemple #1
0
def dir_connect():
    '''
	Input: None
	Output: None
	Connects to the directory to get a encryption key by performing the DH key exchange
	'''

    global DIR_KEY
    print("#: Connecting to directory")
    sock = create_socket()
    sock.connect((HOST, DIR_PORT))

    #DH
    sock.send(calculate_shared(OWNSECRET).encode("utf-8"))
    SECRET = calculate_secret(sock.recv(1024), OWNSECRET)
    print(SECRET)

    DIR_KEY = AES.DF_keygen(SECRET)
    print(DIR_KEY)
    sock.close()