Esempio n. 1
0
def pack_handshake(message, crypto_dict, verbose = False):
	
	if verbose:
		print "\n"

	# Compile message
	client_message = encodeMessage(message) + ";" + crypto_dict["rsa_user_public_key_hash"]

	return util.pack_handshake_general(client_message, crypto_dict, "client", verbose)
Esempio n. 2
0
def pack_handshake(message, crypto_dict, verbose = False):
   	
	if verbose:
		print "\n"
		
	# Update AES session key
	try:
		crypto_dict["aes_session_keys"][crypto_dict["rsa_user_public_key_hash"]] = str(rand.rand_byte(32))[:32]
		crypto_dict["aes_session_ids"][crypto_dict["rsa_user_public_key_hash"]] = str(rand.rand_byte(32))[:32]
	except Exception as inst:
		return [False, "Error [ " + str(inspect.stack()[0][3]) + " -> rand ]: " + str(inst)]

	util.debug(verbose, "aes_session_key", crypto_dict["aes_session_keys"][crypto_dict["rsa_user_public_key_hash"]])
	util.debug(verbose, "aes_session_id", crypto_dict["aes_session_ids"][crypto_dict["rsa_user_public_key_hash"]])

	# Compile message
	server_message = message + ";" + crypto_dict["aes_session_keys"][crypto_dict["rsa_user_public_key_hash"]] + ";" + crypto_dict["aes_session_ids"][crypto_dict["rsa_user_public_key_hash"]]+ ";"

	for key in sorted(crypto_dict["candidates"].keys()):
		server_message += str(key) + ":" + str(crypto_dict["candidates"][key]) + "-"

	return util.pack_handshake_general(server_message, crypto_dict, "server", verbose)