External Exam Download Resources Web Applications Games Recycle Bin

Feistel, DES and AES

Feistel_DES_and_AES.py

#The magic of a Feistel cipher is the Exclusive OR (XOR) function.
#When you XOR something with the same thing again, it undoes it:

pin = {1,2,3}
block_key = {3,4,5}
encrypted_pin = pin.symmetric_difference(block_key) #XOR
print(encrypted_pin) #{1, 2, 4, 5}
decrypted_pin = encrypted_pin.symmetric_difference(block_key) #XOR
print(decrypted_pin) #{1, 2, 3}  

#By using XOR, an encryption function can still be one-way
#(e.g. hash function). The Feistel network can still decrypt.

########## DATA ENCRYPYTION STANDARD:
#On the exam, a Feistel network can be described as a "very
#similar or identical set of iterative structural processes
#to encrypt or decrypt the same block of data".

# Feistel network (DES):
#1) get a block of data
#2) split the block into two sides
#3) use one side to permute the other side
#4) swap the sides
#5) repeat


# HOW IS FEISTEL (DES) DIFFERENT TO AES?
# --------------------------------------
# AES is a 'substitution-permutation' network which is different
# in structure. The AES structure uses a lookup table of bytes...
# it still repeats this through multiple rounds, but uses a jumbling
# of bytes. Both AES and DES can be reversed. AES could be considered
# a "random"-permutation (you need the key).