mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
Change back to a initialized variable and document ssh_finalize().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@557 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
14
libssh/dh.c
14
libssh/dh.c
@@ -72,7 +72,7 @@ static unsigned char p_value[] = {
|
|||||||
static unsigned long g_int = 2 ; /* G is defined as 2 by the ssh2 standards */
|
static unsigned long g_int = 2 ; /* G is defined as 2 by the ssh2 standards */
|
||||||
static bignum g;
|
static bignum g;
|
||||||
static bignum p;
|
static bignum p;
|
||||||
static unsigned int ssh_crypto_initialized_ref_count = 0;
|
static int ssh_crypto_initialized;
|
||||||
|
|
||||||
int ssh_get_random(void *where, int len, int strong){
|
int ssh_get_random(void *where, int len, int strong){
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ int ssh_get_random(void *where, int len, int strong){
|
|||||||
* FIXME: Make the function thread safe by adding a semaphore or mutex.
|
* FIXME: Make the function thread safe by adding a semaphore or mutex.
|
||||||
*/
|
*/
|
||||||
int ssh_crypto_init(void) {
|
int ssh_crypto_init(void) {
|
||||||
if (ssh_crypto_initialized_ref_count == 0) {
|
if (ssh_crypto_initialized == 0) {
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_check_version(NULL);
|
gcry_check_version(NULL);
|
||||||
|
|
||||||
@@ -134,19 +134,15 @@ int ssh_crypto_init(void) {
|
|||||||
bignum_bin2bn(p_value, P_LEN, p);
|
bignum_bin2bn(p_value, P_LEN, p);
|
||||||
OpenSSL_add_all_algorithms();
|
OpenSSL_add_all_algorithms();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
ssh_crypto_initialized_ref_count++;
|
ssh_crypto_initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ssh_crypto_finalize(void) {
|
void ssh_crypto_finalize(void) {
|
||||||
if (ssh_crypto_initialized_ref_count) {
|
if (ssh_crypto_initialized) {
|
||||||
ssh_crypto_initialized_ref_count--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ssh_crypto_initialized_ref_count == 0) {
|
|
||||||
bignum_free(g);
|
bignum_free(g);
|
||||||
g = NULL;
|
g = NULL;
|
||||||
bignum_free(p);
|
bignum_free(p);
|
||||||
|
|||||||
@@ -32,12 +32,15 @@
|
|||||||
* \addtogroup ssh_session
|
* \addtogroup ssh_session
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief finalize and cleanup all libssh and cryptographic data structures
|
* @brief Finalize and cleanup all libssh and cryptographic data structures.
|
||||||
* \returns 0
|
*
|
||||||
|
* This function should only be called once, at the end of the program!
|
||||||
|
*
|
||||||
|
* @returns 0
|
||||||
*/
|
*/
|
||||||
int ssh_finalize(void)
|
int ssh_finalize(void) {
|
||||||
{
|
|
||||||
ssh_crypto_finalize();
|
ssh_crypto_finalize();
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_control(GCRYCTL_TERM_SECMEM);
|
gcry_control(GCRYCTL_TERM_SECMEM);
|
||||||
|
|||||||
Reference in New Issue
Block a user