def build_hmac_sha1(pkt, pw = '\0' * 20, ip4l = [], ip6l = []):
if not pkt.haslayer(CARP):
return None
p = pkt[CARP]
h = hmac.new(pw, digestmod = hashlib.sha1)
# XXX: this is a dirty hack. it needs to pack version and type into a single 8bit field
h.update('\x21')
# XXX: mac addy if different from special link layer. comes before vhid
h.update(struct.pack('!B', p.vhid))
sl = []
for i in ip4l:
# sort ips from smallest to largest
sl.append(inet_aton(i))
sl.sort()
for i in sl:
h.update(i)
# XXX: do ip6l sorting
return h.digest()
评论列表
文章目录