For this they have to register their public keys in a server:
- Alice generates her public and private keys (pub_A, priv_A).
- Alice sends pub_A to a public server.
- Bob generates his public and private keys (pub_B, priv_B).
- Bob sends pub_B to a public server.
So, you are basicly exchange public keys and the server uses those as encryption keys.
This means two things:
- Anyone intercepting those public keys can forge messages, and
- You are ignoring the fact why public and private keys come in pairs.
Practically, since your protocol does not use the private keys anyway, you might as well rename “public key” to “key” and notice yourself that you´re exchanging those keys (aka “secrets”) in public with no security what so ever. $User_{Key} \rightarrow Server$ is transmitted unprotected! Anyone eavesdropping the key exchange can intecept those keys and abuse them accordingly. Bob would have no chance to know if a received message was send and encrypted by Alice or Eve.
Also…
Suppose A want to send a message m to B using AES:
- The server generates a random symmetric key key_AES and encrypts it using pub_A and pub_B. Then it sends the encrypted key to Alice and Bob respectively.
Well, your protocol describes that you are expecting Alice and Bob to send their message in plain text to the server, and then the server encrypts the message to send it to Bob. What makes you think Eve will not abuse the fact you are sending “plain text” to the server? That marks another big flaw in your protocol: $User_{message} \rightarrow Server$ is transmitted unprotected!
Does this (chat) protocol for key exchange exist?
No. The obvious reason is that your idea of a secure protocol is absolutely insecure!
Besides that, your protocol idea is a prime example showing you why not to create your own crypto. There are ample well-vetted protocols available (for example diffie-hellman and ecc-based DH) which you can use as a base for mobile chat apps. Don´t shoot yourself in the foot by trying to invent something while better and more secure solutions already exist.
To get you going, I´d like to advise you to read up on both Diffie-Hellman key exchange and the (more recent) Elliptic curve Diffie–Hellman. Doing so will help you grasp how secure public/private key exchanges actually work, and (assuming you implement things correctly) each of them can be used to create secure chat apps.