|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2010-2012 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* The GnuTLS is free software; you can redistribute it and/or
|
|
Packit Service |
4684c1 |
* modify it under the terms of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
* as published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
4684c1 |
* the License, or (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This library is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* Lesser General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "gnutls_int.h"
|
|
Packit Service |
4684c1 |
#include "errors.h"
|
|
Packit Service |
4684c1 |
#include <libtasn1.h>
|
|
Packit Service |
4684c1 |
#include <dh.h>
|
|
Packit Service |
4684c1 |
#include <random.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <locks.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/**
|
|
Packit Service |
4684c1 |
* gnutls_global_set_mutex:
|
|
Packit Service |
4684c1 |
* @init: mutex initialization function
|
|
Packit Service |
4684c1 |
* @deinit: mutex deinitialization function
|
|
Packit Service |
4684c1 |
* @lock: mutex locking function
|
|
Packit Service |
4684c1 |
* @unlock: mutex unlocking function
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* With this function you are allowed to override the default mutex
|
|
Packit Service |
4684c1 |
* locks used in some parts of gnutls and dependent libraries. This function
|
|
Packit Service |
4684c1 |
* should be used if you have complete control of your program and libraries.
|
|
Packit Service |
4684c1 |
* Do not call this function from a library, or preferably from any application
|
|
Packit Service |
4684c1 |
* unless really needed to. GnuTLS will use the appropriate locks for the running
|
|
Packit Service |
4684c1 |
* system.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Note that since the move to implicit initialization of GnuTLS on library
|
|
Packit Service |
4684c1 |
* load, calling this function will deinitialize the library, and re-initialize
|
|
Packit Service |
4684c1 |
* it after the new locking functions are set.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This function must be called prior to any other gnutls function.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Since: 2.12.0
|
|
Packit Service |
4684c1 |
**/
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
gnutls_global_set_mutex(mutex_init_func init, mutex_deinit_func deinit,
|
|
Packit Service |
4684c1 |
mutex_lock_func lock, mutex_unlock_func unlock)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (init == NULL || deinit == NULL || lock == NULL
|
|
Packit Service |
4684c1 |
|| unlock == NULL)
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_mutex_init = init;
|
|
Packit Service |
4684c1 |
gnutls_mutex_deinit = deinit;
|
|
Packit Service |
4684c1 |
gnutls_mutex_lock = lock;
|
|
Packit Service |
4684c1 |
gnutls_mutex_unlock = unlock;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_global_init();
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
_gnutls_debug_log("error in gnutls_global_init(): %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|