I have a question regarding encryption and message sending.
There are 2 hosts, A and B with their own secret key kA and kB (assuming this is not PKI).
It is known that when A wants to send a message to B, they do this handshaking protocol:
A sends to B, an encrypted message in this form E(kA, m), where m is the message and kA is used to encrypt it. B sends to A, an encryption of the previously sent message, E(kB, E(kA, m)), encrypted using kB. A will then send to B, E(kB, m).
after that, B will just decrypt the message using kB.
My question is that how does A know B's key to encrypt the message.
What I think I know about the question:
-I believe it's some kind of mathematical property like RSA's modulus?
-I think it can also be a logarithmic function? (bring down the power, where power = key?)
-Both A and B do not know about each other's key so I think it can be something using interchangeable functions like Log(Exponential(x)) = Exponential(Log(x))?
There's no one real answer as this is just theoretical so I hope to have suggestions (or links where I can further read up) from you guys on how to go about doing this.