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.


They will absolutely need to do a key exchange so that A knows Kb and B knows Ka. There are different methods but they are usually based in the Diffie Hellman algorithm.

For convenience I will paste here wikipedia's example:

Alice and Bob agree to use a prime number p = 23 and base g = 5.
Alice chooses a secret integer a = 6, then sends Bob A = ga mod p
    A = 56 mod 23
    A = 15,625 mod 23
    A = 8
Bob chooses a secret integer b = 15, then sends Alice B = gb mod p
    B = 515 mod 23
    B = 30,517,578,125 mod 23
    B = 19
Alice computes s = Ba mod p
    s = 196 mod 23
    s = 47,045,881 mod 23
    s = 2
Bob computes s = Ab mod p
    s = 815 mod 23
    s = 35,184,372,088,832 mod 23
    s = 2
Alice and Bob now share a secret (the number 2) because 6 × 15 is the same as 15 × 6.

You will find several answers discussing this algorithm.

| improve this answer | |
  • Hi, I didn't look into diffie hellman's algo, but I shall do it now, but this question comes with restrictions i.e. no prior knowledge of any common info beforehand, A does not know kB, all he knows is the message and kA so that he can do E(kA, m) – robobooga Feb 25 '14 at 9:07
  • If they can communicate they can exchange some messages with the numbers don't you think? Also, if they can't exchange the keys, they can't crypt their communications... – kiBytes Feb 25 '14 at 9:28

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.