Category: Crypto
Author: Adarsh Kishore
Answer / Flag: WEC{DH_sm@a11_subgr0up_A11@ck-c@N-Be-Pr3v3ntedD}
Barry was studying about Electronic Codebooks when he came across a strange text lZyiOdb3KVLrsCn4rOZ3PJ36SCJAnRVGfq4sv4jkFw2TIPiSPHcr5Kv5l/w3Nc9W\n
which was labelled as 'Message From Hell'.
Curious to know more, Barry went to Hell and found that it has
- The title of this problem suggests something no?
- The given flag seems to have all alphabets and numbers. That is in total 62.
- What are the possible attacks on this encryption?
The problem utilizes the small subgroup attack on Diffie-Hellman. Basically, cracking Diffie-Hellman comes down to solving the Discrete Logarithm Problem (DLP) which is, given
This defines a finite group
is called the order of the subgroup generated by
In the given problem,
Also, for additional security, the secret key generated from the DH process is hashed using SHA-256. This key is then used as a symmtetric key in an AES encryption in ECB mode of the flag obtained after decoding the text lZyiOdb3KVLrsCn4rOZ3PJ36SCJAnRVGfq4sv4jkFw2TIPiSPHcr5Kv5l/w3Nc9W\n
in base64
.
Now we simply need to iterate through the subgroup
Upon decryption, we can check if the text obtained starts with "WEC{" and if so, this is our required flag.
A complete solution is outlined in diffie_hellman.py.