# Public Keys on Social Media

Is there any problem with using social media (i.e. Facebook) as a directory of public keys?

For example, couldn't Alice put a note containing $(g^a \bmod p, g, p)$ on her Facebook page so she could receive email attachments which have been encrypted with the common secret value?

That is, Bob would encrypt his message with the value obtained from $(g^a)^b \bmod p$ and send it along with in-the-clear $g^b \bmod p$ to Alice. She then can decrypt the message.

If everyone were to publish their public keys, wouldn't this defeat most "man-in-the-middle" attacks?

-
What's to stop a hacker from putting his public key in Alice's profile? –  pg1989 Aug 12 '13 at 21:37
You are effectively using FB as a keyserver. This question on Security.SE might be of interest. –  rath Aug 13 '13 at 14:46

This depends largely on the trustworthiness of Facebook and your assumptions about the model and attacker.

• If Facebook is corrupted, they will just exchange your information to their address/public key and can still do a man-in-the-middle.

• An external attacker could modify the profile pages while they are being transmitted to other users or in their browser, with the same result. In reality, this is easy when SSL is not used or when the person (viewing your profile) is infected by malware.

• If your own computer/browser is compromised, the attacker will either know the according secret $a$ anyway or he can modify your profile update to a value of his choice.

In a more practical world, this could work... if people would use email encryption in general. There are mechanics like PGP or S/MIME, but they are not widely used due to not being comfortable. This is a general problem, but Facebook (or any other social media) would surely work as a place to publish your public key/certificate. But using such a public profile from Facebook from someone else requires a certain amount of trust in the plattform (that it is actually the information from the according user).

In your example you use an Diffie-Hellman key exchange with one fixed parameter, you might want to change that to an ElGamal encryption of a new random key for the symmetric encryption., as usual in hybrid encryption schemes.

-