- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
def calcCrc(d):
null = ''.join( ['\x00' for x in xrange(0,16)] )
init = ''.join( ['\x00' for x in xrange(0,16)] )
hsh = ''.join( ['\x00' for x in xrange(0,16)] )
inputd = array('c',''.join( ['\x00' for x in xrange(0,16)] ))
data = copy.copy(d)
if isinstance(d,list):
data = struct.pack('B'*len(data), *data)
l = len(data)
if l % 16 != 0:
data+="".join(["\x00" for x in xrange(0, 16-l % 16)]);
for i in range(0,len(data),16):
for j in xrange(16):
if i + j < len(data):
inputd[j] = chr(ord(hsh[j]) ^ ord(data[i+j]));
else:
inputd[j] = hsh[j];
obj = AES.new(null, AES.MODE_ECB, hsh)
hsh = obj.encrypt(inputd)
return hsh