Search code examples
c++copensslaespad

Enforce OpenSSL to pad/unpad data in stream mode encryption/decryption(like AES-CFG, AES-OFB, etc)


I'm currently writing a C++ software which have to be compatible with a legacy network service. The encryption/decryption which is used by that service is AES-128-OFB-PKCS#7(yes, it pads the data in OFB mode). Because OFB mode does not require padding OpenSSL does not apply or remove such padding which gives me the troubles.

I've been trying to find a way if OpenSSL can be enforced to use padding for modes which do not require it in order to make it compatible with the legacy service. Is that possible on API level?

Worst case would be to do the padding myself but if possible I would like to avoid such resolution.


Solution

  • Just wanted to get back to this and notify everyone that there is no way to do that with OpenSSL directly. I've ended up manually adding/removing the padding.