summaryrefslogtreecommitdiffstats
path: root/libssh/dh.c
diff options
context:
space:
mode:
authorJean-Philippe Garcia Ballester <giga@le-pec.org>2006-03-01 16:32:22 +0000
committerJean-Philippe Garcia Ballester <giga@le-pec.org>2006-03-01 16:32:22 +0000
commit770e73d8b7d0ca1e3fd8faab08cb88307d1b1c99 (patch)
tree22b77de706cd0e0506159db40be970f949bc17bb /libssh/dh.c
parent10b1a631e8794932a57c84b41a6bf3870416a4cd (diff)
downloadlibssh-770e73d8b7d0ca1e3fd8faab08cb88307d1b1c99.tar.gz
libssh-770e73d8b7d0ca1e3fd8faab08cb88307d1b1c99.tar.xz
libssh-770e73d8b7d0ca1e3fd8faab08cb88307d1b1c99.zip
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
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++;
}
}