-
Notifications
You must be signed in to change notification settings - Fork 2
Attack on libgcrypt's ElGamal Encryption with Proof of Concept (PoC)
Joint work with Erik-Oliver Blass from Airbus.
The textbook ElGamal implementation is not secure. If we use libgcrypt to encrypt messages directly, rather than using for hybrid encryption, the security can be broken.
I would give the basic idea as follows. Readers with modern algebra background can jump to @TElgamal 's explanation here.
Due to technical reasons, all messages are classified into two classes. A random message belongs to one of them (with 50% 50% possibility).
In some applications, there are only several possible messages. Consider we are sending a military message. There are only two outcomes: the army moved forward or retracted. With a high possibility, they belong to different classes.
We now encrypt two messages with ElGamal.
The encrypted result is called a ciphertext. It should reveal NO information about the original message.
We expect a secure encryption scheme to provide message indistinguishability. No adversary can learn what is encrypted inside the ciphertext better than a random guess.
Let us assume the headquarter sent the second message -- no adversary should to able to learn.
Due to the wrong implementation, the adversary can distinguish messages in different classes.
If the outcomes differ in which classes they belong to, then an adversary can infer more information.
We release our attack code in this GitHub repo: https://github.com/weikengchen/attack-on-libgcrypt-elgamal
A running trace is collected by Travis CI: https://travis-ci.org/weikengchen/attack-on-libgcrypt-elgamal/builds/336433895
Showing that our adversary makes 0% mistakes in guessing the messages if the two outcomes differ in the classes they belong to.
The problem can be fixed by using ElGamal carefully on the correct algebra group. Some results are given by @TElgamal and me on issue https://github.com/Legrandin/pycryptodome/issues/90 .
If libgcrypt plans to limit the uses only to hybrid encryption, I think libgcrypt should announce it on the manual here: https://gnupg.org/documentation/manuals/gcrypt/Available-algorithms.html#Available-algorithms