def __init__(self, iKICD):
""" Constructor for KIC/KID object.
iKICD - coding of KIC or KID (see ETSI 102.225, 5.1.2 and 5.1.3, u8)"""
iKICD %= 0x100
self.iKICD = iKICD
self.keyval = None
if iKICD & KICD.ALGO == KICD.ALGO_DES: # DES/3DES key
b43 = iKICD & 0x0C # bits 4 and 3 of KIC/KID
self.keysize = 8 + 2*(b43 % 12) # mapping to DES, 3DES 2k, 3DES 3k
self.cipModule = b43 % 12 and DES3 or DES
self.MODE = b43 == KICD.DES_ECB and DES.MODE_EBC or DES.MODE_CBC
self.BS = 8
self.zAES = False
elif iKICD & 0x0F == KICD.ALGO_AES: # AES CBC / CMAC
self.zAES = True
self.cipModule = AES
self.MODE = AES.MODE_CBC
self.BS = 16
self.TlenB = 8 # length of CMAC, you may manually change to 4
self.irrPoly = 0x87 # for CMAC
else:
raise ValueError("Only DES/AES implemented for KIC/KID")
评论列表
文章目录