简体   繁体   English

强制 OpenSSL 在 stream 模式加密/解密(如 AES-CFG、AES-OFB 等)中填充/取消填充数据

[英]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.我目前正在编写一个必须与传统网络服务兼容的 C++ 软件。 The encryption/decryption which is used by that service is AES-128-OFB-PKCS#7(yes, it pads the data in OFB mode).该服务使用的加密/解密是 AES-128-OFB-PKCS#7(是的,它以 OFB 模式填充数据)。 Because OFB mode does not require padding OpenSSL does not apply or remove such padding which gives me the troubles.因为 OFB 模式不需要填充 OpenSSL 不应用或删除这样的填充,这给我带来了麻烦。

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.我一直在尝试寻找一种方法,如果可以强制 OpenSSL 对不需要它的模式使用填充以使其与旧服务兼容。 Is that possible on API level?这可能在 API 级别上吗?

Worst case would be to do the padding myself but if possible I would like to avoid such resolution.最坏的情况是自己做填充,但如果可能的话,我想避免这样的解决方案。

Just wanted to get back to this and notify everyone that there is no way to do that with OpenSSL directly.只是想回到这一点并通知大家,没有办法直接用 OpenSSL 做到这一点。 I've ended up manually adding/removing the padding.我最终手动添加/删除了填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM