def get_hops_hash(self, hex=False): # pragma: no cover """ Returns the hash over all triples (ISD_AS, IG_IF, EG_IF) included in the path segment. """ data = [] for asm in self.iter_asms(): pcbm = asm.pcbm(0) data.append(asm.isd_as().pack()) data.append(struct.pack("!QQ", pcbm.p.inIF, pcbm.p.outIF)) data = b"".join(data) if hex: return crypto_hash(data).hex() return crypto_hash(data)
def _zk_write_rev(self, data): hash_ = crypto_hash(data).hex() try: self.rev_cache.store("%s-%s" % (hash_, SCIONTime.get_time()), data) except ZkNoConnection: logging.warning("Unable to store revocation(s) in shared path: " "no connection to ZK")
def _share_object(self, pld, is_trc): """ Share path segments (via ZK) with other path servers. """ pld_packed = pld.pack() pld_hash = crypto_hash(pld_packed).hex() try: if is_trc: self.trc_cache.store( "%s-%s" % (pld_hash, SCIONTime.get_time()), pld_packed) else: self.cc_cache.store("%s-%s" % (pld_hash, SCIONTime.get_time()), pld_packed) except ZkNoConnection: logging.warning("Unable to store %s in shared path: " "no connection to ZK" % "TRC" if is_trc else "CC") return logging.debug("%s stored in ZK: %s" % ("TRC" if is_trc else "CC", pld_hash))