[EN] [CTF] TAMU - Simple DES
Write-up for challenge 'Simple DES' (Crypto, 125 pts) from TAMU CTF 2018.
Larry is working on an encryption algorithm based on DES.
He hasn’t worked out all the kinks yet, but he thinks it works.
Your job is to confirm that you can decrypt a message, given the algorithm and parameters used.
His system works as follows:
- Choose a plaintext that is divisible into 12bit ‘blocks’
- Choose a key at least 8bits in length
- For each block from
i=0
whilei<N
perform the following operations- Repeat the following operations on block
i
, fromr=0
whiler<R
- Divide the block into 2 6bit sections
Lr
,Rr
- Using
Rr
, “expand” the value from 6bits to 8bits.
Do this by remapping the values using their index, e.g.
1 2 3 4 5 6 -> 1 2 4 3 4 3 5 6- XOR the result of this with 8bits of the
Key
beginning withKey[iR+r]
and wrapping back to the beginning if necessary.- Divide the result into 2 4bit sections
S1
,S2
- Calculate the 2 3bit values using the two “S boxes” below, using S1 and S2 as input respectively.
S1 0 1 2 3 4 5 6 7 0 101 010 001 110 011 100 111 000 1 001 100 110 010 000 111 101 011
S2 0 1 2 3 4 5 6 7 0 100 000 110 101 111 001 011 010 1 101 011 000 111 110 010 001 100
- Concatenate the results of the S-boxes into 1 6bit value
- XOR the result with
Lr
- Use
Rr
asLr
and your alteredRr
(result of previous step) asRr
for any further computation on blocki
- increment
r
He has encryped a message using Key="Mu”, and R=2. See if you can decipher it into plaintext.
Submit your result to Larry in the format Gigem{plaintext}.
Binary of ciphertext:
01100101 00100010 10001100 01011000 00010001 10000101
Since the key and the number of iteration are known, we simply need to build a decryption function to which we will give the ciphertext. Based on Larry’s encryption algorithm, here are the different steps needed to decrypt a message :
- Divide the encrypted text into 12-bit blocks
- For each block from
i=0
whilei<N
perform the following operations - Repeat the following operations on block
i
, fromr=R-1
whiler<=0
- Divide the block into 2 6bit sections
Rr
(left) andRr-alt
(right) - Using
Rr
, “expand” the value from 6bits to 8bits using the same method as encryption (e.g. 1 2 3 4 5 6 -> 1 2 4 3 4 3 5 6) - XOR the result of this with 8bits of the
Key
beginning withKey[iR+r]
and wrapping back to the beginning if necessary. - Divide the result into 2 4bit sections
S1
,S2
and calculate the 2 3bit values using the two “S boxes” above, using S1 and S2 as input respectively. - Concatenate the results of the S-boxes into 1 6bit value
- XOR the result with
Rr-alt
to recoverLr
- Your new block consists of
Lr
, the result of the XOR above (left) andRr
(right) - Decrement
r
|
|
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email