Assuming that Alice and Bob know the hash of each other's public key, take this method:
- Use ECDiffieHellman with temporary private keys each time to generate a per-session shared symmetric key
- Create an AES connection secured with the shared key (unique IVs for each message, verified with HMAC)
- Send their public keys along with their signatures of that particular session key over the encrypted connection to authenticate each other (by verifying that the public key matches the stored hash, and that the signature was signed by the public key).
Is this a safe way to create a secure and authenticated session? Are there any better ways that do not require pre-existing knowledge of the private key (or trust in a centralised certificate authority). I know that you should always try to use standard libraries, but I am interested in understanding more about cryptography - this will not be used in any critical software.
Thanks very much for your help.