From 770e73d8b7d0ca1e3fd8faab08cb88307d1b1c99 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Garcia Ballester Date: Wed, 1 Mar 2006 16:32:22 +0000 Subject: keyfiles.c and wrapper.c: Remove useless secure memory flag (for libgcrypt) dh.c: Initialize libgcrypt only if not done before client.c: Remove cleanup of cryptograhpic library. This needs to be put somewhere, like in a crypto_finish function or something. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@70 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/dh.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'libssh/dh.c') diff --git a/libssh/dh.c b/libssh/dh.c index 89fda25..cbf143c 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -37,9 +37,9 @@ MA 02111-1307, USA. */ #include #include -#include -#include #include +#include +#include "libssh/crypto.h" #include "libssh/priv.h" #ifdef HAVE_LIBCRYPTO @@ -47,8 +47,7 @@ MA 02111-1307, USA. */ #include #include #endif -#include -#include "libssh/crypto.h" + static unsigned char p_value[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, @@ -67,8 +66,6 @@ static unsigned long g_int = 2 ; /* G is defined as 2 by the ssh2 standards */ static bignum g; static bignum p; -int connections = 0; - /* maybe it might be enhanced .... */ /* XXX Do it. */ int ssh_get_random(void *where, int len, int strong){ @@ -93,6 +90,11 @@ void ssh_crypto_init(){ if(!init){ #ifdef HAVE_LIBGCRYPT gcry_check_version(NULL); + if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P,0)) + { + gcry_control(GCRYCTL_INIT_SECMEM, 4096); + gcry_control(GCRYCTL_INITIALIZATION_FINISHED,0); + } #endif g=bignum_new(); bignum_set_word(g,g_int); @@ -101,16 +103,9 @@ void ssh_crypto_init(){ #elif defined HAVE_LIBCRYPTO p=bignum_new(); bignum_bin2bn(p_value,P_LEN,p); -#endif - init++; - } - if (!connections++){ -#ifdef HAVE_LIBGCRYPT - gcry_control(GCRYCTL_INIT_SECMEM,524288,0); - gcry_control(GCRYCTL_INITIALIZATION_FINISHED,0); -#elif defined HAVE_LIBCRYPTO OpenSSL_add_all_algorithms(); #endif + init++; } } -- cgit