def AS_to_Client(ip_Client, r): Key_c = (r.get('Key_Client')).decode() Key_c = tostr.key_tostr(Key_c) QW.Key_client = Key_c Key_ctgs = (r.get('Key_ctgs')).decode() # 理论上从数据库获取 Key_ctgs = tostr.key_tostr(Key_ctgs) print("Key_ctgs = ", Key_ctgs) ip_TGS = (r.get('ip_TGS')).decode() # 从数据库获取TGS的IP地址 ip_TGS = tostr.ip_tostr(ip_TGS) ts2 = time.time() ts2 = tostr.ts_tostr(ts2) lifetime2 = 666 lifetime2 = tostr.lifetime_tostr(lifetime2) ip_Client = tostr.ip_tostr(ip_Client) ticket_tgs = get_ticket(Key_ctgs, ip_Client, ip_TGS, ts2, lifetime2, r) message = Key_ctgs + ip_TGS + ts2 + lifetime2 + ticket_tgs QW.message2_Plaintext = message message = des_en.test(message, Key_c) QW.message2_Ciphertext = message return message
def TGS_to_Client(ip_Client, ip_Server, Key_ctgs): Key_server = 'bcdefgh' Key_server = tostr.ip_tostr(Key_server) Key_cv = get_key() Key_server = tostr.ip_tostr(Key_server) ip_Server = tostr.ip_tostr(ip_Server) ip_Client = tostr.ip_tostr(ip_Client) AD_Client = ip_Client ticket_Server, ts4 = get_ticket(ip_Client, AD_Client, ip_Server, Key_cv, Key_server) message = Key_cv + ip_Server + ts4 + ticket_Server message = des_en.test(message, Key_ctgs) print("message = ", message) return message
def TGS_to_Client(ip_Client, ip_Server, Key_ctgs): Key_server = 'bcdefgh' QW.Key_server = Key_server Key_server = tostr.ip_tostr(Key_server) Key_cv = get_key() Key_server = tostr.ip_tostr(Key_server) ip_Server = tostr.ip_tostr(ip_Server) ip_Client = tostr.ip_tostr(ip_Client) AD_Client = ip_Client ticket_Server,ts4 = get_ticket(ip_Client,AD_Client,ip_Server,Key_cv,Key_server) message = Key_cv + ip_Server + ts4 + ticket_Server QW.message4_Plaintext = message message = des_en.test(message, Key_ctgs) QW.message4_Ciphertext = message print("message = ", message) return message
def Client_to_AS(): ip_Client = tostr.get_host_ip() ip_Client = tostr.ip_tostr(ip_Client) print("ip = ", ip_Client) ip_TGS = "192.168.43.203" ip_TGS = tostr.ip_tostr(ip_TGS) print("ip_TGS = ", ip_TGS) ts1 = time.time() ts1 = tostr.ts_tostr(ts1) print("ts1 = ", ts1) #str_ClienttoAS = tostr.IntegrationMessage.ClientAS(ip_Client, ip_TGS, ts1) str_ClienttoAS = ip_Client + ip_TGS + ts1 print("str_Client = ", str_ClienttoAS) return str_ClienttoAS
def Client_to_TGS(ticket_TGS, Key_ctgs): ip_Server = '192.168.43.204' # 如何获取SERVER端的IP呢************************************************ ip_Server = tostr.ip_tostr(ip_Server) Authenticator_c, ts = get_Authencator(Key_ctgs) message = ip_Server + ticket_TGS + Authenticator_c return message, str(len(ticket_TGS))
def get_Authencator(Key_ctgs): ip_Client = tostr.get_host_ip() ip_Client = tostr.ip_tostr(ip_Client) AD_c = ip_Client ts3 = time.time() ts3 = tostr.ts_tostr(ts3) authencator = ip_Client + AD_c + ts3 authencator = des_en.test(authencator, Key_ctgs) return authencator, ts3