Beispiel #1
0
static void _gnutls_global_deinit(unsigned destructor)
{
	GNUTLS_STATIC_MUTEX_LOCK(global_init_mutex);

	if (_gnutls_init == 1) {
		_gnutls_init = 0;
		gnutls_crypto_deinit();
		_gnutls_rnd_deinit();
		_gnutls_ext_deinit();
		asn1_delete_structure(&_gnutls_gnutls_asn);
		asn1_delete_structure(&_gnutls_pkix1_asn);
		_gnutls_crypto_deregister();
		gnutls_system_global_deinit();
		_gnutls_cryptodev_deinit();

#ifdef ENABLE_PKCS11
		/* Do not try to deinitialize the PKCS #11 libraries
		 * from the destructor. If we do and the PKCS #11 modules
		 * are already being unloaded, we may crash.
		 */
		if (destructor == 0) {
			gnutls_pkcs11_deinit();
		}
#endif

		gnutls_mutex_deinit(&_gnutls_file_mutex);
		gnutls_mutex_deinit(&_gnutls_pkcs11_mutex);
	} else {
		if (_gnutls_init > 0)
			_gnutls_init--;
	}
	GNUTLS_STATIC_MUTEX_UNLOCK(global_init_mutex);
}
Beispiel #2
0
static void _gnutls_global_deinit(unsigned destructor)
{
	if (!destructor) {
		GNUTLS_STATIC_MUTEX_LOCK(global_init_mutex);
	}

	if (_gnutls_init == 1) {
		_gnutls_init = 0;
		if (_gnutls_init_ret < 0) {
			/* only deinitialize if gnutls_global_init() has
			 * succeeded */
			gnutls_assert();
			goto fail;
		}

		_gnutls_system_key_deinit();
		gnutls_crypto_deinit();
		_gnutls_rnd_deinit();
		_gnutls_ext_deinit();
		asn1_delete_structure(&_gnutls_gnutls_asn);
		asn1_delete_structure(&_gnutls_pkix1_asn);

		_gnutls_crypto_deregister();
		gnutls_system_global_deinit();
		_gnutls_cryptodev_deinit();

		_gnutls_supplemental_deinit();
		_gnutls_unload_system_priorities();

#ifdef ENABLE_PKCS11
		/* Do not try to deinitialize the PKCS #11 libraries
		 * from the destructor. If we do and the PKCS #11 modules
		 * are already being unloaded, we may crash.
		 */
		if (destructor == 0) {
			gnutls_pkcs11_deinit();
		}
#endif
#ifdef HAVE_TROUSERS
		_gnutls_tpm_global_deinit();
#endif

		gnutls_mutex_deinit(&_gnutls_file_mutex);
		gnutls_mutex_deinit(&_gnutls_pkcs11_mutex);
	} else {
		if (_gnutls_init > 0)
			_gnutls_init--;
	}

 fail:
	if (!destructor) {
		GNUTLS_STATIC_MUTEX_UNLOCK(global_init_mutex);
	}
}
Beispiel #3
0
/**
 * gnutls_global_deinit:
 *
 * This function deinitializes the global data, that were initialized
 * using gnutls_global_init().
 *
 * Note!  This function is not thread safe.  See the discussion for
 * gnutls_global_init() for more information.
 **/
void
gnutls_global_deinit (void)
{
  if (_gnutls_init == 1)
    {
      gl_sockets_cleanup ();
      _gnutls_rnd_deinit ();
      _gnutls_ext_deinit ();
      asn1_delete_structure (&_gnutls_gnutls_asn);
      asn1_delete_structure (&_gnutls_pkix1_asn);
      _gnutls_crypto_deregister ();
      _gnutls_cryptodev_deinit ();
    }
  _gnutls_init--;
}
Beispiel #4
0
/**
 * gnutls_global_deinit:
 *
 * This function deinitializes the global data, that were initialized
 * using gnutls_global_init().
 *
 * Note!  This function is not thread safe.  See the discussion for
 * gnutls_global_init() for more information.
 **/
void
gnutls_global_deinit (void)
{
  if (_gnutls_init == 1)
    {
      gl_sockets_cleanup ();
      gnutls_crypto_deinit();
      _gnutls_rnd_deinit ();
      _gnutls_ext_deinit ();
      asn1_delete_structure (&_gnutls_gnutls_asn);
      asn1_delete_structure (&_gnutls_pkix1_asn);
      _gnutls_crypto_deregister ();
      _gnutls_cryptodev_deinit ();
      gnutls_system_global_deinit ();
#ifdef ENABLE_PKCS11
      gnutls_pkcs11_deinit ();
#endif
      gnutls_mutex_deinit(&_gnutls_file_mutex);
    }
  _gnutls_init--;
}