I'm designing architecture for sending private messages (i.e. only sender and receiver are able to read a message).

Client side - iOS, server side - Parse.com

I'm thinking of using RSA to encrypt/decrypt messages as follows:

  • iOS app generates a private/public key pair for each user.
  • Private key is stored locally in iOS Keychain
  • Public key is stored on the server.
  • When a user initiates a new conversation, it fetches recipient's public key from the server, encrypts his message with it and sends it to the server.
  • Recipient then fetches the message and decrypts it with his private key from his Keychain

My goal is that no one except the participants of the conversation is able to read the messages. Will this system ensure that?

On the side note, would you recommend any iOS libraries for RSA encryption/decryption?

1 Answer 1


Your scheme isn't very secure.

Someone could mount a MITM attack by intercepting the public key and replacing it by its own. After that, he would be free to relay and re-encrypt all messages without anyone being the wiser.

You need to have some authentication component included in your key exchange so that you can guarantee the ownership of the public key you're using.

  • The users are authenticated by Parse, and with ACL they have access only to the public keys of the people whom they have a conversation with. Communication with the server is SSL-encrypted, so MITM is not possible unless client or the server are compromised. Commented Mar 25, 2015 at 9:27
  • The security of your system still relies on all 3 pieces - the server and both clients - to be secure. That's not what your purposed design goal is.
    – Stephane
    Commented Mar 27, 2015 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .