Xace fua eno el lex jat fesela. La kinunsaresen rironen ernlarnkael'i lius, cene niurnen asti'e laozia. Pa, liaxo vileti's moni'akda'i kalzanenon cerkmern...
Note: The flag of this challenge is in the format of
Overview, Concept and Design Criteria
The key vulnerability is small subgroup attack under multiplicative DHKE. By sending a element in that small group, there won't be too much possible shared secrets.
This is a simple modern crytographic challenge, which may deserve 100 points in normal CTF. However, this challenge requires you to have some basic knowledge of number theory, otherwise you won't even notice the existence of subgroup. I also put some effort to make it more interesting to experienced crypto solvers, such as introducing a guest account, PBKDF2, using flag as password, and the most confusing one: obfuscation by a obsecure language.
About the language
The description and the program of this challenge is written in Lineparine (リパライン語, 理語), an artificial language created by Fafs F. sashimi. The vulnerability is not related to the language, so it is still solvable if you treat the source code as obfustrated. It just sets the crytographic tone for the whole challenge perfectly :)
If you are interesting to the meanings, there's English translation in
translation.txt. I'm not a master of Lineparine, I guess there are many mistakes in this challenge. If you know how to write in Lineparine fluently, please help me to improve the challenge :)
I spent about 10 hours designing this challenge, where 9 hours are used to translate to Lineparine LOL.
Send a element in a small group and guess the shared secret.
You need to know some basic group theory.
- The order of finite field over prime is . [Euler's totient function]
- A prime number dividing the order of implies the existence of subgroup with order . [Cauchy's theorem)]
- The order of every subgroup of divides the order of . [Lagrange's theorem)]
The generator of order 2 subgroup is -1, which cannot be used in this challenge.
To find an generator of subgroup with order 49391, you can select a random number r that is not 1 or -1, and calculate by: Order of should be 49391 because that according to Fermet's little theorem: This method may output with probability of , if you're too lucky to get , try again.
The shared secret have only 49391 possible values. You can check which one is correct using sha256 MAC inside the message.
Small subgroup attack is a very old but common mistake in DH/ECDH is not handled correctly, and it still appears in modern softwares. One most recently example is CVE-2018-5383 on Bluetooth pairing, which use a invalid curve of order 2 (Strictly speaking, it actually using another curve which has exactly same arithmetic operation rather than subgroup).