Reputation: 500
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.
I have a requirement to set buf_len of EVP_CIPHER_CTX to 0. Is there a way to achieve this?
EVP_CIPHER_CTX* p_ctx;
p_ctx = EVP_CIPHER_CTX_new();
...
p_ctx->buf_len = 0;
Upvotes: 0
Views: 124
Reputation: 500
I did this with a dirtiest hack possible in c++
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));
Upvotes: 0