Diffie-Hellman and MIM attack:
When variants of Diffie-Hellman algorithms like DHE, ECDHE etc. are used in SSL handshake for key exchange then can it become prone to man in middle (MIM) attack.
Suppose, SSL handshake has started and now it is time of key exchange, so client computes its public key part of DH and sends it, now bad guy sitting in the middle intercepts it and computes its public key part of DH and sends it. And then both computes the shared secret from each other's public key and shared secret is established. Now even though the traffic is encrypted using the shared secret but since the bad guy did all this, so he will be able to decrypt it. No?
In case of RSA, since anything encrypted using public key can only be decrypted using private key so it is safe. I am sure about this, but with DH I am getting above doubt.
Suppose cipher is TLS_ECDHE_RSA..... Now, as I understand ECDHE is for key exchange and RSA is to prove server identity or authentication. But how RSA is used to prove the server identity or authentication because it is done with digital signature, right? Client will see the server's DC is signed by a trusted CA and he will identify and trust the server. Then how "_RSA" or "ECDSA" part of cipher suite comes into picture to prove server's identity or for authentication?
I have read a lot of algorithm explanation for key exchange thing but never about server's identity or for authentication from "_RSA" or "ECDSA" part of cipher suite.