I am using ElGamal ECC to encrypt my plain text data. I want to ensure that my data is safe from a Man-In-The-Middle attack. What methodology I can adopt to achieve this goal?

How can we prevent a Man-In-The-Middle attack while encrypting data by using ElGamal ECC?

  • 4
    $\begingroup$ Be sure that you use the correct (authentic) public key of the intended receiver. $\endgroup$ – DrLecter Sep 1 '14 at 20:40
  • 3
    $\begingroup$ That rather depends on the goals of the man-in-the-middle. Is it a) to read what you sent (in which case DrLecter's advice is the correct answer), or b) to replace your message with his own (which ElGamal does nothing to prevent; you'll need to sign/MAC your message to prevent that) $\endgroup$ – poncho Sep 2 '14 at 3:46
  • 2
    $\begingroup$ Keep in mind that ElGamal is a cryptographic primitive; it is used to build secure cryptographic algorithms that are secure against a multitude of attacks. Just using the primitive alone is not going to cut it. You need padding, authentication, etc. $\endgroup$ – QuadrExAtt Sep 2 '14 at 6:36

DrLecter is right.

It all boils down to making sure to use the right public key. In fact this is the same for any public key cryptosystem be it RSA elGamal or ECC variants thereof.

A MAC or whatever other construction local to your system won't do the job. The MAC e.g. can only make sure the last "editor" of the message knew the symmetric key the message is enciphered with, which a man in the middle obviously always does.

You can only achieve some protection by

  • trusting a CA who signed the key or

  • trusting a PGP style "web of trust" or

  • by meeting your communication partner in person and exchange keys face to face.

A somewhat weaker protection independent of an external organization might be achieved by:

  • Using a second independent and well protected channel to transfer the public key. E.g. use the phone if you trust your mobile...

  • Posting a video where you read your public key aloud. (This helps with people who know you well in person and is hard to fake - I do that with my Academic Signature ECC-key here: http://www.fh-wedel.de/~an/crypto/key_read_anders.ogv . It might be awkward with elGamal or RSA keys which need to be very long nowadays.

  • There are also cryptographic concepts of deterministically deriving a public key from an e-mail address or a name string. This concept is called "Identity Based Encryption" (IBE). You can find it explained in wikipedia. IBE, however, IMHO just transfers the problem and doesn't solve it.

| improve this answer | |

There are two parts of this, as poncho already noted in his comment:

  1. protecting the confidentiality of the message against a man-in-the-middle;
  2. protecting the integrity / authenticity of the message against a man-in-the-middle.

The first protection can be achieved by making sure that the public key of the key pair used by the receiver can be trusted. That is: the sender must be sure that the private key is under control of the intended receiver.

The second protection can be achieved by signing the message before encryption using a separate key pair used by the sender. To be able to verify the message the receiver of course needs make sure that the public key of the sender can be trusted.

Using a MAC or encrypt-then-sign won't work. The attacker could simply strip off the MAC value or signature and replace it by its own value.

Finally you may have to make sure that replay attacks cannot be executed. Any additional (symmetric) algorithm must be used correctly as well of course. Just getting this part right doesn't suddenly protect the entire system.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.