[gnutls-devel] eliminating gnutls_global_init

Nikos Mavrogiannopoulos nmav at gnutls.org
Sat Nov 30 01:01:46 CET 2013


Hello,
 I'm considering moving parts of gnutls_global_init to a library
constructor. That would mean that in ELF systems and systems that
support constructors, it would be possible to use gnutls without calling
gnutls_global_init().

The main parts in gnutls_global_init now are:
* Initialization of libtasn1 structures (no I/O)
* Initialization of mutexes (no I/O)
* Detection of CPU type and loading of any possible accelerated cipher
versions (may have I/O when cryptodev is compiled in)
* Initialization of the random number generator (requires I/O
from /dev/urandom)
* Initialization of PKCS #11 modules (anything could be there -it's
hell)

I'm thinking to put everything except the PKCS #11 initialization in the
constructor, and that functionality would only be available if the
global_init is explicitly called.

The issues with having the initialization the constructor are
* It is not clear what to do on initialization error (e.g. when some I/O
fails)
* There will be different semantics in static libraries (that call no
constructors), which will still need to call gnutls_global_init and ELF
shared libraries that will not.

Any issues I've missed, or ideas?

regards,
Nikos





More information about the Gnutls-devel mailing list