def decrypt(word, key): ip = IP(word) helper.debug(["IP", ip]) key1 = Key_generator.generate_key(key, 1) helper.debug(["KE2", key1]) key2 = Key_generator.generate_key(key, 2) helper.debug(["KEY2", key2]) fk2 = fk_function.FK(ip, key2) helper.debug(["FK1", fk2]) sw = SW(fk2) helper.debug(["SW", sw]) fk1 = fk_function.FK(sw, key1) helper.debug(["FK1", fk1]) ip_1 = IP_1(fk1) helper.debug(["IP-1", ip_1]) return ip_1
def test_FK(): word = bitarray() for i in range(0, 64): word.append(randint(0, 1)) key = bitarray() for i in range(0, 48): key.append(randint(0, 1)) print "WORD", word print "KEY", key print "FK", Fk_function.FK(word, key)
def decryptage(plaintext, key): keys = key_generator.generate_keys(key, nbRound) word = key_generator.IP(plaintext) for round in range(0, nbRound): word = fk_function.FK(word, keys[nbRound - 1 - round]) leftBlock = word[0:32] rightBlock = word[32:] word = rightBlock + leftBlock word = key_generator.IP1(word) return word