Only in libssh2-1.2.5-20100309_orig/: ChangeLog
diff -ru libssh2-1.2.5-20100309_orig/include/libssh2.h libssh2-1.2.5-20100309/include/libssh2.h
--- libssh2-1.2.5-20100309_orig/include/libssh2.h	2010-03-09 06:06:36.000000000 +0100
+++ libssh2-1.2.5-20100309/include/libssh2.h	2010-03-10 11:58:23.000000000 +0100
@@ -996,6 +996,26 @@
                                          void* context,
                                          libssh2_trace_handler_func callback);
 
+#define LIBSSH2_INIT_ALL                   0x0000
+#define LIBSSH2_INIT_NO_CRYPTO_INIT        0x0001
+/*
+ * libssh2_init()
+ *
+ * Initialize the libssh2 functions. flags can be:
+ * LIBSSH2_INIT_ALL:               Initialize everything
+ * LIBSSH2_INIT_NO_CRYPTO_INIT:    Do not initialize the crypto library (ie. 
+ * OPENSSL_add_cipher_algoritms() for OpenSSL
+ *
+ * Returns 0 if succeeded, or a negative value for error.
+ */
+LIBSSH2_API int libssh2_init(int flags);
+/*
+ * libssh2_exit()
+ *
+ * Exits the libssh2 function and free's all memory used internal.
+ */
+LIBSSH2_API void libssh2_exit();
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
Only in libssh2-1.2.5-20100309/src: global.c
diff -ru libssh2-1.2.5-20100309_orig/src/libgcrypt.h libssh2-1.2.5-20100309/src/libgcrypt.h
--- libssh2-1.2.5-20100309_orig/src/libgcrypt.h	2009-11-17 06:06:05.000000000 +0100
+++ libssh2-1.2.5-20100309/src/libgcrypt.h	2010-03-10 12:03:22.000000000 +0100
@@ -93,6 +93,7 @@
 #define libssh2_hmac_cleanup(ctx) gcry_md_close (*ctx);
 
 #define libssh2_crypto_init() gcry_control (GCRYCTL_DISABLE_SECMEM)
+#define libssh2_crypto_exit() 
 
 #define libssh2_rsa_ctx struct gcry_sexp
 
diff -ru libssh2-1.2.5-20100309_orig/src/libssh2_priv.h libssh2-1.2.5-20100309/src/libssh2_priv.h
--- libssh2-1.2.5-20100309_orig/src/libssh2_priv.h	2010-03-04 06:06:04.000000000 +0100
+++ libssh2-1.2.5-20100309/src/libssh2_priv.h	2010-03-10 12:06:06.000000000 +0100
@@ -1242,5 +1242,6 @@
 
 #define ARRAY_SIZE(a) (sizeof ((a)) / sizeof ((a)[0]))
 
+extern int libssh2_initialized;
 
 #endif /* LIBSSH2_H */
diff -ru libssh2-1.2.5-20100309_orig/src/Makefile.in libssh2-1.2.5-20100309/src/Makefile.in
--- libssh2-1.2.5-20100309_orig/src/Makefile.in	2010-03-09 06:06:16.000000000 +0100
+++ libssh2-1.2.5-20100309/src/Makefile.in	2010-03-10 11:59:28.000000000 +0100
@@ -65,7 +65,7 @@
 am__objects_1 = channel.lo comp.lo crypt.lo hostkey.lo kex.lo mac.lo \
 	misc.lo packet.lo publickey.lo scp.lo session.lo sftp.lo \
 	userauth.lo transport.lo version.lo knownhost.lo agent.lo \
-	openssl.lo libgcrypt.lo pem.lo
+	openssl.lo libgcrypt.lo pem.lo global.lo
 am__objects_2 =
 am_libssh2_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libssh2_la_OBJECTS = $(am_libssh2_la_OBJECTS)
@@ -217,7 +217,7 @@
 AUTOMAKE_OPTIONS = foreign nostdinc
 CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
  packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
- version.c knownhost.c agent.c openssl.c libgcrypt.c pem.c
+ version.c knownhost.c agent.c openssl.c libgcrypt.c pem.c global.c
 
 HHEADERS = libssh2_priv.h openssl.h libgcrypt.h transport.h channel.h comp.h mac.h misc.h
 
diff -ru libssh2-1.2.5-20100309_orig/src/openssl.c libssh2-1.2.5-20100309/src/openssl.c
--- libssh2-1.2.5-20100309_orig/src/openssl.c	2010-03-02 06:06:07.000000000 +0100
+++ libssh2-1.2.5-20100309/src/openssl.c	2010-03-10 12:02:17.000000000 +0100
@@ -358,14 +358,6 @@
         (pem_read_bio_func) &PEM_read_bio_RSAPrivateKey;
     (void) session;
 
-    if (!EVP_get_cipherbyname("des")) {
-/* If this cipher isn't loaded it's a pretty good indication that none are.
- * I have *NO DOUBT* that there's a better way to deal with this ($#&%#$(%$#(
- * Someone buy me an OpenSSL manual and I'll read up on it.
- */
-        OpenSSL_add_all_ciphers();
-    }
-
     return read_private_key_from_file((void **) rsa, read_rsa,
                                       filename, passphrase);
 }
@@ -380,14 +372,6 @@
         (pem_read_bio_func) &PEM_read_bio_DSAPrivateKey;
     (void) session;
 
-    if (!EVP_get_cipherbyname("des")) {
-/* If this cipher isn't loaded it's a pretty good indication that none are.
- * I have *NO DOUBT* that there's a better way to deal with this ($#&%#$(%$#(
- * Someone buy me an OpenSSL manual and I'll read up on it.
- */
-        OpenSSL_add_all_ciphers();
-    }
-
     return read_private_key_from_file((void **) dsa, read_dsa,
                                       filename, passphrase);
 }
@@ -461,4 +445,15 @@
 }
 #endif /* LIBSSH_DSA */
 
+void libssh2_crypto_init()
+{
+        ERR_load_crypto_strings();
+        OpenSSL_add_all_algorithms();
+        ENGINE_load_builtin_engines();
+}
+
+void libssh2_crypto_exit()
+{
+}
+
 #endif /* !LIBSSH2_LIBGCRYPT */
diff -ru libssh2-1.2.5-20100309_orig/src/openssl.h libssh2-1.2.5-20100309/src/openssl.h
--- libssh2-1.2.5-20100309_orig/src/openssl.h	2010-03-02 06:06:07.000000000 +0100
+++ libssh2-1.2.5-20100309/src/openssl.h	2010-03-10 12:02:43.000000000 +0100
@@ -130,8 +130,6 @@
 #define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
 #define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx)
 
-#define libssh2_crypto_init()
-
 #define libssh2_rsa_ctx RSA
 
 int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
diff -ru libssh2-1.2.5-20100309_orig/src/session.c libssh2-1.2.5-20100309/src/session.c
--- libssh2-1.2.5-20100309_orig/src/session.c	2010-03-04 06:06:04.000000000 +0100
+++ libssh2-1.2.5-20100309/src/session.c	2010-03-10 12:00:34.000000000 +0100
@@ -456,7 +456,8 @@
         session->api_block_mode = 1; /* blocking API by default */
         _libssh2_debug(session, LIBSSH2_TRACE_TRANS,
                        "New session resource allocated");
-        libssh2_crypto_init();
+	if (libssh2_initialized == 0)
+            libssh2_init(LIBSSH2_INIT_ALL);
     }
     return session;
 }
Only in libssh2-1.2.5-20100309_orig/win32: libssh2.dsp


