예제 #1
0
 def _create_one_hop_path(self, egress_if):
     ts = int(SCIONTime.get_time())
     info = InfoOpaqueField.from_values(ts, self.addr.isd_as[0], hops=2)
     hf1 = HopOpaqueField.from_values(self.HOF_EXP_TIME, 0, egress_if)
     hf1.set_mac(self.of_gen_key, ts, None)
     # Return a path where second HF is empty.
     return SCIONPath.from_values(info, [hf1, HopOpaqueField()])
예제 #2
0
파일: base.py 프로젝트: jpcsmith/scion-old
 def _create_pcbm(self, in_if, out_if, ts, prev_hof, xover=False):
     hof = HopOpaqueField.from_values(self.HOF_EXP_TIME,
                                      in_if,
                                      out_if,
                                      xover=xover)
     hof.set_mac(self.of_gen_key, ts, prev_hof)
     in_info = self._mk_if_info(in_if)
     out_info = self._mk_if_info(out_if)
     return PCBMarking.from_values(in_info["remote_ia"],
                                   in_info["remote_if"], in_info["mtu"],
                                   out_info["remote_ia"],
                                   out_info["remote_if"], hof,
                                   self._get_if_rev_token(in_if))
예제 #3
0
파일: base.py 프로젝트: fjacky/scion
 def _create_pcbm(self, in_if, out_if, ts, prev_hof, xover=False):
     in_info = self._mk_if_info(in_if)
     if in_info["remote_ia"].int() and not in_info["remote_if"]:
         return None
     out_info = self._mk_if_info(out_if)
     if out_info["remote_ia"].int() and not out_info["remote_if"]:
         return None
     hof = HopOpaqueField.from_values(
         self.HOF_EXP_TIME, in_if, out_if, xover=xover)
     hof.set_mac(self.of_gen_key, ts, prev_hof)
     return PCBMarking.from_values(
         in_info["remote_ia"], in_info["remote_if"], in_info["mtu"],
         out_info["remote_ia"], out_info["remote_if"], hof)
예제 #4
0
 def _create_ad_marking(self):
     """
     Create an AD Marking with the given ingress and egress interfaces.
     """
     hof = HopOpaqueField.from_values(1, 111, 222)
     rev_token = HashChain(Random.new().read(32)).next_element()
     pcbm = PCBMarking.from_values(1, 10, hof)
     peer_markings = []
     signing_key = read_file(get_sig_key_file_path(1, 10))
     signing_key = base64.b64decode(signing_key)
     data_to_sign = (b'11' + pcbm.hof.pack())
     signature = sign(data_to_sign, signing_key)
     return ADMarking.from_values(pcbm, peer_markings, rev_token, signature)
예제 #5
0
 def handle_one_hop_path(self, hdr, spkt, from_local_as):
     if len(spkt.path) != InfoOpaqueField.LEN + 2 * HopOpaqueField.LEN:
         logging.error("OneHopPathExt: incorrect path length.")
         return [(RouterFlag.ERROR,)]
     if not from_local_as:  # Remote packet, create the 2nd Hop Field
         info = spkt.path.get_iof()
         hf1 = spkt.path.get_hof_ver(ingress=True)
         exp_time = OneHopPathExt.HOF_EXP_TIME
         hf2 = HopOpaqueField.from_values(exp_time, self.interface.if_id, 0)
         hf2.set_mac(self.of_gen_key, info.timestamp, hf1)
         # FIXME(PSz): quite brutal for now:
         spkt.path = SCIONPath.from_values(info, [hf1, hf2])
         spkt.path.inc_hof_idx()
     return []
예제 #6
0
파일: base.py 프로젝트: xabarass/scion
 def _create_pcbm(self, in_if, out_if, ts, prev_hof, xover=False):
     in_info = self._mk_if_info(in_if)
     if in_info["remote_ia"].int() and not in_info["remote_if"]:
         return None
     out_info = self._mk_if_info(out_if)
     if out_info["remote_ia"].int() and not out_info["remote_if"]:
         return None
     exp_time = self.hof_exp_time(ts)
     if exp_time <= 0:
         logging.error("Invalid hop field expiration time value: %s",
                       exp_time)
         return None
     hof = HopOpaqueField.from_values(exp_time, in_if, out_if, xover=xover)
     hof.set_mac(self.of_gen_key, ts, prev_hof)
     return PCBMarking.from_values(in_info["remote_ia"],
                                   in_info["remote_if"], in_info["mtu"],
                                   out_info["remote_ia"],
                                   out_info["remote_if"], hof)