I want to create a message exchange program. These messages are encrypted with the AES key, and this key is encrypted using the RSA algorithm. When I send a message from User 1 to User 2, I need to request the public key from User 2, do I just get the key and use it or do I need a secure key exchange like Deffie Hellman or something else? If the answer is yes, how will I be able to use the deffie-Hellman algorithm to send this RSA public key? What I read that Hellman’s algorithm generates its own public and private key, and both are dependent on it, then how do I pass the RSA public key?
The second question is whether I encrypted using the AES algorithm only, and here I have to send the public key from the sender to the receiver, then of course I need a secure medium to transfer the keys like Deffie Hellman’s algorithm. but as I mentioned before that this algorithm generates its own public and private key. But I already have the AES public key. Is there a way to pass the AES public key to deffie hellman? please help me I am really confused about that thnx