summaryrefslogtreecommitdiffstats
path: root/libssh/dh.c
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/dh.c')
-rw-r--r--libssh/dh.c23
1 files changed, 9 insertions, 14 deletions
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 <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
#include <netdb.h>
+#include <string.h>
+#include "libssh/crypto.h"
#include "libssh/priv.h"
#ifdef HAVE_LIBCRYPTO
@@ -47,8 +47,7 @@ MA 02111-1307, USA. */
#include <openssl/evp.h>
#include <openssl/err.h>
#endif
-#include <string.h>
-#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++;
}
}