Lipovlan / cng-openssl-provider

OpenSSL provider using Windows Cryptography API: Next Generation
MIT License
6 stars 6 forks source link

Use OpenSSL memory allocation methods #2

Closed Lipovlan closed 1 year ago

Lipovlan commented 1 year ago

OpenSSL has function that core passes to the provider such asOSSL_FUNC_CRYPTO_MALLOC, OSSL_FUNC_CRYPTO_ZALLOC or OSSL_FUNC_CRYPTO_FREE. Those should be used instead of normal malloc and free so it can be better integrated with OpenSSL tools.

levitte commented 1 year ago

Actually... why? There is no real reason why you a provider should have to use OpenSSL's memory management routines. All the memory allocated by a provider is 100% provider private anyway, so as long as the provider handles dynamic memory cleanly, it's fine using the usual C RTL routines.

Lipovlan commented 1 year ago

Thanks for the feedback. I was wondering since the OpenSSL core passes these functions to the provider that they must serve a purpose.

These functions are supposed to be like the CRYPTO_malloc related functions. But I wasn't quite able to figure out their exact purpose (other than doing normal allocation-related stuff).

As I do not have full overview of the functionalities and tools around OpenSSL I thought that maybe they have a purpose in tests and tracing. Thus if I changed the normal malloc for CRYPTO_malloc I could later write tests and such that when this provider is compiled with OpenSSL and not standalone they would run in the same manner.

And when doing research on other providers (which I found out today are neatly packed in your Provider corner) I found usage of what I thought were these functions which I assumed must be there for a purpose that I simply don't know yet.

So the goal of this issue was to find out if there were benefits for CNG provider in using these functions and if to implement them. But it seems like that is not necessary :)