def TestCaseSetup(tc): print("TestCaseSetup(): Start") tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr.GetMeta() rnmdpr.GetRingEntries([rnmdpr.pi]) tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() tnmdpr.GetRingEntries([tnmdpr.pi]) if tc.module.args.cipher_suite == "CCM": brq = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CCM"]) elif tc.module.args.cipher_suite == "CBC": brq = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CBC"]) else: brq = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["BRQ_DECRYPT_GCM"]) brq.GetMeta() tlscbid = "TlsCb%04d" % id tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy | \ tcp_tls_proxy.tls_debug_dol_sesq_stop if hasattr(tc.module.args, 'reassemble'): if tc.module.args.reassemble == True: print("Enabling reassembly support") tlscb.debug_dol = tlscb.debug_dol | tcp_tls_proxy.tls_debug_dol_dec_reasm_path tlscb.other_fid = 0xffff tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.SetObjValPd() if tc.module.args.key_size == 16: tcp_tls_proxy.tls_aes128_decrypt_setup(tc, tlscb) elif tc.module.args.key_size == 32: tcp_tls_proxy.tls_aes256_decrypt_setup(tc, tlscb) tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr) tc.pvtdata.Add(tnmdpr) tc.pvtdata.Add(brq) return
def Configure(self): for proxycb in self.proxy_service_list: logger.info("configuring proxycb object for session %s" % (proxycb.session.GID())) if proxycb.session.iflow.label == 'TCP-PROXY-E2E': tls_sess_profile_template = \ getattr(proxycb.session.spec, 'tls_sess_profile', None) if tls_sess_profile_template: proxycb.tls_sess_profile = tls_sess_profile_template.Get( Store) TlsProxySessProfileHelper.main(proxycb.tls_sess_profile) if proxycb.session.iflow.label == 'TCP-PROXY' or proxycb.session.iflow.label == 'ESP-PROXY' or proxycb.session.iflow.label == 'IPSEC-PROXY' or \ proxycb.session.iflow.label == 'RAW-REDIR' or proxycb.session.iflow.label == 'RAW-REDIR-FLOW-MISS' or \ proxycb.session.iflow.label == 'RAW-REDIR-SPAN' or proxycb.session.iflow.label == 'RAW-REDIR-KNOWN-APPID' or \ proxycb.session.iflow.label == 'RAW-REDIR-SPAN-FLOW-MISS' or \ proxycb.session.iflow.label == 'PROXY-REDIR' or proxycb.session.iflow.label == 'PROXY-REDIR-E2E' or \ proxycb.session.iflow.label == 'PROXY-REDIR-SPAN-E2E' or \ proxycb.session.iflow.label == 'TCP-PROXY-E2E' or proxycb.session.iflow.label == 'NVME-PROXY': lst = [] lst.append(proxycb) halapi.ConfigureProxyCbService(lst) halapi.GetQidProxycbGetFlowInfo(lst) if proxycb.session.iflow.label == 'TCP-PROXY' or proxycb.session.iflow.label == 'NVME-PROXY': TcpCbHelper.main(proxycb.qid, proxycb.other_qid, proxycb.session, True) TcpCbHelper.main(proxycb.other_qid, proxycb.qid, proxycb.session, False) #if proxycb.session.iflow.label == 'ESP-PROXY' or proxycb.session.iflow.label == 'IPSEC-PROXY': # IpsecCbHelper.main(proxycb.qid) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids(tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.debug_dol = 0 # set tcb state to SYN_SENT(2) tcb.state = tcp_proxy.tcp_state_SYN_SENT tcb.SetObjValPd() TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() # 2. Clone objects that are needed for verification arq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["CPU0000_ARQ"]) arq.Configure() sesqid = "TCPCB%04d_SESQ" % id sesq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[sesqid]) tlscbid = "TlsCb%04d" % id tlscb_cur = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb_cur.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb_cur.SetObjValPd() tlscb = copy.deepcopy(tlscb_cur) tcpcb = copy.deepcopy(tcb) tc.pvtdata.Add(tlscb) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(sesq) tc.pvtdata.Add(arq) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = tcp_proxy.tcp_state_ESTABLISHED tcb.debug_dol_tx |= tcp_proxy.tcp_tx_debug_dol_dont_tx tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr.GetMeta() tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() arq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["CPU0000_ARQ"]) sesqid = "TCPCB%04d_SESQ" % id sesq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[sesqid]) sesq.GetMeta() tlscbid = "TlsCb%04d" % id tlscb_cur = tc.infra_data.ConfigStore.objects.db[tlscbid] #tlscb_cur.debug_dol = (tcp_tls_proxy.tls_debug_dol_leave_in_arq | tcp_tls_proxy.tls_debug_dol_bypass_proxy | tcp_tls_proxy.tls_debug_dol_bypass_barco | tcp_tls_proxy.tls_debug_dol_fake_handshake_msg) tlscb_cur.debug_dol = (tcp_tls_proxy.tls_debug_dol_bypass_proxy | tcp_tls_proxy.tls_debug_dol_bypass_barco | tcp_tls_proxy.tls_debug_dol_arm_loop_ctlr_pkts) tlscb_cur.other_fid = 0xffff tlscb_cur.is_decrypt_flow = 1 tlscb_cur.serq_pi = 0 tlscb_cur.serq_ci = 0 tlscb_cur.SetObjValPd() tlscb = copy.deepcopy(tlscb_cur) tlscb.GetObjValPd() tcpcb = copy.deepcopy(tcb) tcpcb.GetObjValPd() tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr) tc.pvtdata.Add(tnmdpr) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(sesq) tc.pvtdata.Add(arq) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.l7_proxy_type = 0 tcb.debug_dol = 0 tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() tnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) #tnmdpr_big.GetMeta() brq = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_GCM"]) #brq.GetMeta() tlscbid = "TlsCb%04d" % id tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy | \ tcp_tls_proxy.tls_debug_dol_sesq_stop tlscb.other_fid = 0xffff tlscb.l7_proxy_type = tcp_proxy.l7_proxy_type_REDIR tlscb.serq_pi = 0 tlscb.serq_ci = 0 if tc.module.args.key_size == 16: tcp_tls_proxy.tls_aes128_decrypt_setup(tc, tlscb) elif tc.module.args.key_size == 32: tcp_tls_proxy.tls_aes256_decrypt_setup(tc, tlscb) tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr_big) tc.pvtdata.Add(tnmdpr_big) tc.pvtdata.Add(brq) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.l7_proxy_type = tcp_proxy.l7_proxy_type_SPAN tcb.debug_dol |= tcp_proxy.tcp_debug_dol_pkt_to_serq tcb.debug_dol |= tcp_proxy.tcp_debug_dol_pkt_to_l7q if hasattr(tc.module.args, 'atomic_stats') and tc.module.args.atomic_stats: print("Testing atomic stats") tcb.debug_dol |= tcp_proxy.tcp_debug_dol_test_atomic_stats tcb.bytes_rcvd = 0 # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() tlscbid = "TlsCb%04d" % id tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb.debug_dol = 0 tlscb.is_decrypt_flow = False tlscb.other_fid = 0xffff tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() rnmdpr_big.GetRingEntries([rnmdpr_big.pi]) serqid = "TLSCB%04d_SERQ" % id serq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[serqid]) serq.GetMeta() tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tcpcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid]) tcpcb.GetObjValPd() tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr_big) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(serq) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() rnmdpr_big.GetRingEntries([rnmdpr_big.pi]) tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() sesqid = "TCPCB%04d_SESQ" % id sesq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[sesqid]) sesq.GetMeta() tlscbid = "TlsCb%04d" % id tlscb_cur = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb_cur.debug_dol = (tcp_tls_proxy.tls_debug_dol_bypass_proxy | tcp_tls_proxy.tls_debug_dol_sesq_stop | tcp_tls_proxy.tls_debug_dol_bypass_barco) tlscb_cur.other_fid = 0xffff tlscb_cur.is_decrypt_flow = False tlscb_cur.serq_pi = 0 tlscb_cur.serq_ci = 0 tlscb_cur.SetObjValPd() tlscb = copy.deepcopy(tlscb_cur) tlscb.GetObjValPd() tcpcb = copy.deepcopy(tcb) tcpcb.GetObjValPd() tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr_big) tc.pvtdata.Add(tnmdpr) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(sesq) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.debug_dol |= tcp_proxy.tcp_debug_dol_leave_in_arq # set tcb state to SYN_SENT(2) tcb.state = tcp_proxy.tcp_state_SYN_SENT tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() rnmdpr_big.GetRingEntries([rnmdpr_big.pi]) tnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr_big.GetMeta() actl = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["CPU0000_TCP_ACTL"]) actl.GetMeta() sesqid = "TCPCB%04d_SESQ" % id sesq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[sesqid]) tlscbid = "TlsCb%04d" % id tlscb_cur = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb_cur.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb_cur.SetObjValPd() tlscb = copy.deepcopy(tlscb_cur) tcpcb = copy.deepcopy(tcb) tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr_big) tc.pvtdata.Add(tnmdpr_big) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(sesq) tc.pvtdata.Add(actl) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tc.SetRetryEnabled(True) tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids( tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id logger.info("Configuring %s" % tcbid) # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.SetObjValPd() TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() # 2. Configure TLS CB in HBM before packet injection tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] tlscb.debug_dol = 0 tlscb2.debug_dol = 0 if tc.pvtdata.bypass_barco: print("Bypassing Barco") tlscb.is_decrypt_flow = False tlscb2.is_decrypt_flow = False tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco if tc.pvtdata.same_flow: print("Same flow") tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_proxy tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_proxy tlscb.other_fid = 0xffff tlscb2.other_fid = 0xffff else: print("Other flow") tlscb.other_fid = other_fid tlscb2.other_fid = id tlscb.SetObjValPd() tlscb2.SetObjValPd() # 3. Clone objects that are needed for verification tcpcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid]) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid2]) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) other_tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) other_tlscb.GetObjValPd() tc.pvtdata.Add(other_tlscb) rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() tc.pvtdata.Add(rnmdpr_big) return
def TestCaseSetup(tc): global rnmdpr_big global proxyrcbid global proxyccbid global proxyrcb global proxyccb global redir_span tc.SetRetryEnabled(True) redir_span = getattr(tc.module.args, 'redir_span', False) tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.l7_proxy_type = 0 tcb.debug_dol = 0 if redir_span: tcb.debug_dol_tx |= tcp_proxy.tcp_tx_debug_dol_dont_tx tcb.SetObjValPd() _proxyrcb_id = id ProxyrCbHelper.main(_proxyrcb_id) proxyrcbid = "ProxyrCb%04d" % _proxyrcb_id # 1. Configure PROXYRCB in HBM before packet injection proxyrcb = tc.infra_data.ConfigStore.objects.db[proxyrcbid] # let HAL fill in defaults for chain_rxq_base, etc. proxyrcb.my_txq_base = 0 proxyrcb.chain_rxq_base = 0 proxyrcb.redir_span = redir_span proxyrcb.proxyrcb_flags = app_redir_shared.app_redir_dol_pipeline_loopbk_en # fill in flow key proxyrcb.FlowKeyBuild(tc.config.flow) print("vrf %d flow sport %d dport %d" % (proxyrcb.vrf, proxyrcb.sport, proxyrcb.dport)) proxyrcb.SetObjValPd() tlscbid = "TlsCb%04d" % id tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy tlscb.other_fid = 0xffff tlscb.l7_proxy_type = tcp_proxy.l7_proxy_type_REDIR if redir_span: tlscb.l7_proxy_type = tcp_proxy.l7_proxy_type_SPAN tlscb.serq_pi = 0 tlscb.serq_ci = 0 if tc.module.args.key_size == 16: tcp_tls_proxy.tls_aes128_decrypt_setup(tc, tlscb) elif tc.module.args.key_size == 32: tcp_tls_proxy.tls_aes256_decrypt_setup(tc, tlscb) _proxyccb_id = id ProxycCbHelper.main(_proxyccb_id) proxyccbid = "ProxycCb%04d" % _proxyccb_id # 1. Configure PROXYCCB in HBM before packet injection proxyccb = tc.infra_data.ConfigStore.objects.db[proxyccbid] # let HAL fill in defaults for my_txq_base, etc. proxyccb.redir_span = redir_span proxyccb.my_txq_base = 0 proxyccb.chain_txq_base = 0 proxyccb.chain_txq_lif = app_redir_shared.service_lif_tcp_proxy proxyccb.chain_txq_qtype = 0 proxyccb.chain_txq_qid = id proxyccb.chain_txq_ring = 0 proxyccb.proxyccb_flags = app_redir_shared.app_redir_chain_desc_add_aol_offset | \ app_redir_shared.app_redir_dol_skip_chain_doorbell proxyccb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() proxyrcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[proxyrcbid]) proxyrcb.GetObjValPd() proxyccb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[proxyccbid]) proxyccb.GetObjValPd() return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) skip_config = False if hasattr(tc.module.args, 'skip_config') and tc.module.args.skip_config: print("skipping config") skip_config = True #id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) id1, id2 = ProxyCbServiceHelper.GetSessionQids(tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] if not skip_config: tcp_proxy.init_tcb_inorder(tc, tcb) # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() else: tc.pvtdata.flow1_bytes_rxed = 0 tc.pvtdata.flow1_bytes_txed = 0 tc.pvtdata.flow2_bytes_rxed = 0 tc.pvtdata.flow2_bytes_txed = 0 TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] if not skip_config: tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() tc.pvtdata.tcb1 = tcb tc.pvtdata.tcb2 = tcb2 tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) #tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] #tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] tlscb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) tlscb.serq_pi = 0 tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.serq_ci = 0 tlscb2.serq_pi = 0 tlscb2.serq_pi = 0 tlscb2.serq_ci = 0 tlscb2.serq_ci = 0 tlscb.debug_dol = 0 tlscb2.debug_dol = 0 #tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy | \ # tcp_tls_proxy.tls_debug_dol_sesq_stop #tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_proxy #If 'use_random_iv' is set, set the corresponding debug-dol flag to indicate #datapath to pick a random value from DRBG as IV. if hasattr(tc.module.args, 'use_random_iv') and tc.module.args.use_random_iv == 1: tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_explicit_iv_use_random tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_explicit_iv_use_random if tc.pvtdata.same_flow: tlscb.other_fid = 0xffff tlscb2.other_fid = 0xffff else: tlscb.other_fid = other_fid tlscb2.other_fid = id if not skip_config: if tc.module.args.key_size == 16: tcp_tls_proxy.tls_aes128_encrypt_setup(tc, tlscb) tcp_tls_proxy.tls_aes128_encrypt_setup(tc, tlscb2) elif tc.module.args.key_size == 32: tcp_tls_proxy.tls_aes256_encrypt_setup(tc, tlscb) tcp_tls_proxy.tls_aes256_encrypt_setup(tc, tlscb2) tlscb.SetObjValPd() tlscb2.SetObjValPd() if skip_config: return # 2. Clone objects that are needed for verification rnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr.GetMeta() rnmdpr.GetRingEntries([rnmdpr.pi]) tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() tnmdpr.GetRingEntries([tnmdpr.pi]) print("snapshot1: tnmdpr_alloc %d enc_requests %d" % (tlscb.tnmdpr_alloc, tlscb.enc_requests)) print("snapshot1: rnmdpr_free %d enc_completions %d" % (tlscb.rnmdpr_free, tlscb.enc_completions)) if tc.module.args.cipher_suite == "CCM": brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CCM"]) elif tc.module.args.cipher_suite == "CBC": brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_CBC"]) else: brq = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_GCM"]) tcpcb = copy.deepcopy(tcb) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tcb2) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) tlscb2.GetObjValPd() tc.pvtdata.Add(tlscb2) tc.pvtdata.Add(rnmdpr) tc.pvtdata.Add(tnmdpr) return
def TestCaseSetup(tc): tc.pvtdata = ObjectDatabase() tcp_proxy.SetupProxyArgs(tc) id = ProxyCbServiceHelper.GetFlowInfo(tc.config.flow._FlowObject__session) TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] tcp_proxy.init_tcb_inorder(tc, tcb) tcb.debug_dol_tx |= tcp_proxy.tcp_tx_debug_dol_dont_send_ack # set tcb state to ESTABLISHED(1) tcb.state = 1 tcb.SetObjValPd() # 2. Clone objects that are needed for verification rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() rnmdpr_big.GetRingEntries([rnmdpr_big.pi]) tnmdpr = copy.deepcopy(tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr.GetMeta() brq = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["BRQ_ENCRYPT_GCM"]) brq.GetMeta() brq.GetRingEntries([brq.pi]) tcpcb = copy.deepcopy(tcb) tcpcb.GetObjValPd() tlscbid = "TlsCb%04d" % id tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) # Key Setup key_type = types_pb2.CRYPTO_KEY_TYPE_AES128 key_size = 16 key = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' tlscb.crypto_key.Update(key_type, key_size, key) # TLS-CB Setup tlscb.command = 0x30000000 tlscb.crypto_key_idx = tlscb.crypto_key.keyindex tlscb.salt = 0x12345678 tlscb.explicit_iv = 0xfedcba9876543210 tlscb.enc_requests = 0 tlscb.enc_completions = 0 tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.debug_dol = tcp_tls_proxy.tls_debug_dol_bypass_barco | \ tcp_tls_proxy.tls_debug_dol_bypass_proxy | \ tcp_tls_proxy.tls_debug_dol_sesq_stop tlscb.other_fid = 0xffff tlscb.is_decrypt_flow = False tlscb.SetObjValPd() tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) tc.pvtdata.Add(rnmdpr_big) tc.pvtdata.Add(tnmdpr) tc.pvtdata.Add(tcpcb) tc.pvtdata.Add(brq) return
def TestCaseSetup(tc): skip_config = False if hasattr(tc.module.args, 'skip_config') and tc.module.args.skip_config: logger.info("skipping config") skip_config = True tc.pvtdata = ObjectDatabase() if hasattr(tc.module.args, 'rnmdr_big_pi'): tc.pvtdata.rnmdr_big_pi = tc.module.args.rnmdr_big_pi else: tc.pvtdata.rnmdr_big_pi = None if hasattr(tc.module.args, 'rnmdr_big_ci'): tc.pvtdata.rnmdr_big_ci = tc.module.args.rnmdr_big_ci else: tc.pvtdata.rnmdr_big_ci = None tcp_proxy.SetupProxyArgs(tc) id1, id2 = ProxyCbServiceHelper.GetSessionQids( tc.config.flow._FlowObject__session) if tc.config.flow.IsIflow(): id = id1 other_fid = id2 else: id = id2 other_fid = id1 TcpCbHelper.main(id) tcbid = "TcpCb%04d" % id logger.info("Configuring %s" % tcbid) # 1. Configure TCB in HBM before packet injection tcb = tc.infra_data.ConfigStore.objects.db[tcbid] if not skip_config: tcp_proxy.init_tcb_inorder(tc, tcb) if tc.pvtdata.serq_full: tcb.serq_pi = 5 tcb.serq_ci = 6 else: if tc.pvtdata.serq_pi: tcb.serq_pi = tc.pvtdata.serq_pi if tc.pvtdata.serq_ci: tcb.serq_ci = tc.pvtdata.serq_ci tcb.SetObjValPd() else: tc.pvtdata.flow1_bytes_rxed = 0 tc.pvtdata.flow1_bytes_txed = 0 tc.pvtdata.flow2_bytes_rxed = 0 tc.pvtdata.flow2_bytes_txed = 0 TcpCbHelper.main(other_fid) tcbid2 = "TcpCb%04d" % (other_fid) logger.info("Configuring %s" % tcbid2) tcb2 = tc.infra_data.ConfigStore.objects.db[tcbid2] if not skip_config: tcp_proxy.init_tcb_inorder2(tc, tcb2) tcb2.SetObjValPd() tc.pvtdata.tcb1 = tcb tc.pvtdata.tcb2 = tcb2 # 2. Configure TLS CB in HBM before packet injection tlscbid = "TlsCb%04d" % id tlscbid2 = "TlsCb%04d" % (other_fid) tlscb = tc.infra_data.ConfigStore.objects.db[tlscbid] tlscb2 = tc.infra_data.ConfigStore.objects.db[tlscbid2] if tc.pvtdata.serq_full: tlscb.serq_pi = 5 tlscb.serq_ci = 6 tlscb2.serq_pi = 5 tlscb2.serq_ci = 6 else: tlscb.serq_pi = 0 tlscb.serq_pi = 0 tlscb.serq_ci = 0 tlscb.serq_ci = 0 tlscb2.serq_pi = 0 tlscb2.serq_pi = 0 tlscb2.serq_ci = 0 tlscb2.serq_ci = 0 tlscb.debug_dol = 0 tlscb2.debug_dol = 0 tlscb.other_fid = other_fid tlscb2.other_fid = id if tc.pvtdata.bypass_barco: logger.info("Bypassing Barco") tlscb.is_decrypt_flow = False tlscb2.is_decrypt_flow = False tlscb.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco tlscb2.debug_dol |= tcp_tls_proxy.tls_debug_dol_bypass_barco if not skip_config: tlscb.SetObjValPd() tlscb2.SetObjValPd() if skip_config: return # 3. Clone objects that are needed for verification tcpcb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid]) tcpcb.GetObjValPd() tc.pvtdata.Add(tcpcb) tcpcb2 = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tcbid2]) tcpcb2.GetObjValPd() tc.pvtdata.Add(tcpcb2) tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid]) tlscb.GetObjValPd() tc.pvtdata.Add(tlscb) other_tlscb = copy.deepcopy(tc.infra_data.ConfigStore.objects.db[tlscbid2]) other_tlscb.GetObjValPd() tc.pvtdata.Add(other_tlscb) rnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["RNMDPR_BIG"]) rnmdpr_big.GetMeta() if tc.pvtdata.sem_full and tc.pvtdata.sem_full == 'nmdr': rnmdpr_big.pi = 0 rnmdpr_big.ci = 2 # ring size of 2, so can hold 1 entry rnmdpr_big.SetMeta() else: setMeta = False if tc.pvtdata.rnmdr_big_pi is not None: rnmdpr_big.pi = tc.pvtdata.rnmdr_big_pi setMeta = True if tc.pvtdata.rnmdr_big_ci is not None: rnmdpr_big.ci = tc.pvtdata.rnmdr_big_ci setMeta = True if setMeta: rnmdpr_big.SetMeta() tc.pvtdata.Add(rnmdpr_big) if tc.pvtdata.test_ooo_queue: ooo_rx_wring = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["OOO_RX"]) ooo_rx_wring.GetMeta() tc.pvtdata.Add(ooo_rx_wring) tnmdpr_big = copy.deepcopy( tc.infra_data.ConfigStore.objects.db["TNMDPR_BIG"]) tnmdpr_big.GetMeta() tc.pvtdata.Add(tnmdpr_big) return