I'm learning Linux, and currently SSH. But there are details that I don't really understand.
I've seen and understood how Diffie-Hellman key exchanges work from a mathematical point of view, but what I would like to understand is the symmetric key that is generated for further communications. Everything starts with a large prime number
g
(generator) andn
, that we use combine in some ways using discrete logarithms with a private number to generate the public key which is only used for encryption. This key is a number, so how can a number encrypt a message?Even the symmetrical key obtained is also a number, that will be used for encryption and decryption. Suppose the calculated symmetrical number obtained is
16
, how can16
encrypt a messageGood morning
that I send to someone and then the same number16
decrypts the message at the other side?I've also read that after a key exchange algorithm, AES symmetrical algorithm can be used for further communication. So is AES the symmetrical key generated by Diffie-Hellman key exchange? Is AES a number obtained after calculation using discrete logarithm?
I've also read that RSA can be combined with Diffie-Hellman to enhance security to avoid a MitM attack. So what does RSA really add to the existent key exchange algorithm?
After executing
ssh-keygen -t rsa
, a key pair has been generated, but when I open them in a text editor, I don't see nothing like prime numbers. It's a different format.
Now I'm really confused about how all this math is related to encrypting data exchanged between 2 computers.