I want to securely share a symmetrical key between two endpoints using OpenSSL's EVP interface. Transferring the encrypted symmetrical key and decrypting it on the other end works fine, but that leaves me with only the sender having it, since the SealInit function generates a random symmetrical key and immediately encrypts it with the receiver's public key.
So my question is, how am I supposed to be using these functions?
I could solve it by:
a) Generating a symmetrical key beforehand and encrypting it with the receiver's public key, which makes some part of the sealing operation pointless
b) Using a separate symmetrical key for both the sender and receiver, which seems needlessly complex
Since neither option seems like a good solution to me, I think I must be missing something or misunderstanding some basic concepts, as encryption is new to me.
Thank you for reading my question.