I\'m trying to write a simple file enc/decryption within a larger project. I\'d like to avoid libgpgme because of license issues. The openPGP standard is to complex for the
Since you are using the OpenSSL envelope-encryption functions anyway, you should just directly use the EVP_SealInit()
/ EVP_SealUpdate()
/ EVP_SealFinal()
functions. These functions take care of generating the symmetric key and IV, encrypting the data with the symmetric key and encrypting the symmetric key with the recipient(s) RSA key(s).
Once thing that you are not taking care of is authenticity. Under CBC mode it is possible for an attacker to make certain predictable changes to the plaintext, even if they can't read it. To detect this, you should either calculate a HMAC over the encrypted message (using a seperate symmetric key to that used for encryption), or sign the encrypted message (eg. with EVP_SignInit()
/ EVP_SignUpdate()
/ EVP_SignFinal()
).