简体   繁体   English

有没有办法在 openssl v1.1.0 或更高版本中设置不透明结构的成员?

[英]Is there any way to set members of opaque structs in openssl v1.1.0 or greater?

I am restructuring a legacy code to be compatiable with OpenSSL 1.1.1, During the upgrade of OpenSSL from 1.0.2 -> 1.1.1, serveral structs were made opaque and direct member access is no longer possible.我正在重组旧代码以与 OpenSSL 1.1.1 兼容,在 OpenSSL 从 1.0.2 -> 1.1.1 升级期间,多个结构变得不透明并且不再可能直接访问成员。

I have a requirement to set buf_len of EVP_CIPHER_CTX to 0. Is there a way to achieve this?我需要将 EVP_CIPHER_CTX 的 buf_len 设置为 0。有没有办法做到这一点?

EVP_CIPHER_CTX* p_ctx;
p_ctx = EVP_CIPHER_CTX_new();
...

p_ctx->buf_len = 0;

I did this with a dirtiest hack possible in c++我在 c++ 中使用了最肮脏的 hack

int buf_len = 0;

//Offset of buf_len in EVP_CIPHER_CTX is 20
int* buf_len_pointer = (int*)((char*)p_ctx + 20); 

memcpy(buf_len_pointer,&buf_len ,sizeof(buf_len));

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

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