Reference: https://wiki.openssl.org/index.php/Manual:EVP_SealInit%283%29
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
or
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.
EVP_SealInit
directly, you could write your own function which is quite similar, but which allows you to specify the symmetric key. TheEVP_SealInit
source code would be fairly easy to copy; you then modify/remove the portion whereEVP_CIPHER_CTX_rand_key
is called to generate the random key, and instead use one you supply to your function.