Пример #1
0
    def test_high8(self):
        """
		testo l'operazione high8
		"""
        a = 0xAABB
        processed = high8(a)
        expected = 0xAA
        self.assertEqual(expected, processed)
Пример #2
0
def S(index):
	'''
	ritorna SBox(index)
	'''
	i0 = low8(index)
	i1 = high8(index)
	firstEl = getValueFromSbox(0,i0)
	secondEl = getValueFromSbox(1,i1)
	return firstEl ^ secondEl
Пример #3
0
	def getWEPSeed(self):
		'''
		calcola il WEPSeed da ttak,tk e tsc. L'algoritmo è descritto a pagina 178 della rfc
		wepSeed è una tupla
		'''
		# prendo i valori di input separati in byte
		tk0,tk1,tk2,tk3,tk4,tk5,tk6,tk7,tk8,tk9,tk10,tk11,tk12,tk13,tk14,tk15 = self.attributeSplitter.getSplittedTK()
		tk_tuple = (tk0,tk1,tk2,tk3,tk4,tk5,tk6,tk7,tk8,tk9,tk10,tk11,tk12,tk13,tk14,tk15)
		tsc0,tsc1,tsc2,tsc3,tsc4,tsc5 = self.attributeSplitter.getSplittedTSC()
		# ttak è già una tupla e quindi non dev'essere splittato
		'''step_1'''
		ppk0 = self.ttak[0]
		ppk1 = self.ttak[1]
		ppk2 = self.ttak[2]
		ppk3 = self.ttak[3]
		ppk4 = self.ttak[4]
		ppk5 = (self.ttak[4] + mk16(tsc1,tsc0)) & 0xffff
		
		'''step_2'''
		ppk0 = (ppk0 + S(ppk5 ^ mk16(tk1,tk0))) & 0xffff
		ppk1 = (ppk1 + S(ppk0 ^ mk16(tk3,tk2))) & 0xffff
		ppk2 = (ppk2 + S(ppk1 ^ mk16(tk5,tk4))) & 0xffff
		ppk3 = (ppk3 + S(ppk2 ^ mk16(tk7,tk6))) & 0xffff
		ppk4 = (ppk4 + S(ppk3 ^ mk16(tk9,tk8))) & 0xffff
		ppk5 = (ppk5 + S(ppk4 ^ mk16(tk11,tk10))) & 0xffff
	
		ppk0 = (ppk0 + self.rotR1(ppk5 ^ mk16(tk13,tk12))) & 0xffff
		ppk1 = (ppk1 + self.rotR1(ppk0 ^ mk16(tk15,tk14))) & 0xffff
		ppk2 = (ppk2 + self.rotR1(ppk1)) & 0xffff
		ppk3 = (ppk3 + self.rotR1(ppk2)) & 0xffff
		ppk4 = (ppk4 + self.rotR1(ppk3)) & 0xffff
		ppk5 = (ppk5 + self.rotR1(ppk4)) & 0xffff
			
		ppk_tuple = (ppk0,ppk1,ppk2,ppk3,ppk4,ppk5)
		'''step3'''
		wepSeed=[]
		wepSeed.append(tsc1)
		wepSeed.append((tsc1 | 0x20) & 0x7F)
		wepSeed.append(tsc0)
		wepSeed.append(low8((ppk5 ^ mk16(tk1,tk0))>>1))
		
		#wepSeed_tuple = (wepSeed0,wepSeed1,wepSeed2,wepSeed3,wepSeed4,wepSeed5)
		for i in range(6):
			wepSeed.append(low8(ppk_tuple[i]))
			wepSeed.append(high8(ppk_tuple[i]))
	
		return tuple(wepSeed)