open-quantum-safe / liboqs

C library for prototyping and experimenting with quantum-resistant cryptography
https://openquantumsafe.org/
Other
1.91k stars 465 forks source link

Avoid OpenSSL functions are unconditionally called at OQS_destroy #1982

Closed ueno closed 1 week ago

ueno commented 2 weeks ago

When OQS_DLOPENOPENSSL is designated and low-level primitives are overridden with OQS_set_callbacks, OQSdestroy still indirectly calls EVP_free from OpenSSL. This adds a extra NULL check to avoid that.

ueno commented 2 weeks ago

then a) why did free_ossl_objects get called in the first place and/or b) why is EVP_MD_free not also replaced with an "alternative TLS lib" variant?

Let me answer (b) first: the objects being freed here (i.e., fetched algorithm implementations) are exclusively used by the OpenSSL implementation, not used nor needed for alternative TLS lib variants.

For (a), to avoid calling free_ossl_objects entirely, liboqs needs to know which objects are used and which are not, as the current mechanism allows partial override (OpenSSL for SHA3 but GnuTLS for SHA2, ...).

baentsch commented 2 weeks ago

the current mechanism allows partial override

That's the explanation I've been looking for, Thanks @ueno .