Skip to content

Instantly share code, notes, and snippets.

@LukeHuckman
Created June 23, 2021 22:45
Show Gist options
  • Save LukeHuckman/fa61ede9d1144e46e2c7c34dcd033e3c to your computer and use it in GitHub Desktop.
Save LukeHuckman/fa61ede9d1144e46e2c7c34dcd033e3c to your computer and use it in GitHub Desktop.
Process steps for Feistel Cipher and S-DES
Feistel Cipher
Step 1: Split the bits in half, L0 and R0
Step 2: R0 XOR K1 = X1
Step 3: L0 XOR X1 = X2 = R1
Step 4: R0 = L1
Step 5: Repeat for n rounds
S-DES
Key Generation:
Step 1: Permute P10
Step 2: Divide P10 into 2 5-bit values L0 and R0
Step 3: Perform an LS-1 cirular left shift on both (L1 and R1)
Step 4: Recombine L1 and R1 into a 10-bit value
Step 5: Permute P8 using the 10-bit value in step 4, resulting in K1
Step 6: Perform an LS-2 cirular left shift on L1 and R1 (L2 and R2)
Step 7: Recombine L2 and R2 into a 10-bit value
Step 8: Permute P8 using the 10-bit value in step 7, resulting in K2
Encryption:
Step 1: Perform initial permutation (IP) and split the output into 2 equal parts, L0 and R0
(Mapping F: Begin)
Step 2: Perform expansion/permutation on R0 (EP)
Step 3: EP XOR K1
Step 4: Split the result into 2 equal parts, L1 and R1
Step 5: The bits of L1 and R1 are further divided in 2 parts
Step 6: The 2 parts will be the coords of their respectable S-boxes in binary
Step 7: The resulting decimals value are converted into binary and is combined into a 4-bit value
Step 8: Permutate P4 on the 4-bit value
(Mapping F: End)
Step 9: P4 XOR L0 = R1 (switch)
Step 10: R0 = L1 (switch)
Step 11: Combine L1 and R1
Step 12: Repeat the whole thing again for the next K
Step 13: When the last repetition is complete, combine LN and RN without switching
Step 14: Inverse permutate the combined bits with IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment