1

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?

2

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. – Nikolay Derkach Mar 25 '15 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 Mar 27 '15 at 8:20

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.