Exemplo n.º 1
0
 def __init__(self, hdr=None, memkey=False, memiv=False):
     if not hdr:
         self.hdr = IkaPacketHeader()
         self.hdr.enctype = C.IKAP_ENC_AES256
         self.hdr.epoch = int(time.time())
         self.calculateChecksum()
         self.setDst(self.dst)
         self.setSrc(self.src)
         self.setArg(self.arg)
         self.setEncType(self.enctype)
     self.epoch = self.hdr.epoch
     if memkey:
         self.setMemkey(memkey)
         self.setMemIV(pwgen.generateIV128(memkey))
     if memiv:
         self.setMemIV(memiv)
Exemplo n.º 2
0
    d["raw"] = data
    return d


def calcIPCheckSum(data):
    s = 0
    for i in range(0, len(data)):
        c = s + data[i]
        s = (c & 0xFFFF) + (c >> 16)
    return ~s & 0xFFFF


# DEFKEY=(0xdeadbeef, 0xcafebabe, 0xdefec8ed, 0xbaadf00d)
# DEFKEY="deadbeefcafebabedefec8edbaadf00dca8b49745393d660b7b55dbb29523971"
DEFKEY = "\xde\xad\xbe\xef\xca\xfe\xba\xbe\xde\xfe\xc8\xed\xba\xad\xf0\x0d\xca\x8b\x49\x74\x53\x93\xd6\x60\xb7\xb5\x5d\xbb\x29\x52\x39\x71"
DEFIV = pwgen.generateIV128(DEFKEY)

CONST = {}
CONST_MSG = {}
CONST_ACT = {}
CONST_CTX = {}
CONST_ENC = {}
for co in dir(C):
    if type(eval("C." + co)).__name__ == "int":
        if co.startswith("IKAP_MSG"):
            CONST_MSG[eval("C." + co)] = co
        elif co.startswith("IKAP_ACT"):
            CONST_ACT[eval("C." + co)] = co
        elif co.startswith("IKAP_CTX"):
            CONST_CTX[eval("C." + co)] = co
        elif co.startswith("IKAP_ENC"):