OSSL_LIB_CTX* libctx = OSSL_LIB_CTX_new();
CMS_ContentInfo* pCMS = CMS_encrypt_ex(pCertStack, inData, EVP_aes_256_cbc(), CMS_BINARY, libctx, NULL);
unsigned char *buf = NULL;
int len = i2d_CMS_ContentInfo(pCMS, &buf);
Decryption Code Snippet:
int error = CMS_decrypt(p7Env, key , user, NULL, outData, 0);
Additional Notes:
* Looks like with serialization/deserialization, it is loosing our engine context.
* Tried i2d_CMS_bio & d2i_CMS_bio but no success.
* If I perform encryption & decryption within same function (and don’t use serialisation/deserialization), decryption works.
* We do have plans to move from engine to provider implementation but it may take some time.
Looking for your suggestions to fix this issue.
Regards,
Madhu