I plan to create an application for secure instant messaging, now I don't know whether or not I want to implement the encryption by myself. This project is also mainly for educational purpose so I wouldn't mind a bit of extra work.
My 'vision' is that every device that registers for my service generates a RSA-2048 keypair. The public key is then stored at the server and exchanged when the device (user) is being added as 'friend'.
When a session is created I would perform a ECDH key exchange for Perfect Forward Secrecy and then agree to a AES-256 symmetric key. The server stores this AES key in a database together with a SHA-1 hash for identifying it at future session reconnects until a new key is negotiated. Not to forget a nonce against replay attacks.
Is there a lot more I would have to think about when creating a secure protocol?
Thanks in advance, conFusion