def PC_2(CiDi): ''' Permutation Choice 2. Drop 8 bits and permute the remaining 48 input bits. 56-bit -> 48-bit ''' return (Permute(CiDi, PC_2_table)) # ok
def PC_1(key): ''' Permutation Choice 1 Discard the parity check bits, which cuts the 64-bit key into 56-bit key and then permute. 64-bit -> 56-bit ''' return (Permute(key, PC_1_table)) # ok
def IP(block): ''' Initial permutation ''' return Permute(block, IP_table) # ok
def Permutation(HalfBlock): ''' Rearrange the 32 outputs from the S-boxes according to a fixed permutation ''' return Permute(HalfBlock, Permutation_table) # ok
def Expansion(HalfBlock): ''' Expand 32-bit half-block to 48 bits using the expansion permutation. 32-bit -> 48-bit ''' return Permute(HalfBlock, Expansion_table) # ok
def FP(block): ''' Final permutation ''' return Permute(block, FP_table) # ok