[packages/php-pecl-ssh2] up to 0.13 (2016-06-12); cleanup branch.diff

glen glen at pld-linux.org
Thu May 4 13:59:58 CEST 2017


commit c179bae37976b682335095d394fc8ef6329bb0d3
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu May 4 14:58:37 2017 +0300

    up to 0.13 (2016-06-12); cleanup branch.diff

 branch.diff        | 19467 ---------------------------------------------------
 php-pecl-ssh2.spec |    15 +-
 2 files changed, 4 insertions(+), 19478 deletions(-)
---
diff --git a/php-pecl-ssh2.spec b/php-pecl-ssh2.spec
index 56732e8..4996b8c 100644
--- a/php-pecl-ssh2.spec
+++ b/php-pecl-ssh2.spec
@@ -1,17 +1,15 @@
 %define		php_name	php%{?php_suffix}
 %define		modname	ssh2
-%define		status	beta
 Summary:	%{modname} - bindings for the libssh2 library
 Summary(pl.UTF-8):	%{modname} - dowiązania do biblioteki libssh2
 Name:		%{php_name}-pecl-%{modname}
-Version:	0.12
-Release:	5
+Version:	0.13
+Release:	1
 License:	PHP
 Group:		Development/Languages/PHP
 Source0:	http://pecl.php.net/get/%{modname}-%{version}.tgz
-# Source0-md5:	409b91678a842bb0ff56f2cf018b9160
-Patch0:		branch.diff
-URL:		http://pecl.php.net/package/ssh2/
+# Source0-md5:	e35f8438b3f6177066166c8c1916f44e
+URL:		https://pecl.php.net/package/ssh2
 BuildRequires:	%{php_name}-devel >= 4:5.0.4
 BuildRequires:	libssh2-devel >= 1.2.9
 BuildRequires:	openssl-devel >= 0.9.7d
@@ -25,18 +23,13 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 Provides bindings to the functions of libssh2 which implements the
 SSH2 protocol.
 
-In PECL status of this extension is: %{status}.
-
 %description -l pl.UTF-8
 Dostarcza dowiązań do różnych funkcji biblioteki libssh2
 implementującej protokół SSH2.
 
-To rozszerzenie ma w PECL status: %{status}.
-
 %prep
 %setup -qc
 mv %{modname}-%{version}/* .
-#%patch0 -p0
 
 %build
 phpize
diff --git a/branch.diff b/branch.diff
deleted file mode 100644
index 6375c0c..0000000
--- a/branch.diff
+++ /dev/null
@@ -1,19467 +0,0 @@
-Index: config.w32
-===================================================================
---- config.w32	(.../tags/RELEASE_0_11_0)
-+++ config.w32	(.../trunk)
-@@ -0,0 +1,37 @@
-+// $Id$
-+// vim:ft=javascript
-+
-+ARG_WITH("ssh2", "SSH2 support", "no");
-+
-+if (PHP_SSH2 != "no") {
-+	if ((((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib", "ssh2", PHP_SSH2) ||  CHECK_LIB("zlib.lib", "ssh2", PHP_SSH2))) || 
-+		(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "ssh2", PHP_SSH2)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED))) &&
-+		CHECK_LIB("libeay32.lib", "ssh2", PHP_SSH2) &&
-+		CHECK_LIB("ssleay32.lib", "ssh2", PHP_SSH2) &&
-+		CHECK_LIB("ws2_32.lib", "ssh2", PHP_SSH2)) {
-+
-+		// Use bundled lib if none installed, even if it is outdated.
-+		if (!(CHECK_LIB("libssh2_a.lib;libssh2.lib", "ssh2", PHP_SSH2) &&
-+				CHECK_HEADER_ADD_INCLUDE("libssh2.h", "CFLAGS_SSH2", PHP_PHP_BUILD + "\\include\\libssh2"))) {
-+			FSO.CopyFile(configure_module_dirname + "\\libssh2\\src\\libssh2_config.h.in.w32",
-+					configure_module_dirname + "\\libssh2\\src\\libssh2_config.h");
-+
-+			ADD_FLAG('CFLAGS_SSH2', '/DLIBSSH2_WIN32=1 /DLIBSSH2_API= /I ' + 
-+					configure_module_dirname + '/libssh2/include');
-+		}
-+
-+		AC_DEFINE('HAVE_SSH2LIB', 1);
-+		AC_DEFINE('PHP_SSH2_REMOTE_FORWARDING', 1);
-+		AC_DEFINE('PHP_SSH2_HOSTBASED_AUTH', 1);
-+		AC_DEFINE('PHP_SSH2_POLL', 1);
-+		AC_DEFINE('PHP_SSH2_PUBLICKEY_SUBSYSTEM', 1);
-+
-+		EXTENSION("ssh2", "ssh2.c ssh2_fopen_wrappers.c ssh2_sftp.c");
-+
-+		ADD_SOURCES(configure_module_dirname + "/libssh2/src", "channel.c comp.c crypt.c \
-+				hostkey.c kex.c mac.c misc.c openssl.c packet.c pem.c publickey.c scp.c \
-+				session.c sftp.c transport.c userauth.c", "ssh2");
-+	} else {
-+		WARNING("ssh2 not enabled: libraries or headers not found");
-+	}
-+}
-
-Property changes on: config.w32
-___________________________________________________________________
-Added: svn:eol-style
-   + native
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.11
-
-Index: ssh2.c
-===================================================================
---- ssh2.c	(.../tags/RELEASE_0_11_0)
-+++ ssh2.c	(.../trunk)
-@@ -47,14 +47,9 @@
- int le_ssh2_pkey_subsys;
- #endif
- 
--#ifdef ZEND_ENGINE_2
--static
--    ZEND_BEGIN_ARG_INFO(php_ssh2_first_arg_force_ref, 0)
--        ZEND_ARG_PASS_INFO(1)
--    ZEND_END_ARG_INFO()
--#else
--static unsigned char php_ssh2_first_arg_force_ref[] = { 1, BYREF_FORCE };
--#endif
-+ZEND_BEGIN_ARG_INFO(php_ssh2_first_arg_force_ref, 0)
-+    ZEND_ARG_PASS_INFO(1)
-+ZEND_END_ARG_INFO()
- 
- /* *************
-    * Callbacks *
-@@ -248,7 +243,7 @@
- /* {{{ php_ssh2_set_callback
-  * Try to set a method if it's passed in with the hash table
-  */
--static int php_ssh2_set_callback(LIBSSH2_SESSION *session, HashTable *ht, char *callback, int callback_len, int callback_type, php_ssh2_session_data *data)
-+static int php_ssh2_set_callback(LIBSSH2_SESSION *session, HashTable *ht, char *callback, int callback_len, int callback_type, php_ssh2_session_data *data TSRMLS_DC)
- {
- 	zval **handler, *copyval;
- 	void *internal_handler;
-@@ -257,7 +252,7 @@
- 		return 0;
- 	}
- 
--	if (!handler || !*handler || !zend_is_callable(*handler, 0, NULL)) {
-+	if (!handler || !*handler || !zend_is_callable(*handler, 0, NULL ZEND_IS_CALLABLE_TSRMLS_CC)) {
- 		return -1;
- 	}
- 
-@@ -358,7 +353,7 @@
- 	if (!session) {
- 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to initialize SSH2 session");
- 		efree(data);
--		close(socket);
-+		closesocket(socket);
- 		return NULL;
- 	}
- 	libssh2_banner_set(session, LIBSSH2_SSH_DEFAULT_BANNER " PHP");
-@@ -411,19 +406,19 @@
- 	if (callbacks) {
- 		/* ignore debug disconnect macerror */
- 
--		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "ignore", sizeof("ignore") - 1, LIBSSH2_CALLBACK_IGNORE, data)) {
-+		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "ignore", sizeof("ignore") - 1, LIBSSH2_CALLBACK_IGNORE, data TSRMLS_CC)) {
- 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed setting IGNORE callback");
- 		}
- 
--		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "debug", sizeof("debug") - 1, LIBSSH2_CALLBACK_DEBUG, data)) {
-+		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "debug", sizeof("debug") - 1, LIBSSH2_CALLBACK_DEBUG, data TSRMLS_CC)) {
- 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed setting DEBUG callback");
- 		}
- 
--		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "macerror", sizeof("macerror") - 1, LIBSSH2_CALLBACK_MACERROR, data)) {
-+		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "macerror", sizeof("macerror") - 1, LIBSSH2_CALLBACK_MACERROR, data TSRMLS_CC)) {
- 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed setting MACERROR callback");
- 		}
- 
--		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "disconnect", sizeof("disconnect") - 1, LIBSSH2_CALLBACK_DISCONNECT, data)) {
-+		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "disconnect", sizeof("disconnect") - 1, LIBSSH2_CALLBACK_DISCONNECT, data TSRMLS_CC)) {
- 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed setting DISCONNECT callback");
- 		}
- 	}
-@@ -434,7 +429,7 @@
- 
- 		last_error = libssh2_session_last_error(session, &error_msg, NULL, 0);
- 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error starting up SSH connection(%d): %s", last_error, error_msg);
--		close(socket);
-+		closesocket(socket);
- 		libssh2_session_free(session);
- 		efree(data);
- 		return NULL;
-@@ -1148,7 +1143,7 @@
- 			zval_ptr_dtor(&(*data)->disconnect_cb);
- 		}
- 
--		close((*data)->socket);
-+		closesocket((*data)->socket);
- 
- 		efree(*data);
- 		*data = NULL;
-@@ -1274,7 +1269,7 @@
- 
- /* {{{ ssh2_functions[]
-  */
--function_entry ssh2_functions[] = {
-+zend_function_entry ssh2_functions[] = {
- 	PHP_FE(ssh2_connect,						NULL)
- 	PHP_FE(ssh2_methods_negotiated,				NULL)
- 	PHP_FE(ssh2_fingerprint,					NULL)
-
-Property changes on: ssh2.c
-___________________________________________________________________
-Modified: cvs2svn:cvs-rev
-   - 1.22
-   + 1.25
-
-Index: libssh2/include/libssh2_publickey.h
-===================================================================
---- libssh2/include/libssh2_publickey.h	(.../tags/RELEASE_0_11_0)
-+++ libssh2/include/libssh2_publickey.h	(.../trunk)
-@@ -0,0 +1,101 @@
-+/* Copyright (c) 2004-2006, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+/* Note: This include file is only needed for using the
-+ * publickey SUBSYSTEM which is not the same as publickey
-+ * authentication.  For authentication you only need libssh2.h
-+ *
-+ * For more information on the publickey subsystem,
-+ * refer to IETF draft: secsh-publickey
-+ */
-+
-+#ifndef LIBSSH2_PUBLICKEY_H
-+#define LIBSSH2_PUBLICKEY_H 1
-+
-+typedef struct _LIBSSH2_PUBLICKEY               LIBSSH2_PUBLICKEY;
-+
-+typedef struct _libssh2_publickey_attribute {
-+    const char *name;
-+    unsigned long name_len;
-+    const char *value;
-+    unsigned long value_len;
-+    char mandatory;
-+} libssh2_publickey_attribute;
-+
-+typedef struct _libssh2_publickey_list {
-+    unsigned char *packet; /* For freeing */
-+
-+    const unsigned char *name;
-+    unsigned long name_len;
-+    const unsigned char *blob;
-+    unsigned long blob_len;
-+    unsigned long num_attrs;
-+    libssh2_publickey_attribute *attrs; /* free me */
-+} libssh2_publickey_list;
-+
-+/* Generally use the first macro here, but if both name and value are string literals, you can use _fast() to take advantage of preprocessing */
-+#define libssh2_publickey_attribute(name, value, mandatory)         { (name), strlen(name), (value), strlen(value), (mandatory) },
-+#define libssh2_publickey_attribute_fast(name, value, mandatory)    { (name), sizeof(name) - 1, (value), sizeof(value) - 1, (mandatory) },
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+/* Publickey Subsystem */
-+LIBSSH2_API LIBSSH2_PUBLICKEY *libssh2_publickey_init(LIBSSH2_SESSION *session);
-+
-+LIBSSH2_API int libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name, unsigned long name_len,
-+                                                            const unsigned char *blob, unsigned long blob_len, char overwrite,
-+                                                            unsigned long num_attrs, const libssh2_publickey_attribute attrs[]);
-+#define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, num_attrs, attrs) \
-+        libssh2_publickey_add_ex((pkey), (name), strlen(name), (blob), (blob_len), (overwrite), (num_attrs), (attrs))
-+
-+LIBSSH2_API int libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name, unsigned long name_len,
-+                                                            const unsigned char *blob, unsigned long blob_len);
-+#define libssh2_publickey_remove(pkey, name, blob, blob_len) \
-+        libssh2_publickey_remove_ex((pkey), (name), strlen(name), (blob), (blob_len))
-+
-+LIBSSH2_API int libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey, unsigned long *num_keys, libssh2_publickey_list **pkey_list);
-+LIBSSH2_API void libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey, libssh2_publickey_list *pkey_list);
-+
-+LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey);
-+
-+#ifdef __cplusplus
-+} /* extern "C" */
-+#endif
-+
-+#endif /* ndef: LIBSSH2_PUBLICKEY_H */
-
-Property changes on: libssh2/include/libssh2_publickey.h
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.2
-Added: svn:eol-style
-   + native
-
-Index: libssh2/include/libssh2_sftp.h
-===================================================================
---- libssh2/include/libssh2_sftp.h	(.../tags/RELEASE_0_11_0)
-+++ libssh2/include/libssh2_sftp.h	(.../trunk)
-@@ -0,0 +1,251 @@
-+/* Copyright (c) 2004-2008, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#ifndef LIBSSH2_SFTP_H
-+#define LIBSSH2_SFTP_H 1
-+
-+#ifndef WIN32
-+#include <unistd.h>
-+#endif
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+/* Note: Version 6 was documented at the time of writing
-+ * However it was marked as "DO NOT IMPLEMENT" due to pending changes
-+ *
-+ * Let's start with Version 3 (The version found in OpenSSH) and go from there
-+ */
-+#define LIBSSH2_SFTP_VERSION        3
-+#define LIBSSH2_SFTP_PACKET_MAXLEN  40000
-+
-+typedef struct _LIBSSH2_SFTP                LIBSSH2_SFTP;
-+typedef struct _LIBSSH2_SFTP_HANDLE         LIBSSH2_SFTP_HANDLE;
-+typedef struct _LIBSSH2_SFTP_ATTRIBUTES     LIBSSH2_SFTP_ATTRIBUTES;
-+
-+/* Flags for open_ex() */
-+#define LIBSSH2_SFTP_OPENFILE           0
-+#define LIBSSH2_SFTP_OPENDIR            1
-+
-+/* Flags for rename_ex() */
-+#define LIBSSH2_SFTP_RENAME_OVERWRITE   0x00000001
-+#define LIBSSH2_SFTP_RENAME_ATOMIC      0x00000002
-+#define LIBSSH2_SFTP_RENAME_NATIVE      0x00000004
-+
-+/* Flags for stat_ex() */
-+#define LIBSSH2_SFTP_STAT               0
-+#define LIBSSH2_SFTP_LSTAT              1
-+#define LIBSSH2_SFTP_SETSTAT            2
-+
-+/* Flags for symlink_ex() */
-+#define LIBSSH2_SFTP_SYMLINK            0
-+#define LIBSSH2_SFTP_READLINK           1
-+#define LIBSSH2_SFTP_REALPATH           2
-+
-+/* SFTP attribute flag bits */
-+#define LIBSSH2_SFTP_ATTR_SIZE              0x00000001
-+#define LIBSSH2_SFTP_ATTR_UIDGID            0x00000002
-+#define LIBSSH2_SFTP_ATTR_PERMISSIONS       0x00000004
-+#define LIBSSH2_SFTP_ATTR_ACMODTIME         0x00000008
-+#define LIBSSH2_SFTP_ATTR_EXTENDED          0x80000000
-+
-+struct _LIBSSH2_SFTP_ATTRIBUTES {
-+    /* If flags & ATTR_* bit is set, then the value in this struct will be meaningful
-+     * Otherwise it should be ignored
-+     */
-+    unsigned long flags;
-+
-+    libssh2_uint64_t filesize;
-+    unsigned long uid, gid;
-+    unsigned long permissions;
-+    unsigned long atime, mtime;
-+};
-+
-+/* SFTP filetypes */
-+#define LIBSSH2_SFTP_TYPE_REGULAR           1
-+#define LIBSSH2_SFTP_TYPE_DIRECTORY         2
-+#define LIBSSH2_SFTP_TYPE_SYMLINK           3
-+#define LIBSSH2_SFTP_TYPE_SPECIAL           4
-+#define LIBSSH2_SFTP_TYPE_UNKNOWN           5
-+#define LIBSSH2_SFTP_TYPE_SOCKET            6
-+#define LIBSSH2_SFTP_TYPE_CHAR_DEVICE       7
-+#define LIBSSH2_SFTP_TYPE_BLOCK_DEVICE      8
-+#define LIBSSH2_SFTP_TYPE_FIFO              9
-+
-+/*
-+ * Reproduce the POSIX file modes here for systems that are not
-+ * POSIX compliant.  
-+ *
-+ * These is used in "permissions" of "struct _LIBSSH2_SFTP_ATTRIBUTES"
-+ */
-+/* File type */
-+#define LIBSSH2_SFTP_S_IFMT         0170000     /* type of file mask */
-+#define LIBSSH2_SFTP_S_IFIFO        0010000     /* named pipe (fifo) */
-+#define LIBSSH2_SFTP_S_IFCHR        0020000     /* character special */
-+#define LIBSSH2_SFTP_S_IFDIR        0040000     /* directory */
-+#define LIBSSH2_SFTP_S_IFBLK        0060000     /* block special */
-+#define LIBSSH2_SFTP_S_IFREG        0100000     /* regular */
-+#define LIBSSH2_SFTP_S_IFLNK        0120000     /* symbolic link */
-+#define LIBSSH2_SFTP_S_IFSOCK       0140000     /* socket */
-+
-+/* File mode */
-+/* Read, write, execute/search by owner */
-+#define LIBSSH2_SFTP_S_IRWXU        0000700     /* RWX mask for owner */
-+#define LIBSSH2_SFTP_S_IRUSR        0000400     /* R for owner */
-+#define LIBSSH2_SFTP_S_IWUSR        0000200     /* W for owner */
-+#define LIBSSH2_SFTP_S_IXUSR        0000100     /* X for owner */
-+/* Read, write, execute/search by group */
-+#define LIBSSH2_SFTP_S_IRWXG        0000070     /* RWX mask for group */
-+#define LIBSSH2_SFTP_S_IRGRP        0000040     /* R for group */
-+#define LIBSSH2_SFTP_S_IWGRP        0000020     /* W for group */
-+#define LIBSSH2_SFTP_S_IXGRP        0000010     /* X for group */
-+/* Read, write, execute/search by others */
-+#define LIBSSH2_SFTP_S_IRWXO        0000007     /* RWX mask for other */
-+#define LIBSSH2_SFTP_S_IROTH        0000004     /* R for other */
-+#define LIBSSH2_SFTP_S_IWOTH        0000002     /* W for other */
-+#define LIBSSH2_SFTP_S_IXOTH        0000001     /* X for other */
-+
-+/* SFTP File Transfer Flags -- (e.g. flags parameter to sftp_open())
-+ * Danger will robinson... APPEND doesn't have any effect on OpenSSH servers */
-+#define LIBSSH2_FXF_READ                        0x00000001
-+#define LIBSSH2_FXF_WRITE                       0x00000002
-+#define LIBSSH2_FXF_APPEND                      0x00000004
-+#define LIBSSH2_FXF_CREAT                       0x00000008
-+#define LIBSSH2_FXF_TRUNC                       0x00000010
-+#define LIBSSH2_FXF_EXCL                        0x00000020
-+
-+/* SFTP Status Codes (returned by libssh2_sftp_last_error() ) */
-+#define LIBSSH2_FX_OK                       0
-+#define LIBSSH2_FX_EOF                      1
-+#define LIBSSH2_FX_NO_SUCH_FILE             2
-+#define LIBSSH2_FX_PERMISSION_DENIED        3
-+#define LIBSSH2_FX_FAILURE                  4
-+#define LIBSSH2_FX_BAD_MESSAGE              5
-+#define LIBSSH2_FX_NO_CONNECTION            6
-+#define LIBSSH2_FX_CONNECTION_LOST          7
-+#define LIBSSH2_FX_OP_UNSUPPORTED           8
-+#define LIBSSH2_FX_INVALID_HANDLE           9
-+#define LIBSSH2_FX_NO_SUCH_PATH             10
-+#define LIBSSH2_FX_FILE_ALREADY_EXISTS      11
-+#define LIBSSH2_FX_WRITE_PROTECT            12
-+#define LIBSSH2_FX_NO_MEDIA                 13
-+#define LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM   14
-+#define LIBSSH2_FX_QUOTA_EXCEEDED           15
-+#define LIBSSH2_FX_UNKNOWN_PRINCIPLE        16 /* Initial mis-spelling */
-+#define LIBSSH2_FX_UNKNOWN_PRINCIPAL        16
-+#define LIBSSH2_FX_LOCK_CONFlICT            17 /* Initial mis-spelling */
-+#define LIBSSH2_FX_LOCK_CONFLICT            17
-+#define LIBSSH2_FX_DIR_NOT_EMPTY            18
-+#define LIBSSH2_FX_NOT_A_DIRECTORY          19
-+#define LIBSSH2_FX_INVALID_FILENAME         20
-+#define LIBSSH2_FX_LINK_LOOP                21
-+
-+/* Returned by any function that would block during a read/write opperation */
-+#define LIBSSH2SFTP_EAGAIN LIBSSH2_ERROR_EAGAIN
-+
-+/* SFTP API */
-+LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session);
-+LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp);
-+LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp);
-+
-+/* File / Directory Ops */
-+LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, const char *filename, unsigned int filename_len,
-+                                                      unsigned long flags, long mode, int open_type);
-+#define libssh2_sftp_open(sftp, filename, flags, mode) \
-+                    libssh2_sftp_open_ex((sftp), (filename), strlen(filename), (flags), (mode), LIBSSH2_SFTP_OPENFILE)
-+#define libssh2_sftp_opendir(sftp, path) \
-+                    libssh2_sftp_open_ex((sftp), (path), strlen(path), 0, 0, LIBSSH2_SFTP_OPENDIR)
-+
-+LIBSSH2_API ssize_t libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxlen);
-+
-+LIBSSH2_API int libssh2_sftp_readdir_ex(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxlen, 
-+                                        char *longentry, size_t longentry_maxlen, 
-+                                        LIBSSH2_SFTP_ATTRIBUTES *attrs);
-+#define libssh2_sftp_readdir(handle, buffer, buffer_maxlen, attrs) \
-+                    libssh2_sftp_readdir_ex((handle), (buffer), (buffer_maxlen), NULL, 0, (attrs))
-+
-+LIBSSH2_API ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer, size_t count);
-+
-+LIBSSH2_API int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle);
-+#define libssh2_sftp_close(handle)                  libssh2_sftp_close_handle(handle)
-+#define libssh2_sftp_closedir(handle)               libssh2_sftp_close_handle(handle)
-+
-+LIBSSH2_API void libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset);
-+LIBSSH2_API void libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset);
-+#define libssh2_sftp_rewind(handle)         libssh2_sftp_seek64((handle), 0)
-+
-+LIBSSH2_API size_t libssh2_sftp_tell(LIBSSH2_SFTP_HANDLE *handle);
-+LIBSSH2_API libssh2_uint64_t libssh2_sftp_tell64(LIBSSH2_SFTP_HANDLE *handle);
-+
-+LIBSSH2_API int libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_ATTRIBUTES *attrs, int setstat);
-+#define libssh2_sftp_fstat(handle, attrs)               libssh2_sftp_fstat_ex((handle), (attrs), 0)
-+#define libssh2_sftp_fsetstat(handle, attrs)            libssh2_sftp_fstat_ex((handle), (attrs), 1)
-+
-+
-+
-+/* Miscellaneous Ops */
-+LIBSSH2_API int libssh2_sftp_rename_ex(LIBSSH2_SFTP *sftp,  const char *source_filename,    unsigned int srouce_filename_len,
-+                                                            const char *dest_filename,      unsigned int dest_filename_len,
-+                                                            long flags);
-+#define libssh2_sftp_rename(sftp, sourcefile, destfile)     libssh2_sftp_rename_ex((sftp), (sourcefile), strlen(sourcefile), (destfile), strlen(destfile), \
-+                                                            LIBSSH2_SFTP_RENAME_OVERWRITE | LIBSSH2_SFTP_RENAME_ATOMIC | LIBSSH2_SFTP_RENAME_NATIVE)
-+
-+LIBSSH2_API int libssh2_sftp_unlink_ex(LIBSSH2_SFTP *sftp, const char *filename, unsigned int filename_len);
-+#define libssh2_sftp_unlink(sftp, filename)                 libssh2_sftp_unlink_ex((sftp), (filename), strlen(filename))
-+
-+LIBSSH2_API int libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len, long mode);
-+#define libssh2_sftp_mkdir(sftp, path, mode)                libssh2_sftp_mkdir_ex((sftp), (path), strlen(path), (mode))
-+
-+LIBSSH2_API int libssh2_sftp_rmdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len);
-+#define libssh2_sftp_rmdir(sftp, path)                      libssh2_sftp_rmdir_ex((sftp), (path), strlen(path))
-+
-+LIBSSH2_API int libssh2_sftp_stat_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len, int stat_type, LIBSSH2_SFTP_ATTRIBUTES *attrs);
-+#define libssh2_sftp_stat(sftp, path, attrs)                libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_STAT, (attrs))
-+#define libssh2_sftp_lstat(sftp, path, attrs)               libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_LSTAT, (attrs))
-+#define libssh2_sftp_setstat(sftp, path, attrs)             libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_SETSTAT, (attrs))
-+
-+LIBSSH2_API int libssh2_sftp_symlink_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len, char *target, unsigned int target_len, int link_type);
-+#define libssh2_sftp_symlink(sftp, orig, linkpath)          libssh2_sftp_symlink_ex((sftp), (orig), strlen(orig), (linkpath), strlen(linkpath), LIBSSH2_SFTP_SYMLINK)
-+#define libssh2_sftp_readlink(sftp, path, target, maxlen)   libssh2_sftp_symlink_ex((sftp), (path), strlen(path), (target), (maxlen), LIBSSH2_SFTP_READLINK)
-+#define libssh2_sftp_realpath(sftp, path, target, maxlen)   libssh2_sftp_symlink_ex((sftp), (path), strlen(path), (target), (maxlen), LIBSSH2_SFTP_REALPATH)
-+
-+#ifdef __cplusplus
-+} /* extern "C" */
-+#endif
-+
-+#endif /* LIBSSH2_SFTP_H */
-
-Property changes on: libssh2/include/libssh2_sftp.h
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.2
-Added: svn:eol-style
-   + native
-
-Index: libssh2/include/libssh2.h
-===================================================================
---- libssh2/include/libssh2.h	(.../tags/RELEASE_0_11_0)
-+++ libssh2/include/libssh2.h	(.../trunk)
-@@ -0,0 +1,489 @@
-+/* Copyright (c) 2004-2008, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#ifndef LIBSSH2_H
-+#define LIBSSH2_H 1
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#include <stddef.h>
-+#include <string.h>
-+#include <sys/stat.h>
-+#include <sys/types.h>
-+
-+/* Allow alternate API prefix from CFLAGS or calling app */
-+#ifndef LIBSSH2_API
-+# ifdef LIBSSH2_WIN32
-+#  ifdef LIBSSH2_LIBRARY
-+#   define LIBSSH2_API __declspec(dllexport)
-+#  else
-+#   define LIBSSH2_API __declspec(dllimport)
-+#  endif /* LIBSSH2_LIBRARY */
-+# else /* !LIBSSH2_WIN32 */
-+#  define LIBSSH2_API
-+# endif /* LIBSSH2_WIN32 */
-+#endif /* LIBSSH2_API */
-+
-+#if defined(LIBSSH2_DARWIN) || (defined(LIBSSH2_WIN32) && !defined(_MSC_VER) && !defined(__MINGW32__))
-+# include <sys/uio.h>
-+#endif
-+
-+#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
-+# include <sys/bsdskt.h>
-+typedef unsigned int uint32_t;
-+#endif
-+
-+#if defined(LIBSSH2_WIN32) && defined(_MSC_VER) && (_MSC_VER <= 1400)
-+typedef unsigned __int64 libssh2_uint64_t;
-+typedef __int64 libssh2_int64_t;
-+typedef unsigned int uint32_t;
-+#ifndef _SSIZE_T_DEFINED
-+typedef int ssize_t;
-+#define _SSIZE_T_DEFINED
-+#endif
-+#else
-+typedef unsigned long long libssh2_uint64_t;
-+typedef long long libssh2_int64_t;
-+#endif
-+
-+/* We use underscore instead of dash when appending CVS in dev versions just
-+   to make the BANNER define (used by src/session.c) be a valid SSH
-+   banner. Release versions have no appended strings and may of coruse not
-+   have dashes either. */
-+#define LIBSSH2_VERSION "1.0"
-+
-+/* The numeric version number is also available "in parts" by using these
-+   defines: */
-+#define LIBSSH2_VERSION_MAJOR 1
-+#define LIBSSH2_VERSION_MINOR 0
-+#define LIBSSH2_VERSION_PATCH 
-+
-+/* This is the numeric version of the libssh2 version number, meant for easier
-+   parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will
-+   always follow this syntax:
-+
-+         0xXXYYZZ
-+
-+   Where XX, YY and ZZ are the main version, release and patch numbers in
-+   hexadecimal (using 8 bits each). All three numbers are always represented
-+   using two digits.  1.2 would appear as "0x010200" while version 9.11.7
-+   appears as "0x090b07".
-+
-+   This 6-digit (24 bits) hexadecimal number does not show pre-release number,
-+   and it is always a greater number in a more recent release. It makes
-+   comparisons with greater than and less than work.
-+*/
-+#define LIBSSH2_VERSION_NUM 0x010000
-+
-+/*
-+ * This is the date and time when the full source package was created. The
-+ * timestamp is not stored in CVS, as the timestamp is properly set in the
-+ * tarballs by the maketgz script.
-+ *
-+ * The format of the date should follow this template:
-+ *
-+ * "Mon Feb 12 11:35:33 UTC 2007"
-+ */
-+#define LIBSSH2_TIMESTAMP "Fri Dec 26 21:35:07 UTC 2008"
-+
-+/* Part of every banner, user specified or not */
-+#define LIBSSH2_SSH_BANNER                  "SSH-2.0-libssh2_" LIBSSH2_VERSION
-+
-+/* We *could* add a comment here if we so chose */
-+#define LIBSSH2_SSH_DEFAULT_BANNER                  LIBSSH2_SSH_BANNER
-+#define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF        LIBSSH2_SSH_DEFAULT_BANNER "\r\n"
-+
-+/* Default generate and safe prime sizes for diffie-hellman-group-exchange-sha1 */
-+#define LIBSSH2_DH_GEX_MINGROUP     1024
-+#define LIBSSH2_DH_GEX_OPTGROUP     1536
-+#define LIBSSH2_DH_GEX_MAXGROUP     2048
-+
-+/* Defaults for pty requests */
-+#define LIBSSH2_TERM_WIDTH      80
-+#define LIBSSH2_TERM_HEIGHT     24
-+#define LIBSSH2_TERM_WIDTH_PX   0
-+#define LIBSSH2_TERM_HEIGHT_PX  0
-+
-+/* 1/4 second */
-+#define LIBSSH2_SOCKET_POLL_UDELAY      250000
-+/* 0.25 * 120 == 30 seconds */
-+#define LIBSSH2_SOCKET_POLL_MAXLOOPS    120
-+
-+/* Maximum size to allow a payload to compress to, plays it safe by falling short of spec limits */
-+#define LIBSSH2_PACKET_MAXCOMP      32000
-+
-+/* Maximum size to allow a payload to deccompress to, plays it safe by allowing more than spec requires */
-+#define LIBSSH2_PACKET_MAXDECOMP    40000
-+
-+/* Maximum size for an inbound compressed payload, plays it safe by overshooting spec limits */
-+#define LIBSSH2_PACKET_MAXPAYLOAD   40000
-+
-+/* Malloc callbacks */
-+#define LIBSSH2_ALLOC_FUNC(name)                    void *name(size_t count, void **abstract)
-+#define LIBSSH2_REALLOC_FUNC(name)                  void *name(void *ptr, size_t count, void **abstract)
-+#define LIBSSH2_FREE_FUNC(name)                     void name(void *ptr, void **abstract)
-+
-+typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT
-+{
-+    char* text;
-+    unsigned int length;
-+    unsigned char echo;
-+} LIBSSH2_USERAUTH_KBDINT_PROMPT;
-+
-+typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
-+{
-+    char* text;
-+    unsigned int length;
-+} LIBSSH2_USERAUTH_KBDINT_RESPONSE;
-+
-+/* 'keyboard-interactive' authentication callback */
-+#define LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(name_) void name_(const char* name, int name_len, const char* instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract)
-+
-+/* Callbacks for special SSH packets */
-+#define LIBSSH2_IGNORE_FUNC(name)                   void name(LIBSSH2_SESSION *session, const char *message, int message_len, void **abstract)
-+#define LIBSSH2_DEBUG_FUNC(name)                    void name(LIBSSH2_SESSION *session, int always_display, const char *message, int message_len, const char *language, int language_len,void **abstract)
-+#define LIBSSH2_DISCONNECT_FUNC(name)               void name(LIBSSH2_SESSION *session, int reason, const char *message, int message_len, const char *language, int language_len, void **abstract)
-+#define LIBSSH2_PASSWD_CHANGEREQ_FUNC(name)         void name(LIBSSH2_SESSION *session, char **newpw, int *newpw_len, void **abstract)
-+#define LIBSSH2_MACERROR_FUNC(name)                 int  name(LIBSSH2_SESSION *session, const char *packet, int packet_len, void **abstract)
-+#define LIBSSH2_X11_OPEN_FUNC(name)                 void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, const char *shost, int sport, void **abstract)
-+
-+#define LIBSSH2_CHANNEL_CLOSE_FUNC(name)            void name(LIBSSH2_SESSION *session, void **session_abstract, LIBSSH2_CHANNEL *channel, void **channel_abstract)
-+
-+/* libssh2_session_callback_set() constants */
-+#define LIBSSH2_CALLBACK_IGNORE             0
-+#define LIBSSH2_CALLBACK_DEBUG              1
-+#define LIBSSH2_CALLBACK_DISCONNECT         2
-+#define LIBSSH2_CALLBACK_MACERROR           3
-+#define LIBSSH2_CALLBACK_X11                4
-+
-+/* libssh2_session_method_pref() constants */
-+#define LIBSSH2_METHOD_KEX          0
-+#define LIBSSH2_METHOD_HOSTKEY      1
-+#define LIBSSH2_METHOD_CRYPT_CS     2
-+#define LIBSSH2_METHOD_CRYPT_SC     3
-+#define LIBSSH2_METHOD_MAC_CS       4
-+#define LIBSSH2_METHOD_MAC_SC       5
-+#define LIBSSH2_METHOD_COMP_CS      6
-+#define LIBSSH2_METHOD_COMP_SC      7
-+#define LIBSSH2_METHOD_LANG_CS      8
-+#define LIBSSH2_METHOD_LANG_SC      9
-+
-+/* session.flags bits */
-+#define LIBSSH2_FLAG_SIGPIPE        0x00000001
-+
-+typedef struct _LIBSSH2_SESSION                     LIBSSH2_SESSION;
-+typedef struct _LIBSSH2_CHANNEL                     LIBSSH2_CHANNEL;
-+typedef struct _LIBSSH2_LISTENER                    LIBSSH2_LISTENER;
-+
-+typedef struct _LIBSSH2_POLLFD {
-+    unsigned char type; /* LIBSSH2_POLLFD_* below */
-+
-+    union {
-+        int socket; /* File descriptors -- examined with system select() call */
-+        LIBSSH2_CHANNEL *channel; /* Examined by checking internal state */
-+        LIBSSH2_LISTENER *listener; /* Read polls only -- are inbound connections waiting to be accepted? */
-+    } fd;
-+
-+    unsigned long events; /* Requested Events */
-+    unsigned long revents; /* Returned Events */
-+} LIBSSH2_POLLFD;
-+
-+/* Poll FD Descriptor Types */
-+#define LIBSSH2_POLLFD_SOCKET       1
-+#define LIBSSH2_POLLFD_CHANNEL      2
-+#define LIBSSH2_POLLFD_LISTENER     3
-+
-+/* Note: Win32 Doesn't actually have a poll() implementation, so some of these values are faked with select() data */
-+/* Poll FD events/revents -- Match sys/poll.h where possible */
-+#define LIBSSH2_POLLFD_POLLIN           0x0001      /* Data available to be read or connection available -- All */
-+#define LIBSSH2_POLLFD_POLLPRI          0x0002      /* Priority data available to be read -- Socket only */
-+#define LIBSSH2_POLLFD_POLLEXT          0x0002      /* Extended data available to be read -- Channel only */
-+#define LIBSSH2_POLLFD_POLLOUT          0x0004      /* Can may be written -- Socket/Channel */
-+/* revents only */
-+#define LIBSSH2_POLLFD_POLLERR          0x0008      /* Error Condition -- Socket */
-+#define LIBSSH2_POLLFD_POLLHUP          0x0010      /* HangUp/EOF -- Socket */
-+#define LIBSSH2_POLLFD_SESSION_CLOSED   0x0010      /* Session Disconnect */
-+#define LIBSSH2_POLLFD_POLLNVAL         0x0020      /* Invalid request -- Socket Only */
-+#define LIBSSH2_POLLFD_POLLEX           0x0040      /* Exception Condition -- Socket/Win32 */
-+#define LIBSSH2_POLLFD_CHANNEL_CLOSED   0x0080      /* Channel Disconnect */
-+#define LIBSSH2_POLLFD_LISTENER_CLOSED  0x0080      /* Listener Disconnect */
-+
-+#define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
-+/* Block Direction Types */
-+#define LIBSSH2_SESSION_BLOCK_INBOUND                  0x0001
-+#define LIBSSH2_SESSION_BLOCK_OUTBOUND                 0x0002
-+
-+/* Hash Types */
-+#define LIBSSH2_HOSTKEY_HASH_MD5                            1
-+#define LIBSSH2_HOSTKEY_HASH_SHA1                           2
-+
-+/* Disconnect Codes (defined by SSH protocol) */
-+#define SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT          1
-+#define SSH_DISCONNECT_PROTOCOL_ERROR                       2
-+#define SSH_DISCONNECT_KEY_EXCHANGE_FAILED                  3
-+#define SSH_DISCONNECT_RESERVED                             4
-+#define SSH_DISCONNECT_MAC_ERROR                            5
-+#define SSH_DISCONNECT_COMPRESSION_ERROR                    6
-+#define SSH_DISCONNECT_SERVICE_NOT_AVAILABLE                7
-+#define SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED       8
-+#define SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE              9
-+#define SSH_DISCONNECT_CONNECTION_LOST                      10
-+#define SSH_DISCONNECT_BY_APPLICATION                       11
-+#define SSH_DISCONNECT_TOO_MANY_CONNECTIONS                 12
-+#define SSH_DISCONNECT_AUTH_CANCELLED_BY_USER               13
-+#define SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE       14
-+#define SSH_DISCONNECT_ILLEGAL_USER_NAME                    15
-+
-+/* Error Codes (defined by libssh2) */
-+#define LIBSSH2_ERROR_NONE                      0
-+#define LIBSSH2_ERROR_SOCKET_NONE               -1
-+#define LIBSSH2_ERROR_BANNER_NONE               -2
-+#define LIBSSH2_ERROR_BANNER_SEND               -3
-+#define LIBSSH2_ERROR_INVALID_MAC               -4
-+#define LIBSSH2_ERROR_KEX_FAILURE               -5
-+#define LIBSSH2_ERROR_ALLOC                     -6
-+#define LIBSSH2_ERROR_SOCKET_SEND               -7
-+#define LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE      -8
-+#define LIBSSH2_ERROR_TIMEOUT                   -9
-+#define LIBSSH2_ERROR_HOSTKEY_INIT              -10
-+#define LIBSSH2_ERROR_HOSTKEY_SIGN              -11
-+#define LIBSSH2_ERROR_DECRYPT                   -12
-+#define LIBSSH2_ERROR_SOCKET_DISCONNECT         -13
-+#define LIBSSH2_ERROR_PROTO                     -14
-+#define LIBSSH2_ERROR_PASSWORD_EXPIRED          -15
-+#define LIBSSH2_ERROR_FILE                      -16
-+#define LIBSSH2_ERROR_METHOD_NONE               -17
-+#define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED    -18
-+#define LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED      -19
-+#define LIBSSH2_ERROR_CHANNEL_OUTOFORDER        -20
-+#define LIBSSH2_ERROR_CHANNEL_FAILURE           -21
-+#define LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED    -22
-+#define LIBSSH2_ERROR_CHANNEL_UNKNOWN           -23
-+#define LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED   -24
-+#define LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED   -25
-+#define LIBSSH2_ERROR_CHANNEL_CLOSED            -26
-+#define LIBSSH2_ERROR_CHANNEL_EOF_SENT          -27
-+#define LIBSSH2_ERROR_SCP_PROTOCOL              -28
-+#define LIBSSH2_ERROR_ZLIB                      -29
-+#define LIBSSH2_ERROR_SOCKET_TIMEOUT            -30
-+#define LIBSSH2_ERROR_SFTP_PROTOCOL             -31
-+#define LIBSSH2_ERROR_REQUEST_DENIED            -32
-+#define LIBSSH2_ERROR_METHOD_NOT_SUPPORTED      -33
-+#define LIBSSH2_ERROR_INVAL                     -34
-+#define LIBSSH2_ERROR_INVALID_POLL_TYPE         -35
-+#define LIBSSH2_ERROR_PUBLICKEY_PROTOCOL        -36
-+#define LIBSSH2_ERROR_EAGAIN                    -37
-+
-+/* Session API */
-+LIBSSH2_API LIBSSH2_SESSION *libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)), LIBSSH2_FREE_FUNC((*my_free)), LIBSSH2_REALLOC_FUNC((*my_realloc)), void *abstract);
-+#define libssh2_session_init()                      libssh2_session_init_ex(NULL, NULL, NULL, NULL)
-+LIBSSH2_API void **libssh2_session_abstract(LIBSSH2_SESSION *session);
-+
-+LIBSSH2_API void *libssh2_session_callback_set(LIBSSH2_SESSION *session, int cbtype, void *callback);
-+LIBSSH2_API int libssh2_banner_set(LIBSSH2_SESSION *session, const char *banner);
-+
-+LIBSSH2_API int libssh2_session_startup(LIBSSH2_SESSION *session, int sock);
-+LIBSSH2_API int libssh2_session_disconnect_ex(LIBSSH2_SESSION *session, int reason, const char *description, const char *lang);
-+#define libssh2_session_disconnect(session, description)    libssh2_session_disconnect_ex((session), SSH_DISCONNECT_BY_APPLICATION, (description), "")
-+LIBSSH2_API int libssh2_session_free(LIBSSH2_SESSION *session);
-+
-+LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type);
-+
-+LIBSSH2_API int libssh2_session_method_pref(LIBSSH2_SESSION *session, int method_type, const char *prefs);
-+LIBSSH2_API const char *libssh2_session_methods(LIBSSH2_SESSION *session, int method_type);
-+LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session, char **errmsg, int *errmsg_len, int want_buf);
-+LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session);
-+LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session);
-+
-+LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag, int value);
-+
-+/* Userauth API */
-+LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session, const char *username, unsigned int username_len);
-+LIBSSH2_API int libssh2_userauth_authenticated(LIBSSH2_SESSION *session);
-+LIBSSH2_API int libssh2_userauth_password_ex(LIBSSH2_SESSION *session, const char *username, unsigned int username_len, const char *password, unsigned int password_len, LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
-+#define libssh2_userauth_password(session, username, password)  libssh2_userauth_password_ex((session), (username), strlen(username), (password), strlen(password), NULL)
-+
-+LIBSSH2_API int libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session, const char *username, unsigned int username_len,
-+                                                                                 const char *publickey, const char *privatekey,
-+                                                                                 const char *passphrase);
-+#define libssh2_userauth_publickey_fromfile(session, username, publickey, privatekey, passphrase)   \
-+        libssh2_userauth_publickey_fromfile_ex((session), (username), strlen(username), (publickey), (privatekey), (passphrase))
-+LIBSSH2_API int libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION *session, const char *username, unsigned int username_len,
-+                                                                                 const char *publickey, const char *privatekey,
-+                                                                                 const char *passphrase,
-+                                                                                 const char *hostname, unsigned int hostname_len,
-+                                                                                 const char *local_username, unsigned int local_username_len);
-+#define libssh2_userauth_hostbased_fromfile(session, username, publickey, privatekey, passphrase, hostname) \
-+        libssh2_userauth_hostbased_fromfile_ex((session), (username), strlen(username), (publickey), (privatekey), (passphrase), (hostname), strlen(hostname), (username), strlen(username))
-+
-+/*
-+ * response_callback is provided with filled by library prompts array,
-+ * but client must allocate and fill individual responses. Responses
-+ * array is already allocated. Responses data will be freed by libssh2
-+ * after callback return, but before subsequent callback invokation.
-+ */
-+LIBSSH2_API int libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION* session, const char *username, unsigned int username_len,
-+                                                         LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback)));
-+#define libssh2_userauth_keyboard_interactive(session, username, response_callback) \
-+        libssh2_userauth_keyboard_interactive_ex((session), (username), strlen(username), (response_callback))
-+
-+LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds, long timeout);
-+
-+/* Channel API */
-+#define LIBSSH2_CHANNEL_WINDOW_DEFAULT  65536
-+#define LIBSSH2_CHANNEL_PACKET_DEFAULT  16384
-+#define LIBSSH2_CHANNEL_MINADJUST       1024
-+
-+/* Extended Data Handling */
-+#define LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL        0
-+#define LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE        1
-+#define LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE         2
-+
-+#define SSH_EXTENDED_DATA_STDERR 1
-+
-+/* Returned by any function that would block during a read/write opperation */
-+#define LIBSSH2CHANNEL_EAGAIN LIBSSH2_ERROR_EAGAIN
-+
-+LIBSSH2_API LIBSSH2_CHANNEL *libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type, unsigned int channel_type_len, unsigned int window_size, unsigned int packet_size, const char *message, unsigned int message_len);
-+#define libssh2_channel_open_session(session)   libssh2_channel_open_ex((session), "session", sizeof("session") - 1, LIBSSH2_CHANNEL_WINDOW_DEFAULT, LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0)
-+
-+LIBSSH2_API LIBSSH2_CHANNEL *libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host, int port, const char *shost, int sport);
-+#define libssh2_channel_direct_tcpip(session, host, port)   libssh2_channel_direct_tcpip_ex((session), (host), (port), "127.0.0.1", 22)
-+
-+LIBSSH2_API LIBSSH2_LISTENER *libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host, int port, int *bound_port, int queue_maxsize);
-+#define libssh2_channel_forward_listen(session, port)           libssh2_channel_forward_listen_ex((session), NULL, (port), NULL, 16)
-+
-+LIBSSH2_API int libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener);
-+
-+LIBSSH2_API LIBSSH2_CHANNEL *libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener);
-+
-+LIBSSH2_API int libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel, const char *varname, unsigned int varname_len, const char *value, unsigned int value_len);
-+#define libssh2_channel_setenv(channel, varname, value) libssh2_channel_setenv_ex((channel), (varname), strlen(varname), (value), strlen(value))
-+
-+LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel, const char *term, unsigned int term_len, const char *modes, unsigned int modes_len, int width, int height, int width_px, int height_px);
-+#define libssh2_channel_request_pty(channel, term)  libssh2_channel_request_pty_ex((channel), (term), strlen(term), NULL, 0, LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX)
-+
-+LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL * channel, int width, int height, int width_px, int height_px);
-+#define libssh2_channel_request_pty_size(channel, width, height) libssh2_channel_request_pty_size_ex( (channel), (width), (height), 0, 0)
-+
-+LIBSSH2_API int libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, int single_connection, const char *auth_proto, const char *auth_cookie, int screen_number);
-+#define libssh2_channel_x11_req(channel, screen_number) libssh2_channel_x11_req_ex((channel), 0, NULL, NULL, (screen_number))
-+
-+LIBSSH2_API int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, const char *request, unsigned int request_len, const char *message, unsigned int message_len);
-+#define libssh2_channel_shell(channel)                  libssh2_channel_process_startup((channel), "shell", sizeof("shell") - 1, NULL, 0)
-+#define libssh2_channel_exec(channel, command)          libssh2_channel_process_startup((channel), "exec", sizeof("exec") - 1, (command), strlen(command))
-+#define libssh2_channel_subsystem(channel, subsystem)   libssh2_channel_process_startup((channel), "subsystem", sizeof("subsystem") - 1, (subsystem), strlen(subsystem))
-+
-+LIBSSH2_API ssize_t libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel, int stream_id, char *buf, size_t buflen);
-+#define libssh2_channel_read(channel, buf, buflen) \
-+                                libssh2_channel_read_ex((channel), 0, (buf), (buflen))
-+#define libssh2_channel_read_stderr(channel, buf, buflen) \
-+                                libssh2_channel_read_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
-+
-+LIBSSH2_API int libssh2_poll_channel_read(LIBSSH2_CHANNEL *channel, int extended);
-+
-+LIBSSH2_API unsigned long libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel, unsigned long *read_avail, unsigned long *window_size_initial);
-+#define libssh2_channel_window_read(channel) \
-+            libssh2_channel_window_read_ex((channel), NULL, NULL)
-+
-+LIBSSH2_API unsigned long libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL *channel, unsigned long adjustment, unsigned char force);
-+
-+LIBSSH2_API ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel, int stream_id, const char *buf, size_t buflen);
-+
-+#define libssh2_channel_write(channel, buf, buflen) \
-+                                libssh2_channel_write_ex((channel), 0, (buf), (buflen))
-+#define libssh2_channel_write_stderr(channel, buf, buflen)  \
-+                                libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
-+
-+LIBSSH2_API unsigned long libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel, unsigned long *window_size_initial);
-+#define libssh2_channel_window_write(channel)           libssh2_channel_window_write_ex((channel), NULL)
-+
-+LIBSSH2_API void libssh2_session_set_blocking(LIBSSH2_SESSION* session, int blocking);
-+LIBSSH2_API int libssh2_session_get_blocking(LIBSSH2_SESSION* session);
-+
-+LIBSSH2_API void libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel, int blocking);
-+
-+LIBSSH2_API void libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
-+LIBSSH2_API int libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel, int ignore_mode);
-+/* libssh2_channel_ignore_extended_data() is defined below for BC with version 0.1
-+ * Future uses should use libssh2_channel_handle_extended_data() directly
-+ * if LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE is passed, extended data will be read (FIFO) from the standard data channel
-+ */
-+/* DEPRECATED */
-+#define libssh2_channel_ignore_extended_data(channel, ignore)       libssh2_channel_handle_extended_data((channel), (ignore) ? LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE : LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL )
-+
-+#define LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA     -1
-+#define LIBSSH2_CHANNEL_FLUSH_ALL               -2
-+LIBSSH2_API int libssh2_channel_flush_ex(LIBSSH2_CHANNEL *channel, int streamid);
-+#define libssh2_channel_flush(channel)          libssh2_channel_flush_ex((channel), 0)
-+#define libssh2_channel_flush_stderr(channel)   libssh2_channel_flush_ex((channel), SSH_EXTENDED_DATA_STDERR)
-+LIBSSH2_API int libssh2_channel_get_exit_status(LIBSSH2_CHANNEL* channel);
-+
-+LIBSSH2_API int libssh2_channel_send_eof(LIBSSH2_CHANNEL *channel);
-+LIBSSH2_API int libssh2_channel_eof(LIBSSH2_CHANNEL *channel);
-+LIBSSH2_API int libssh2_channel_wait_eof(LIBSSH2_CHANNEL *channel);
-+LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel);
-+LIBSSH2_API int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
-+LIBSSH2_API int libssh2_channel_free(LIBSSH2_CHANNEL *channel);
-+
-+LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);
-+LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, const char *path, int mode, size_t size, long mtime, long atime);
-+#define libssh2_scp_send(session, path, mode, size)                 libssh2_scp_send_ex((session), (path), (mode), (size), 0, 0)
-+
-+LIBSSH2_API int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest, unsigned int *dest_len, const char *src, unsigned int src_len);
-+
-+/* NOTE NOTE NOTE
-+   libssh2_trace() has no function in builds that aren't built with debug
-+   enabled
-+ */
-+LIBSSH2_API int libssh2_trace(LIBSSH2_SESSION *session, int bitmask);
-+#define LIBSSH2_TRACE_TRANS (1<<1)
-+#define LIBSSH2_TRACE_KEX   (1<<2)
-+#define LIBSSH2_TRACE_AUTH  (1<<3)
-+#define LIBSSH2_TRACE_CONN  (1<<4)
-+#define LIBSSH2_TRACE_SCP   (1<<5)
-+#define LIBSSH2_TRACE_SFTP  (1<<6)
-+#define LIBSSH2_TRACE_ERROR (1<<7)
-+#define LIBSSH2_TRACE_PUBLICKEY (1<<8)
-+
-+#ifdef __cplusplus
-+} /* extern "C" */
-+#endif
-+
-+#endif /* LIBSSH2_H */
-
-Property changes on: libssh2/include/libssh2.h
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.3
-Added: svn:eol-style
-   + native
-
-Index: libssh2/src/comp.c
-===================================================================
---- libssh2/src/comp.c	(.../tags/RELEASE_0_11_0)
-+++ libssh2/src/comp.c	(.../trunk)
-@@ -0,0 +1,340 @@
-+/* Copyright (c) 2004-2007, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#include "libssh2_priv.h"
-+#ifdef LIBSSH2_HAVE_ZLIB
-+# include <zlib.h>
-+#endif
-+
-+/* ********
-+   * none *
-+   ******** */
-+
-+/* {{{ libssh2_comp_method_none_comp
-+ * Minimalist compression: Absolutely none
-+ */
-+static int
-+libssh2_comp_method_none_comp(LIBSSH2_SESSION * session,
-+                              int compress,
-+                              unsigned char **dest,
-+                              unsigned long *dest_len,
-+                              unsigned long payload_limit,
-+                              int *free_dest,
-+                              const unsigned char *src,
-+                              unsigned long src_len, void **abstract)
-+{
-+    (void) session;
-+    (void) compress;
-+    (void) payload_limit;
-+    (void) abstract;
-+    *dest = (unsigned char *) src;
-+    *dest_len = src_len;
-+
-+    *free_dest = 0;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_COMP_METHOD libssh2_comp_method_none = {
-+    "none",
-+    NULL,
-+    libssh2_comp_method_none_comp,
-+    NULL
-+};
-+
-+#ifdef LIBSSH2_HAVE_ZLIB
-+/* ********
-+   * zlib *
-+   ******** */
-+
-+/* {{{ Memory management wrappers
-+ * Yes, I realize we're doing a callback to a callback,
-+ * Deal...
-+ */
-+
-+static voidpf
-+libssh2_comp_method_zlib_alloc(voidpf opaque, uInt items, uInt size)
-+{
-+    LIBSSH2_SESSION *session = (LIBSSH2_SESSION *) opaque;
-+
-+    return (voidpf) LIBSSH2_ALLOC(session, items * size);
-+}
-+
-+static void
-+libssh2_comp_method_zlib_free(voidpf opaque, voidpf address)
-+{
-+    LIBSSH2_SESSION *session = (LIBSSH2_SESSION *) opaque;
-+
-+    LIBSSH2_FREE(session, address);
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_comp_method_zlib_init
-+ * All your bandwidth are belong to us (so save some)
-+ */
-+static int
-+libssh2_comp_method_zlib_init(LIBSSH2_SESSION * session, int compress,
-+                              void **abstract)
-+{
-+    z_stream *strm;
-+    int status;
-+
-+    strm = LIBSSH2_ALLOC(session, sizeof(z_stream));
-+    if (!strm) {
-+        libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                      "Unable to allocate memory for zlib compression/decompression",
-+                      0);
-+        return -1;
-+    }
-+    memset(strm, 0, sizeof(z_stream));
-+
-+    strm->opaque = (voidpf) session;
-+    strm->zalloc = (alloc_func) libssh2_comp_method_zlib_alloc;
-+    strm->zfree = (free_func) libssh2_comp_method_zlib_free;
-+    if (compress) {
-+        /* deflate */
-+        status = deflateInit(strm, Z_DEFAULT_COMPRESSION);
-+    } else {
-+        /* inflate */
-+        status = inflateInit(strm);
-+    }
-+
-+    if (status != Z_OK) {
-+        LIBSSH2_FREE(session, strm);
-+        return -1;
-+    }
-+    *abstract = strm;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_comp_method_zlib_comp
-+ * zlib, a compression standard for all occasions
-+ */
-+static int
-+libssh2_comp_method_zlib_comp(LIBSSH2_SESSION * session,
-+                              int compress,
-+                              unsigned char **dest,
-+                              unsigned long *dest_len,
-+                              unsigned long payload_limit,
-+                              int *free_dest,
-+                              const unsigned char *src,
-+                              unsigned long src_len, void **abstract)
-+{
-+    z_stream *strm = *abstract;
-+    /* A short-term alloc of a full data chunk is better than a series of
-+       reallocs */
-+    char *out;
-+    int out_maxlen = compress ? (src_len + 4) : (2 * src_len);
-+    int limiter = 0;
-+
-+    /* In practice they never come smaller than this */
-+    if (out_maxlen < 25) {
-+        out_maxlen = 25;
-+    }
-+
-+    if (out_maxlen > (int) payload_limit) {
-+        out_maxlen = payload_limit;
-+    }
-+
-+    strm->next_in = (unsigned char *) src;
-+    strm->avail_in = src_len;
-+    strm->next_out = (unsigned char *) LIBSSH2_ALLOC(session, out_maxlen);
-+    out = (char *) strm->next_out;
-+    strm->avail_out = out_maxlen;
-+    if (!strm->next_out) {
-+        libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                      "Unable to allocate compression/decompression buffer",
-+                      0);
-+        return -1;
-+    }
-+    while (strm->avail_in) {
-+        int status;
-+
-+        if (compress) {
-+            status = deflate(strm, Z_PARTIAL_FLUSH);
-+        } else {
-+            status = inflate(strm, Z_PARTIAL_FLUSH);
-+        }
-+        if (status != Z_OK) {
-+            libssh2_error(session, LIBSSH2_ERROR_ZLIB,
-+                          "compress/decompression failure", 0);
-+            LIBSSH2_FREE(session, out);
-+            return -1;
-+        }
-+        if (strm->avail_in) {
-+            unsigned long out_ofs = out_maxlen - strm->avail_out;
-+            char *newout;
-+
-+            out_maxlen +=
-+                compress ? (strm->avail_in + 4) : (2 * strm->avail_in);
-+
-+            if ((out_maxlen > (int) payload_limit) && !compress && limiter++) {
-+                libssh2_error(session, LIBSSH2_ERROR_ZLIB,
-+                              "Excessive growth in decompression phase", 0);
-+                LIBSSH2_FREE(session, out);
-+                return -1;
-+            }
-+
-+            newout = LIBSSH2_REALLOC(session, out, out_maxlen);
-+            if (!newout) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to expand compress/decompression buffer",
-+                              0);
-+                LIBSSH2_FREE(session, out);
-+                return -1;
-+            }
-+            out = newout;
-+            strm->next_out = (unsigned char *) out + out_ofs;
-+            strm->avail_out +=
-+                compress ? (strm->avail_in + 4) : (2 * strm->avail_in);
-+        } else
-+            while (!strm->avail_out) {
-+                /* Done with input, might be a byte or two in internal buffer during compress
-+                 * Or potentially many bytes if it's a decompress
-+                 */
-+                int grow_size = compress ? 8 : 1024;
-+                char *newout;
-+
-+                if (out_maxlen >= (int) payload_limit) {
-+                    libssh2_error(session, LIBSSH2_ERROR_ZLIB,
-+                                  "Excessive growth in decompression phase",
-+                                  0);
-+                    LIBSSH2_FREE(session, out);
-+                    return -1;
-+                }
-+
-+                if (grow_size > (int) (payload_limit - out_maxlen)) {
-+                    grow_size = payload_limit - out_maxlen;
-+                }
-+
-+                out_maxlen += grow_size;
-+                strm->avail_out = grow_size;
-+
-+                newout = LIBSSH2_REALLOC(session, out, out_maxlen);
-+                if (!newout) {
-+                    libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                                  "Unable to expand final compress/decompress buffer",
-+                                  0);
-+                    LIBSSH2_FREE(session, out);
-+                    return -1;
-+                }
-+                out = newout;
-+                strm->next_out = (unsigned char *) out + out_maxlen -
-+                    grow_size;
-+
-+                if (compress) {
-+                    status = deflate(strm, Z_PARTIAL_FLUSH);
-+                } else {
-+                    status = inflate(strm, Z_PARTIAL_FLUSH);
-+                }
-+                if (status != Z_OK) {
-+                    libssh2_error(session, LIBSSH2_ERROR_ZLIB,
-+                                  "compress/decompression failure", 0);
-+                    LIBSSH2_FREE(session, out);
-+                    return -1;
-+                }
-+            }
-+    }
-+
-+    *dest = (unsigned char *) out;
-+    *dest_len = out_maxlen - strm->avail_out;
-+    *free_dest = 1;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_comp_method_zlib_dtor
-+ * All done, no more compression for you
-+ */
-+static int
-+libssh2_comp_method_zlib_dtor(LIBSSH2_SESSION * session, int compress,
-+                              void **abstract)
-+{
-+    z_stream *strm = *abstract;
-+
-+    if (strm) {
-+        if (compress) {
-+            /* deflate */
-+            deflateEnd(strm);
-+        } else {
-+            /* inflate */
-+            inflateEnd(strm);
-+        }
-+
-+        LIBSSH2_FREE(session, strm);
-+    }
-+
-+    *abstract = NULL;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_COMP_METHOD libssh2_comp_method_zlib = {
-+    "zlib",
-+    libssh2_comp_method_zlib_init,
-+    libssh2_comp_method_zlib_comp,
-+    libssh2_comp_method_zlib_dtor,
-+};
-+#endif /* LIBSSH2_HAVE_ZLIB */
-+
-+/* ***********************
-+   * Compression Methods *
-+   *********************** */
-+
-+static const LIBSSH2_COMP_METHOD *_libssh2_comp_methods[] = {
-+    &libssh2_comp_method_none,
-+#ifdef LIBSSH2_HAVE_ZLIB
-+    &libssh2_comp_method_zlib,
-+#endif /* LIBSSH2_HAVE_ZLIB */
-+    NULL
-+};
-+
-+const LIBSSH2_COMP_METHOD **
-+libssh2_comp_methods(void)
-+{
-+    return _libssh2_comp_methods;
-+}
-
-Property changes on: libssh2/src/comp.c
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.2
-Added: svn:eol-style
-   + native
-
-Index: libssh2/src/libgcrypt.c
-===================================================================
---- libssh2/src/libgcrypt.c	(.../tags/RELEASE_0_11_0)
-+++ libssh2/src/libgcrypt.c	(.../trunk)
-@@ -0,0 +1,560 @@
-+/* Copyright (C) 2006, 2007, The Written Word, Inc.
-+ * Copyright (C) 2008, Simon Josefsson
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#include "libssh2_priv.h"
-+#include <string.h>
-+
-+int
-+_libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
-+                 const unsigned char *edata,
-+                 unsigned long elen,
-+                 const unsigned char *ndata,
-+                 unsigned long nlen,
-+                 const unsigned char *ddata,
-+                 unsigned long dlen,
-+                 const unsigned char *pdata,
-+                 unsigned long plen,
-+                 const unsigned char *qdata,
-+                 unsigned long qlen,
-+                 const unsigned char *e1data,
-+                 unsigned long e1len,
-+                 const unsigned char *e2data,
-+                 unsigned long e2len,
-+                 const unsigned char *coeffdata, unsigned long coefflen)
-+{
-+    int rc;
-+    (void) e1data;
-+    (void) e1len;
-+    (void) e2data;
-+    (void) e2len;
-+
-+    if (ddata) {
-+        rc = gcry_sexp_build
-+            (rsa, NULL,
-+             "(private-key(rsa(n%b)(e%b)(d%b)(q%b)(p%b)(u%b)))",
-+             nlen, ndata, elen, edata, dlen, ddata, plen, pdata,
-+             qlen, qdata, coefflen, coeffdata);
-+    } else {
-+        rc = gcry_sexp_build(rsa, NULL, "(public-key(rsa(n%b)(e%b)))",
-+                             nlen, ndata, elen, edata);
-+    }
-+    if (rc) {
-+        *rsa = NULL;
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+int
-+_libssh2_rsa_sha1_verify(libssh2_rsa_ctx * rsa,
-+                         const unsigned char *sig,
-+                         unsigned long sig_len,
-+                         const unsigned char *m, unsigned long m_len)
-+{
-+    unsigned char hash[SHA_DIGEST_LENGTH];
-+    gcry_sexp_t s_sig, s_hash;
-+    int rc = -1;
-+
-+    libssh2_sha1(m, m_len, hash);
-+
-+    rc = gcry_sexp_build(&s_hash, NULL,
-+                         "(data (flags pkcs1) (hash sha1 %b))",
-+                         SHA_DIGEST_LENGTH, hash);
-+    if (rc != 0) {
-+        return -1;
-+    }
-+
-+    rc = gcry_sexp_build(&s_sig, NULL, "(sig-val(rsa(s %b)))", sig_len, sig);
-+    if (rc != 0) {
-+        gcry_sexp_release(s_hash);
-+        return -1;
-+    }
-+
-+    rc = gcry_pk_verify(s_sig, s_hash, rsa);
-+    gcry_sexp_release(s_sig);
-+    gcry_sexp_release(s_hash);
-+
-+    return (rc == 0) ? 0 : -1;
-+}
-+
-+int
-+_libssh2_dsa_new(libssh2_dsa_ctx ** dsactx,
-+                 const unsigned char *p,
-+                 unsigned long p_len,
-+                 const unsigned char *q,
-+                 unsigned long q_len,
-+                 const unsigned char *g,
-+                 unsigned long g_len,
-+                 const unsigned char *y,
-+                 unsigned long y_len,
-+                 const unsigned char *x, unsigned long x_len)
-+{
-+    int rc;
-+
-+    if (x_len) {
-+        rc = gcry_sexp_build
-+            (dsactx, NULL,
-+             "(private-key(dsa(p%b)(q%b)(g%b)(y%b)(x%b)))",
-+             p_len, p, q_len, q, g_len, g, y_len, y, x_len, x);
-+    } else {
-+        rc = gcry_sexp_build(dsactx, NULL,
-+                             "(public-key(dsa(p%b)(q%b)(g%b)(y%b)))",
-+                             p_len, p, q_len, q, g_len, g, y_len, y);
-+    }
-+
-+    if (rc) {
-+        *dsactx = NULL;
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+int
-+_libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
-+                         LIBSSH2_SESSION * session,
-+                         FILE * fp, unsigned const char *passphrase)
-+{
-+    unsigned char *data, *save_data;
-+    unsigned int datalen;
-+    int ret;
-+    unsigned char *n, *e, *d, *p, *q, *e1, *e2, *coeff;
-+    unsigned int nlen, elen, dlen, plen, qlen, e1len, e2len, coefflen;
-+
-+    (void) passphrase;
-+
-+    ret = _libssh2_pem_parse(session,
-+                             "-----BEGIN RSA PRIVATE KEY-----",
-+                             "-----END RSA PRIVATE KEY-----",
-+                             fp, &data, &datalen);
-+    if (ret) {
-+        return -1;
-+    }
-+
-+    save_data = data;
-+
-+    if (_libssh2_pem_decode_sequence(&data, &datalen)) {
-+        ret = -1;
-+        goto fail;
-+    }
-+/* First read Version field (should be 0). */
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &n, &nlen);
-+    if (ret != 0 || (nlen != 1 && *n != '\0')) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &n, &nlen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &e, &elen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &d, &dlen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &q, &qlen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &e1, &e1len);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &e2, &e2len);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &coeff, &coefflen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    if (_libssh2_rsa_new(rsa, e, elen, n, nlen, d, dlen, p, plen,
-+                         q, qlen, e1, e1len, e2, e2len, coeff, coefflen)) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = 0;
-+
-+  fail:
-+    LIBSSH2_FREE(session, save_data);
-+    return ret;
-+}
-+
-+int
-+_libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
-+                         LIBSSH2_SESSION * session,
-+                         FILE * fp, unsigned const char *passphrase)
-+{
-+    unsigned char *data, *save_data;
-+    unsigned int datalen;
-+    int ret;
-+    unsigned char *p, *q, *g, *y, *x;
-+    unsigned int plen, qlen, glen, ylen, xlen;
-+
-+    (void) passphrase;
-+
-+    ret = _libssh2_pem_parse(session,
-+                             "-----BEGIN DSA PRIVATE KEY-----",
-+                             "-----END DSA PRIVATE KEY-----",
-+                             fp, &data, &datalen);
-+    if (ret) {
-+        return -1;
-+    }
-+
-+    save_data = data;
-+
-+    if (_libssh2_pem_decode_sequence(&data, &datalen)) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+/* First read Version field (should be 0). */
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
-+    if (ret != 0 || (plen != 1 && *p != '\0')) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &q, &qlen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &g, &glen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &y, &ylen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = _libssh2_pem_decode_integer(&data, &datalen, &x, &xlen);
-+    if (ret != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    if (datalen != 0) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    if (_libssh2_dsa_new(dsa, p, plen, q, qlen, g, glen, y, ylen, x, xlen)) {
-+        ret = -1;
-+        goto fail;
-+    }
-+
-+    ret = 0;
-+
-+  fail:
-+    LIBSSH2_FREE(session, save_data);
-+    return ret;
-+}
-+
-+int
-+_libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session,
-+                       libssh2_dsa_ctx * rsactx,
-+                       const unsigned char *hash,
-+                       unsigned long hash_len,
-+                       unsigned char **signature, unsigned long *signature_len)
-+{
-+    gcry_sexp_t sig_sexp;
-+    gcry_sexp_t data;
-+    int rc;
-+    const char *tmp;
-+    size_t size;
-+
-+    if (hash_len != SHA_DIGEST_LENGTH) {
-+        return -1;
-+    }
-+
-+    if (gcry_sexp_build(&data, NULL,
-+                        "(data (flags pkcs1) (hash sha1 %b))",
-+                        hash_len, hash)) {
-+        return -1;
-+    }
-+
-+    rc = gcry_pk_sign(&sig_sexp, data, rsactx);
-+
-+    gcry_sexp_release(data);
-+
-+    if (rc != 0) {
-+        return -1;
-+    }
-+
-+    data = gcry_sexp_find_token(sig_sexp, "s", 0);
-+    if (!data) {
-+        return -1;
-+    }
-+
-+    tmp = gcry_sexp_nth_data(data, 1, &size);
-+    if (!tmp) {
-+        return -1;
-+    }
-+
-+    if (tmp[0] == '\0') {
-+        tmp++;
-+        size--;
-+    }
-+
-+    *signature = LIBSSH2_ALLOC(session, size);
-+    memcpy(*signature, tmp, size);
-+    *signature_len = size;
-+
-+    return rc;
-+}
-+
-+int
-+_libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
-+                       const unsigned char *hash,
-+                       unsigned long hash_len, unsigned char *sig)
-+{
-+    unsigned char zhash[SHA_DIGEST_LENGTH + 1];
-+    gcry_sexp_t sig_sexp;
-+    gcry_sexp_t data;
-+    int ret;
-+    const char *tmp;
-+    size_t size;
-+
-+    if (hash_len != SHA_DIGEST_LENGTH) {
-+        return -1;
-+    }
-+
-+    memcpy(zhash + 1, hash, hash_len);
-+    zhash[0] = 0;
-+
-+    if (gcry_sexp_build(&data, NULL, "(data (value %b))", hash_len + 1, zhash)) {
-+        return -1;
-+    }
-+
-+    ret = gcry_pk_sign(&sig_sexp, data, dsactx);
-+
-+    gcry_sexp_release(data);
-+
-+    if (ret != 0) {
-+        return -1;
-+    }
-+
-+/* Extract R. */
-+
-+    data = gcry_sexp_find_token(sig_sexp, "r", 0);
-+    if (!data) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    tmp = gcry_sexp_nth_data(data, 1, &size);
-+    if (!tmp) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    if (tmp[0] == '\0') {
-+        tmp++;
-+        size--;
-+    }
-+
-+    if (size != 20) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    memcpy(sig, tmp, 20);
-+
-+    gcry_sexp_release(data);
-+
-+/* Extract S. */
-+
-+    data = gcry_sexp_find_token(sig_sexp, "s", 0);
-+    if (!data) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    tmp = gcry_sexp_nth_data(data, 1, &size);
-+    if (!tmp) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    if (tmp[0] == '\0') {
-+        tmp++;
-+        size--;
-+    }
-+
-+    if (size != 20) {
-+        ret = -1;
-+        goto out;
-+    }
-+
-+    memcpy(sig + 20, tmp, 20);
-+
-+    ret = 0;
-+  out:
-+    if (sig_sexp) {
-+        gcry_sexp_release(sig_sexp);
-+    }
-+    if (data) {
-+        gcry_sexp_release(data);
-+    }
-+    return ret;
-+}
-+
-+int
-+_libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
-+                         const unsigned char *sig,
-+                         const unsigned char *m, unsigned long m_len)
-+{
-+    unsigned char hash[SHA_DIGEST_LENGTH + 1];
-+    gcry_sexp_t s_sig, s_hash;
-+    int rc = -1;
-+
-+    libssh2_sha1(m, m_len, hash + 1);
-+    hash[0] = 0;
-+
-+    if (gcry_sexp_build(&s_hash, NULL, "(data(flags raw)(value %b))",
-+                        SHA_DIGEST_LENGTH + 1, hash)) {
-+        return -1;
-+    }
-+
-+    if (gcry_sexp_build(&s_sig, NULL, "(sig-val(dsa(r %b)(s %b)))",
-+                        20, sig, 20, sig + 20)) {
-+        gcry_sexp_release(s_hash);
-+        return -1;
-+    }
-+
-+    rc = gcry_pk_verify(s_sig, s_hash, dsactx);
-+    gcry_sexp_release(s_sig);
-+    gcry_sexp_release(s_hash);
-+
-+    return (rc == 0) ? 0 : -1;
-+}
-+
-+int
-+_libssh2_cipher_init(_libssh2_cipher_ctx * h,
-+                     _libssh2_cipher_type(algo),
-+                     unsigned char *iv, unsigned char *secret, int encrypt)
-+{
-+    int mode = 0, ret;
-+    int keylen = gcry_cipher_get_algo_keylen(algo);
-+
-+    (void) encrypt;
-+
-+    if (algo != GCRY_CIPHER_ARCFOUR) {
-+        mode = GCRY_CIPHER_MODE_CBC;
-+    }
-+
-+    ret = gcry_cipher_open(h, algo, mode, 0);
-+    if (ret) {
-+        return -1;
-+    }
-+
-+    ret = gcry_cipher_setkey(*h, secret, keylen);
-+    if (ret) {
-+        gcry_cipher_close(*h);
-+        return -1;
-+    }
-+
-+    if (algo != GCRY_CIPHER_ARCFOUR) {
-+        int blklen = gcry_cipher_get_algo_blklen(algo);
-+        ret = gcry_cipher_setiv(*h, iv, blklen);
-+        if (ret) {
-+            gcry_cipher_close(*h);
-+            return -1;
-+        }
-+    }
-+
-+    return 0;
-+}
-+
-+int
-+_libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
-+                      _libssh2_cipher_type(algo),
-+                      int encrypt, unsigned char *block)
-+{
-+    size_t blklen = gcry_cipher_get_algo_blklen(algo);
-+    int ret;
-+    if (blklen == 1) {
-+/* Hack for arcfour. */
-+        blklen = 8;
-+    }
-+
-+    if (encrypt) {
-+        ret = gcry_cipher_encrypt(*ctx, block, blklen, block, blklen);
-+    } else {
-+        ret = gcry_cipher_decrypt(*ctx, block, blklen, block, blklen);
-+    }
-+    return ret;
-+}
-
-Property changes on: libssh2/src/libgcrypt.c
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.1
-Added: svn:eol-style
-   + native
-Added: svn:executable
-   + *
-
-Index: libssh2/src/userauth.c
-===================================================================
---- libssh2/src/userauth.c	(.../tags/RELEASE_0_11_0)
-+++ libssh2/src/userauth.c	(.../trunk)
-@@ -0,0 +1,1473 @@
-+/* Copyright (c) 2004-2007, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#include "libssh2_priv.h"
-+
-+#include <ctype.h>
-+#include <stdio.h>
-+
-+/* Needed for struct iovec on some platforms */
-+#ifdef HAVE_SYS_UIO_H
-+#include <sys/uio.h>
-+#endif
-+
-+
-+/* {{{ proto libssh2_userauth_list
-+ * List authentication methods
-+ * Will yield successful login if "none" happens to be allowable for this user
-+ * Not a common configuration for any SSH server though
-+ * username should be NULL, or a null terminated string
-+ */
-+LIBSSH2_API char *
-+libssh2_userauth_list(LIBSSH2_SESSION * session, const char *username,
-+                      unsigned int username_len)
-+{
-+    static const unsigned char reply_codes[3] =
-+        { SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE, 0 };
-+    /* packet_type(1) + username_len(4) + service_len(4) +
-+       service(14)"ssh-connection" + method_len(4) + method(4)"none" */
-+    unsigned long methods_len;
-+    unsigned char *s;
-+    int rc;
-+
-+    if (session->userauth_list_state == libssh2_NB_state_idle) {
-+        /* Zero the whole thing out */
-+        memset(&session->userauth_list_packet_requirev_state, 0,
-+               sizeof(session->userauth_list_packet_requirev_state));
-+
-+        session->userauth_list_data_len = username_len + 31;
-+
-+        s = session->userauth_list_data =
-+            LIBSSH2_ALLOC(session, session->userauth_list_data_len);
-+        if (!session->userauth_list_data) {
-+            libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                          "Unable to allocate memory for userauth_list", 0);
-+            return NULL;
-+        }
-+
-+        *(s++) = SSH_MSG_USERAUTH_REQUEST;
-+        libssh2_htonu32(s, username_len);
-+        s += 4;
-+        if (username) {
-+            memcpy(s, username, username_len);
-+            s += username_len;
-+        }
-+
-+        libssh2_htonu32(s, 14);
-+        s += 4;
-+        memcpy(s, "ssh-connection", 14);
-+        s += 14;
-+
-+        libssh2_htonu32(s, 4);
-+        s += 4;
-+        memcpy(s, "none", 4);
-+        s += 4;
-+
-+        session->userauth_list_state = libssh2_NB_state_created;
-+    }
-+
-+    if (session->userauth_list_state == libssh2_NB_state_created) {
-+        rc = libssh2_packet_write(session, session->userauth_list_data,
-+                                  session->userauth_list_data_len);
-+        if (rc == PACKET_EAGAIN) {
-+            libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
-+                          "Would block requesting userauth list", 0);
-+            return NULL;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send userauth-none request", 0);
-+            LIBSSH2_FREE(session, session->userauth_list_data);
-+            session->userauth_list_data = NULL;
-+            session->userauth_list_state = libssh2_NB_state_idle;
-+            return NULL;
-+        }
-+        LIBSSH2_FREE(session, session->userauth_list_data);
-+        session->userauth_list_data = NULL;
-+
-+        session->userauth_list_state = libssh2_NB_state_sent;
-+    }
-+
-+    if (session->userauth_list_state == libssh2_NB_state_sent) {
-+        rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                        &session->userauth_list_data,
-+                                        &session->userauth_list_data_len, 0,
-+                                        NULL, 0,
-+                                        &session->
-+                                        userauth_list_packet_requirev_state);
-+        if (rc == PACKET_EAGAIN) {
-+            libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
-+                          "Would block requesting userauth list", 0);
-+            return NULL;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_NONE, "No error", 0);
-+            session->userauth_list_state = libssh2_NB_state_idle;
-+            return NULL;
-+        }
-+
-+        if (session->userauth_list_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+            /* Wow, who'dve thought... */
-+            libssh2_error(session, LIBSSH2_ERROR_NONE, "No error", 0);
-+            LIBSSH2_FREE(session, session->userauth_list_data);
-+            session->userauth_list_data = NULL;
-+            session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+            session->userauth_list_state = libssh2_NB_state_idle;
-+            return NULL;
-+        }
-+
-+        methods_len = libssh2_ntohu32(session->userauth_list_data + 1);
-+
-+        /* Do note that the memory areas overlap! */
-+        memmove(session->userauth_list_data, session->userauth_list_data + 5,
-+               methods_len);
-+        session->userauth_list_data[methods_len] = '\0';
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Permitted auth methods: %s",
-+                       session->userauth_list_data);
-+    }
-+
-+    session->userauth_list_state = libssh2_NB_state_idle;
-+    return (char *) session->userauth_list_data;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_userauth_authenticated
-+ * 0 if not yet authenticated
-+ * non-zero is already authenticated
-+ */
-+LIBSSH2_API int
-+libssh2_userauth_authenticated(LIBSSH2_SESSION * session)
-+{
-+    return session->state & LIBSSH2_STATE_AUTHENTICATED;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_userauth_password
-+ * Plain ol' login
-+ */
-+LIBSSH2_API int
-+libssh2_userauth_password_ex(LIBSSH2_SESSION * session, const char *username,
-+                             unsigned int username_len, const char *password,
-+                             unsigned int password_len,
-+                             LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)))
-+{
-+    unsigned char *s;
-+    static const unsigned char reply_codes[4] =
-+        { SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE,
-+        SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, 0
-+    };
-+    int rc;
-+
-+    if (session->userauth_pswd_state == libssh2_NB_state_idle) {
-+        /* Zero the whole thing out */
-+        memset(&session->userauth_pswd_packet_requirev_state, 0,
-+               sizeof(session->userauth_pswd_packet_requirev_state));
-+
-+        /*
-+         * 40 = acket_type(1) + username_len(4) + service_len(4) + 
-+         * service(14)"ssh-connection" + method_len(4) + method(8)"password" +
-+         * chgpwdbool(1) + password_len(4) */
-+        session->userauth_pswd_data_len = username_len + password_len + 40;
-+
-+        session->userauth_pswd_data0 = ~SSH_MSG_USERAUTH_PASSWD_CHANGEREQ;
-+
-+        s = session->userauth_pswd_data =
-+            LIBSSH2_ALLOC(session, session->userauth_pswd_data_len);
-+        if (!session->userauth_pswd_data) {
-+            libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                          "Unable to allocate memory for userauth-password request",
-+                          0);
-+            return -1;
-+        }
-+
-+        *(s++) = SSH_MSG_USERAUTH_REQUEST;
-+        libssh2_htonu32(s, username_len);
-+        s += 4;
-+        memcpy(s, username, username_len);
-+        s += username_len;
-+
-+        libssh2_htonu32(s, sizeof("ssh-connection") - 1);
-+        s += 4;
-+        memcpy(s, "ssh-connection", sizeof("ssh-connection") - 1);
-+        s += sizeof("ssh-connection") - 1;
-+
-+        libssh2_htonu32(s, sizeof("password") - 1);
-+        s += 4;
-+        memcpy(s, "password", sizeof("password") - 1);
-+        s += sizeof("password") - 1;
-+
-+        *s = '\0';
-+        s++;
-+
-+        libssh2_htonu32(s, password_len);
-+        s += 4;
-+        memcpy(s, password, password_len);
-+        s += password_len;
-+
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Attempting to login using password authentication");
-+
-+        session->userauth_pswd_state = libssh2_NB_state_created;
-+    }
-+
-+    if (session->userauth_pswd_state == libssh2_NB_state_created) {
-+        rc = libssh2_packet_write(session, session->userauth_pswd_data,
-+                                  session->userauth_pswd_data_len);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send userauth-password request", 0);
-+            LIBSSH2_FREE(session, session->userauth_pswd_data);
-+            session->userauth_pswd_data = NULL;
-+            session->userauth_pswd_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+        LIBSSH2_FREE(session, session->userauth_pswd_data);
-+        session->userauth_pswd_data = NULL;
-+
-+        session->userauth_pswd_state = libssh2_NB_state_sent;
-+    }
-+
-+  password_response:
-+
-+    if ((session->userauth_pswd_state == libssh2_NB_state_sent)
-+        || (session->userauth_pswd_state == libssh2_NB_state_sent1)
-+        || (session->userauth_pswd_state == libssh2_NB_state_sent2)) {
-+        if (session->userauth_pswd_state == libssh2_NB_state_sent) {
-+            rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                            &session->userauth_pswd_data,
-+                                            &session->userauth_pswd_data_len,
-+                                            0, NULL, 0,
-+                                            &session->
-+                                            userauth_pswd_packet_requirev_state);
-+            if (rc == PACKET_EAGAIN) {
-+                return PACKET_EAGAIN;
-+            } else if (rc) {
-+                session->userauth_pswd_state = libssh2_NB_state_idle;
-+                return -1;
-+            }
-+
-+            if (session->userauth_pswd_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+                _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                               "Password authentication successful");
-+                LIBSSH2_FREE(session, session->userauth_pswd_data);
-+                session->userauth_pswd_data = NULL;
-+                session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+                session->userauth_pswd_state = libssh2_NB_state_idle;
-+                return 0;
-+            }
-+
-+            session->userauth_pswd_newpw = NULL;
-+            session->userauth_pswd_newpw_len = 0;
-+
-+            session->userauth_pswd_state = libssh2_NB_state_sent1;
-+        }
-+
-+        if ((session->userauth_pswd_data[0] ==
-+             SSH_MSG_USERAUTH_PASSWD_CHANGEREQ)
-+            || (session->userauth_pswd_data0 ==
-+                SSH_MSG_USERAUTH_PASSWD_CHANGEREQ)) {
-+            session->userauth_pswd_data0 = SSH_MSG_USERAUTH_PASSWD_CHANGEREQ;
-+
-+            if ((session->userauth_pswd_state == libssh2_NB_state_sent1) ||
-+                (session->userauth_pswd_state == libssh2_NB_state_sent2)) {
-+                if (session->userauth_pswd_state == libssh2_NB_state_sent1) {
-+                    _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                                   "Password change required");
-+                    LIBSSH2_FREE(session, session->userauth_pswd_data);
-+                    session->userauth_pswd_data = NULL;
-+                }
-+                if (passwd_change_cb) {
-+                    if (session->userauth_pswd_state == libssh2_NB_state_sent1) {
-+                        passwd_change_cb(session,
-+                                         &session->userauth_pswd_newpw,
-+                                         &session->userauth_pswd_newpw_len,
-+                                         &session->abstract);
-+                        if (!session->userauth_pswd_newpw) {
-+                            libssh2_error(session,
-+                                          LIBSSH2_ERROR_PASSWORD_EXPIRED,
-+                                          "Password expired, and callback failed",
-+                                          0);
-+                            return -1;
-+                        }
-+
-+                        /* basic data_len + newpw_len(4) */
-+                        session->userauth_pswd_data_len =
-+                            username_len + password_len + 44 +
-+                            session->userauth_pswd_newpw_len;
-+
-+                        s = session->userauth_pswd_data =
-+                            LIBSSH2_ALLOC(session,
-+                                          session->userauth_pswd_data_len);
-+                        if (!session->userauth_pswd_data) {
-+                            libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                                          "Unable to allocate memory for userauth-password-change request",
-+                                          0);
-+                            LIBSSH2_FREE(session,
-+                                         session->userauth_pswd_newpw);
-+                            session->userauth_pswd_newpw = NULL;
-+                            return -1;
-+                        }
-+
-+                        *(s++) = SSH_MSG_USERAUTH_REQUEST;
-+                        libssh2_htonu32(s, username_len);
-+                        s += 4;
-+                        memcpy(s, username, username_len);
-+                        s += username_len;
-+
-+                        libssh2_htonu32(s, sizeof("ssh-connection") - 1);
-+                        s += 4;
-+                        memcpy(s, "ssh-connection",
-+                               sizeof("ssh-connection") - 1);
-+                        s += sizeof("ssh-connection") - 1;
-+
-+                        libssh2_htonu32(s, sizeof("password") - 1);
-+                        s += 4;
-+                        memcpy(s, "password", sizeof("password") - 1);
-+                        s += sizeof("password") - 1;
-+
-+                        *s = 0x01;
-+                        s++;
-+
-+                        libssh2_htonu32(s, password_len);
-+                        s += 4;
-+                        memcpy(s, password, password_len);
-+                        s += password_len;
-+
-+                        libssh2_htonu32(s, session->userauth_pswd_newpw_len);
-+                        s += 4;
-+                        memcpy(s, session->userauth_pswd_newpw,
-+                               session->userauth_pswd_newpw_len);
-+                        s += session->userauth_pswd_newpw_len;
-+
-+                        session->userauth_pswd_state = libssh2_NB_state_sent2;
-+                    }
-+
-+                    if (session->userauth_pswd_state == libssh2_NB_state_sent2) {
-+                        rc = libssh2_packet_write(session,
-+                                                  session->userauth_pswd_data,
-+                                                  session->
-+                                                  userauth_pswd_data_len);
-+                        if (rc == PACKET_EAGAIN) {
-+                            return PACKET_EAGAIN;
-+                        } else if (rc) {
-+                            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                                          "Unable to send userauth-password-change request",
-+                                          0);
-+                            LIBSSH2_FREE(session, session->userauth_pswd_data);
-+                            session->userauth_pswd_data = NULL;
-+                            LIBSSH2_FREE(session,
-+                                         session->userauth_pswd_newpw);
-+                            session->userauth_pswd_newpw = NULL;
-+                            return -1;
-+                        }
-+                        LIBSSH2_FREE(session, session->userauth_pswd_data);
-+                        session->userauth_pswd_data = NULL;
-+                        LIBSSH2_FREE(session, session->userauth_pswd_newpw);
-+                        session->userauth_pswd_newpw = NULL;
-+
-+                        /*
-+                         * Ugliest use of goto ever.  Blame it on the
-+                         * askN => requirev migration.
-+                         */
-+                        session->userauth_pswd_state = libssh2_NB_state_sent;
-+                        goto password_response;
-+                    }
-+                }
-+            } else {
-+                libssh2_error(session, LIBSSH2_ERROR_PASSWORD_EXPIRED,
-+                              "Password Expired, and no callback specified",
-+                              0);
-+                session->userauth_pswd_state = libssh2_NB_state_idle;
-+                return -1;
-+            }
-+        }
-+    }
-+
-+    /* FAILURE */
-+    LIBSSH2_FREE(session, session->userauth_pswd_data);
-+    session->userauth_pswd_data = NULL;
-+    session->userauth_pswd_state = libssh2_NB_state_idle;
-+    return -1;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_file_read_publickey
-+ * Read a public key from an id_???.pub style file
-+ */
-+static int
-+libssh2_file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
-+                            unsigned long *method_len,
-+                            unsigned char **pubkeydata,
-+                            unsigned long *pubkeydata_len,
-+                            const char *pubkeyfile)
-+{
-+    FILE *fd;
-+    char c;
-+    unsigned char *pubkey = NULL, *sp1, *sp2, *tmp;
-+    size_t pubkey_len = 0;
-+    unsigned int tmp_len;
-+
-+    _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Loading public key file: %s",
-+                   pubkeyfile);
-+    /* Read Public Key */
-+    fd = fopen(pubkeyfile, "r");
-+    if (!fd) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE,
-+                      "Unable to open public key file", 0);
-+        return -1;
-+    }
-+    while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n')
-+        pubkey_len++;
-+    if (feof(fd)) {
-+        /* the last character was EOF */
-+        pubkey_len--;
-+    }
-+    rewind(fd);
-+
-+    if (pubkey_len <= 1) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE,
-+                      "Invalid data in public key file", 0);
-+        fclose(fd);
-+        return -1;
-+    }
-+
-+    pubkey = LIBSSH2_ALLOC(session, pubkey_len);
-+    if (!pubkey) {
-+        libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                      "Unable to allocate memory for public key data", 0);
-+        fclose(fd);
-+        return -1;
-+    }
-+    if (fread(pubkey, 1, pubkey_len, fd) != pubkey_len) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE,
-+                      "Unable to read public key from file", 0);
-+        LIBSSH2_FREE(session, pubkey);
-+        fclose(fd);
-+        return -1;
-+    }
-+    fclose(fd);
-+    /*
-+     * Remove trailing whitespace
-+     */
-+    while (pubkey_len && isspace(pubkey[pubkey_len - 1]))
-+        pubkey_len--;
-+
-+    if (!pubkey_len) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE, "Missing public key data",
-+                      0);
-+        LIBSSH2_FREE(session, pubkey);
-+        return -1;
-+    }
-+
-+    if ((sp1 = memchr(pubkey, ' ', pubkey_len)) == NULL) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE, "Invalid public key data",
-+                      0);
-+        LIBSSH2_FREE(session, pubkey);
-+        return -1;
-+    }
-+    /* Wasting some bytes here (okay, more than some),
-+     * but since it's likely to be freed soon anyway, 
-+     * we'll just avoid the extra free/alloc and call it a wash */
-+    *method = pubkey;
-+    *method_len = sp1 - pubkey;
-+
-+    sp1++;
-+
-+    if ((sp2 = memchr(sp1, ' ', pubkey_len - *method_len)) == NULL) {
-+        /* Assume that the id string is missing, but that it's okay */
-+        sp2 = pubkey + pubkey_len;
-+    }
-+
-+    if (libssh2_base64_decode
-+        (session, (char **) &tmp, &tmp_len, (char *) sp1, sp2 - sp1)) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE,
-+                      "Invalid key data, not base64 encoded", 0);
-+        LIBSSH2_FREE(session, pubkey);
-+        return -1;
-+    }
-+    *pubkeydata = tmp;
-+    *pubkeydata_len = tmp_len;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_file_read_privatekey
-+ * Read a PEM encoded private key from an id_??? style file
-+ */
-+static int
-+libssh2_file_read_privatekey(LIBSSH2_SESSION * session,
-+                             const LIBSSH2_HOSTKEY_METHOD ** hostkey_method,
-+                             void **hostkey_abstract,
-+                             const unsigned char *method, int method_len,
-+                             const char *privkeyfile, const char *passphrase)
-+{
-+    const LIBSSH2_HOSTKEY_METHOD **hostkey_methods_avail =
-+        libssh2_hostkey_methods();
-+
-+    _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Loading private key file: %s",
-+                   privkeyfile);
-+    *hostkey_method = NULL;
-+    *hostkey_abstract = NULL;
-+    while (*hostkey_methods_avail && (*hostkey_methods_avail)->name) {
-+        if ((*hostkey_methods_avail)->initPEM
-+            && strncmp((*hostkey_methods_avail)->name, (const char *) method,
-+                       method_len) == 0) {
-+            *hostkey_method = *hostkey_methods_avail;
-+            break;
-+        }
-+        hostkey_methods_avail++;
-+    }
-+    if (!*hostkey_method) {
-+        libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
-+                      "No handler for specified private key", 0);
-+        return -1;
-+    }
-+
-+    if ((*hostkey_method)->
-+        initPEM(session, privkeyfile, (unsigned char *) passphrase,
-+                hostkey_abstract)) {
-+        libssh2_error(session, LIBSSH2_ERROR_FILE,
-+                      "Unable to initialize private key from file", 0);
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_userauth_hostbased_fromfile_ex
-+ * Authenticate using a keypair found in the named files
-+ */
-+LIBSSH2_API int
-+libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION * session,
-+                                       const char *username,
-+                                       unsigned int username_len,
-+                                       const char *publickey,
-+                                       const char *privatekey,
-+                                       const char *passphrase,
-+                                       const char *hostname,
-+                                       unsigned int hostname_len,
-+                                       const char *local_username,
-+                                       unsigned int local_username_len)
-+{
-+    static const unsigned char reply_codes[3] =
-+        { SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE, 0 };
-+    int rc;
-+
-+    if (session->userauth_host_state == libssh2_NB_state_idle) {
-+        const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
-+        unsigned char *pubkeydata, *sig;
-+        unsigned long pubkeydata_len;
-+        unsigned long sig_len;
-+        void *abstract;
-+        unsigned char buf[5];
-+        struct iovec datavec[4];
-+
-+        /* Zero the whole thing out */
-+        memset(&session->userauth_host_packet_requirev_state, 0,
-+               sizeof(session->userauth_host_packet_requirev_state));
-+
-+        if (libssh2_file_read_publickey
-+            (session, &session->userauth_host_method,
-+             &session->userauth_host_method_len, &pubkeydata, &pubkeydata_len,
-+             publickey)) {
-+            return -1;
-+        }
-+
-+        /*
-+         * 48 = packet_type(1) + username_len(4) + servicename_len(4) + 
-+         * service_name(14)"ssh-connection" + authmethod_len(4) +
-+         * authmethod(9)"hostbased" + method_len(4) + pubkeydata_len(4) + 
-+         * local_username_len(4)
-+         */
-+        session->userauth_host_packet_len =
-+            username_len + session->userauth_host_method_len + hostname_len +
-+            local_username_len + pubkeydata_len + 48;
-+
-+        /*
-+         * Preallocate space for an overall length,  method name again,
-+         * and the signature, which won't be any larger than the size of 
-+         * the publickeydata itself
-+         */
-+        session->userauth_host_s = session->userauth_host_packet =
-+            LIBSSH2_ALLOC(session,
-+                          session->userauth_host_packet_len + 4 + (4 +
-+                                                                   session->
-+                                                                   userauth_host_method_len)
-+                          + (4 + pubkeydata_len));
-+        if (!session->userauth_host_packet) {
-+            LIBSSH2_FREE(session, session->userauth_host_method);
-+            session->userauth_host_method = NULL;
-+            return -1;
-+        }
-+
-+        *(session->userauth_host_s++) = SSH_MSG_USERAUTH_REQUEST;
-+        libssh2_htonu32(session->userauth_host_s, username_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, username, username_len);
-+        session->userauth_host_s += username_len;
-+
-+        libssh2_htonu32(session->userauth_host_s, 14);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, "ssh-connection", 14);
-+        session->userauth_host_s += 14;
-+
-+        libssh2_htonu32(session->userauth_host_s, 9);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, "hostbased", 9);
-+        session->userauth_host_s += 9;
-+
-+        libssh2_htonu32(session->userauth_host_s,
-+                        session->userauth_host_method_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, session->userauth_host_method,
-+               session->userauth_host_method_len);
-+        session->userauth_host_s += session->userauth_host_method_len;
-+
-+        libssh2_htonu32(session->userauth_host_s, pubkeydata_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, pubkeydata, pubkeydata_len);
-+        session->userauth_host_s += pubkeydata_len;
-+
-+        libssh2_htonu32(session->userauth_host_s, hostname_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, hostname, hostname_len);
-+        session->userauth_host_s += hostname_len;
-+
-+        libssh2_htonu32(session->userauth_host_s, local_username_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, local_username, local_username_len);
-+        session->userauth_host_s += local_username_len;
-+
-+        if (libssh2_file_read_privatekey
-+            (session, &privkeyobj, &abstract, session->userauth_host_method,
-+             session->userauth_host_method_len, privatekey, passphrase)) {
-+            LIBSSH2_FREE(session, session->userauth_host_method);
-+            session->userauth_host_method = NULL;
-+            LIBSSH2_FREE(session, session->userauth_host_packet);
-+            session->userauth_host_packet = NULL;
-+            return -1;
-+        }
-+
-+        libssh2_htonu32(buf, session->session_id_len);
-+        datavec[0].iov_base = buf;
-+        datavec[0].iov_len = 4;
-+        datavec[1].iov_base = session->session_id;
-+        datavec[1].iov_len = session->session_id_len;
-+        datavec[2].iov_base = session->userauth_host_packet;
-+        datavec[2].iov_len = session->userauth_host_packet_len;
-+
-+        if (privkeyobj->signv(session, &sig, &sig_len, 3, datavec, &abstract)) {
-+            LIBSSH2_FREE(session, session->userauth_host_method);
-+            session->userauth_host_method = NULL;
-+            LIBSSH2_FREE(session, session->userauth_host_packet);
-+            session->userauth_host_packet = NULL;
-+            if (privkeyobj->dtor) {
-+                privkeyobj->dtor(session, &abstract);
-+            }
-+            return -1;
-+        }
-+
-+        if (privkeyobj->dtor) {
-+            privkeyobj->dtor(session, &abstract);
-+        }
-+
-+        if (sig_len > pubkeydata_len) {
-+            unsigned char *newpacket;
-+            /* Should *NEVER* happen, but...well.. better safe than sorry */
-+            newpacket = LIBSSH2_REALLOC(session, session->userauth_host_packet, session->userauth_host_packet_len + 4 + (4 + session->userauth_host_method_len) + (4 + sig_len));       /* PK sigblob */
-+            if (!newpacket) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Failed allocating additional space for userauth-hostbased packet",
-+                              0);
-+                LIBSSH2_FREE(session, sig);
-+                LIBSSH2_FREE(session, session->userauth_host_packet);
-+                session->userauth_host_packet = NULL;
-+                LIBSSH2_FREE(session, session->userauth_host_method);
-+                session->userauth_host_method = NULL;
-+                return -1;
-+            }
-+            session->userauth_host_packet = newpacket;
-+        }
-+
-+        session->userauth_host_s =
-+            session->userauth_host_packet + session->userauth_host_packet_len;
-+
-+        libssh2_htonu32(session->userauth_host_s,
-+                        4 + session->userauth_host_method_len + 4 + sig_len);
-+        session->userauth_host_s += 4;
-+
-+        libssh2_htonu32(session->userauth_host_s,
-+                        session->userauth_host_method_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, session->userauth_host_method,
-+               session->userauth_host_method_len);
-+        session->userauth_host_s += session->userauth_host_method_len;
-+        LIBSSH2_FREE(session, session->userauth_host_method);
-+        session->userauth_host_method = NULL;
-+
-+        libssh2_htonu32(session->userauth_host_s, sig_len);
-+        session->userauth_host_s += 4;
-+        memcpy(session->userauth_host_s, sig, sig_len);
-+        session->userauth_host_s += sig_len;
-+        LIBSSH2_FREE(session, sig);
-+
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Attempting hostbased authentication");
-+
-+        session->userauth_host_state = libssh2_NB_state_created;
-+    }
-+
-+    if (session->userauth_host_state == libssh2_NB_state_created) {
-+        rc = libssh2_packet_write(session, session->userauth_host_packet,
-+                                  session->userauth_host_s -
-+                                  session->userauth_host_packet);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send userauth-hostbased request", 0);
-+            LIBSSH2_FREE(session, session->userauth_host_packet);
-+            session->userauth_host_packet = NULL;
-+            session->userauth_host_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+        LIBSSH2_FREE(session, session->userauth_host_packet);
-+        session->userauth_host_packet = NULL;
-+
-+        session->userauth_host_state = libssh2_NB_state_sent;
-+    }
-+
-+    if (session->userauth_host_state == libssh2_NB_state_sent) {
-+        unsigned long data_len;
-+        rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                        &session->userauth_host_data,
-+                                        &data_len, 0, NULL, 0,
-+                                        &session->
-+                                        userauth_host_packet_requirev_state);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            session->userauth_host_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        if (session->userauth_host_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+            _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                           "Hostbased authentication successful");
-+            /* We are us and we've proved it. */
-+            LIBSSH2_FREE(session, session->userauth_host_data);
-+            session->userauth_host_data = NULL;
-+            session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+            session->userauth_host_state = libssh2_NB_state_idle;
-+            return 0;
-+        }
-+    }
-+
-+    /* This public key is not allowed for this user on this server */
-+    LIBSSH2_FREE(session, session->userauth_host_data);
-+    session->userauth_host_data = NULL;
-+    libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
-+                  "Invalid signature for supplied public key, or bad username/public key combination",
-+                  0);
-+    session->userauth_host_state = libssh2_NB_state_idle;
-+    return -1;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_userauth_publickey_fromfile_ex
-+ * Authenticate using a keypair found in the named files
-+ */
-+LIBSSH2_API int
-+libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION * session,
-+                                       const char *username,
-+                                       unsigned int username_len,
-+                                       const char *publickey,
-+                                       const char *privatekey,
-+                                       const char *passphrase)
-+{
-+    unsigned long pubkeydata_len = 0;
-+    unsigned char reply_codes[4] =
-+        { SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE,
-+        SSH_MSG_USERAUTH_PK_OK, 0
-+    };
-+    int rc;
-+
-+    if (session->userauth_pblc_state == libssh2_NB_state_idle) {
-+        unsigned char *pubkeydata;
-+
-+        /* Zero the whole thing out */
-+        memset(&session->userauth_pblc_packet_requirev_state, 0,
-+               sizeof(session->userauth_pblc_packet_requirev_state));
-+
-+        if (libssh2_file_read_publickey
-+            (session, &session->userauth_pblc_method,
-+             &session->userauth_pblc_method_len, &pubkeydata, &pubkeydata_len,
-+             publickey)) {
-+            return -1;
-+        }
-+
-+        /*
-+         * 45 = packet_type(1) + username_len(4) + servicename_len(4) + 
-+         * service_name(14)"ssh-connection" + authmethod_len(4) + 
-+         * authmethod(9)"publickey" + sig_included(1)'\0' + algmethod_len(4) +
-+         * publickey_len(4)
-+         */
-+        session->userauth_pblc_packet_len =
-+            username_len + session->userauth_pblc_method_len + pubkeydata_len +
-+            45;
-+
-+        /*
-+         * Preallocate space for an overall length,  method name again, and
-+         * the signature, which won't be any larger than the size of the 
-+         * publickeydata itself
-+         */
-+        session->userauth_pblc_s = session->userauth_pblc_packet =
-+            LIBSSH2_ALLOC(session,
-+                          session->userauth_pblc_packet_len + 4 + (4 +
-+                                                                   session->
-+                                                                   userauth_pblc_method_len)
-+                          + (4 + pubkeydata_len));
-+        if (!session->userauth_pblc_packet) {
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            LIBSSH2_FREE(session, pubkeydata);
-+            return -1;
-+        }
-+
-+        *(session->userauth_pblc_s++) = SSH_MSG_USERAUTH_REQUEST;
-+        libssh2_htonu32(session->userauth_pblc_s, username_len);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, username, username_len);
-+        session->userauth_pblc_s += username_len;
-+
-+        libssh2_htonu32(session->userauth_pblc_s, 14);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, "ssh-connection", 14);
-+        session->userauth_pblc_s += 14;
-+
-+        libssh2_htonu32(session->userauth_pblc_s, 9);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, "publickey", 9);
-+        session->userauth_pblc_s += 9;
-+
-+        session->userauth_pblc_b = session->userauth_pblc_s;
-+        /* Not sending signature with *this* packet */
-+        *(session->userauth_pblc_s++) = 0;
-+
-+        libssh2_htonu32(session->userauth_pblc_s,
-+                        session->userauth_pblc_method_len);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, session->userauth_pblc_method,
-+               session->userauth_pblc_method_len);
-+        session->userauth_pblc_s += session->userauth_pblc_method_len;
-+
-+        libssh2_htonu32(session->userauth_pblc_s, pubkeydata_len);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, pubkeydata, pubkeydata_len);
-+        session->userauth_pblc_s += pubkeydata_len;
-+        LIBSSH2_FREE(session, pubkeydata);
-+
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Attempting publickey authentication");
-+
-+        session->userauth_pblc_state = libssh2_NB_state_created;
-+    }
-+
-+    if (session->userauth_pblc_state == libssh2_NB_state_created) {
-+        rc = libssh2_packet_write(session, session->userauth_pblc_packet,
-+                                  session->userauth_pblc_packet_len);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send userauth-publickey request", 0);
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        session->userauth_pblc_state = libssh2_NB_state_sent;
-+    }
-+
-+    if (session->userauth_pblc_state == libssh2_NB_state_sent) {
-+        const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
-+        void *abstract;
-+        unsigned char buf[5];
-+        struct iovec datavec[4];
-+        unsigned char *sig;
-+        unsigned long sig_len;
-+
-+        rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                        &session->userauth_pblc_data,
-+                                        &session->userauth_pblc_data_len, 0,
-+                                        NULL, 0,
-+                                        &session->
-+                                        userauth_pblc_packet_requirev_state);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        if (session->userauth_pblc_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+            _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                           "Pubkey authentication prematurely successful");
-+            /*
-+             * God help any SSH server that allows an UNVERIFIED
-+             * public key to validate the user
-+             */
-+            LIBSSH2_FREE(session, session->userauth_pblc_data);
-+            session->userauth_pblc_data = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return 0;
-+        }
-+
-+        if (session->userauth_pblc_data[0] == SSH_MSG_USERAUTH_FAILURE) {
-+            /* This public key is not allowed for this user on this server */
-+            LIBSSH2_FREE(session, session->userauth_pblc_data);
-+            session->userauth_pblc_data = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED,
-+                          "Username/PublicKey combination invalid", 0);
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        /* Semi-Success! */
-+        LIBSSH2_FREE(session, session->userauth_pblc_data);
-+        session->userauth_pblc_data = NULL;
-+
-+        if (libssh2_file_read_privatekey
-+            (session, &privkeyobj, &abstract, session->userauth_pblc_method,
-+             session->userauth_pblc_method_len, privatekey, passphrase)) {
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        *session->userauth_pblc_b = 0x01;
-+
-+        libssh2_htonu32(buf, session->session_id_len);
-+        datavec[0].iov_base = buf;
-+        datavec[0].iov_len = 4;
-+        datavec[1].iov_base = session->session_id;
-+        datavec[1].iov_len = session->session_id_len;
-+        datavec[2].iov_base = session->userauth_pblc_packet;
-+        datavec[2].iov_len = session->userauth_pblc_packet_len;
-+
-+        if (privkeyobj->signv(session, &sig, &sig_len, 3, datavec, &abstract)) {
-+            LIBSSH2_FREE(session, session->userauth_pblc_method);
-+            session->userauth_pblc_method = NULL;
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            if (privkeyobj->dtor) {
-+                privkeyobj->dtor(session, &abstract);
-+            }
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        if (privkeyobj->dtor) {
-+            privkeyobj->dtor(session, &abstract);
-+        }
-+
-+	/* 
-+	 * If this function was restarted, pubkeydata_len might still be 0
-+	 * which will cause an unnecessary but harmless realloc here.
-+	 */
-+        if (sig_len > pubkeydata_len) {
-+            unsigned char *newpacket;
-+            /* Should *NEVER* happen, but...well.. better safe than sorry */
-+            newpacket = LIBSSH2_REALLOC(session, session->userauth_pblc_packet, session->userauth_pblc_packet_len + 4 + (4 + session->userauth_pblc_method_len) + (4 + sig_len));       /* PK sigblob */
-+            if (!newpacket) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Failed allocating additional space for userauth-publickey packet",
-+                              0);
-+                LIBSSH2_FREE(session, sig);
-+                LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+                session->userauth_pblc_packet = NULL;
-+                LIBSSH2_FREE(session, session->userauth_pblc_method);
-+                session->userauth_pblc_method = NULL;
-+                session->userauth_pblc_state = libssh2_NB_state_idle;
-+                return -1;
-+            }
-+            session->userauth_pblc_packet = newpacket;
-+        }
-+
-+        session->userauth_pblc_s =
-+            session->userauth_pblc_packet + session->userauth_pblc_packet_len;
-+        session->userauth_pblc_b = NULL;
-+
-+        libssh2_htonu32(session->userauth_pblc_s,
-+                        4 + session->userauth_pblc_method_len + 4 + sig_len);
-+        session->userauth_pblc_s += 4;
-+
-+        libssh2_htonu32(session->userauth_pblc_s,
-+                        session->userauth_pblc_method_len);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, session->userauth_pblc_method,
-+               session->userauth_pblc_method_len);
-+        session->userauth_pblc_s += session->userauth_pblc_method_len;
-+        LIBSSH2_FREE(session, session->userauth_pblc_method);
-+        session->userauth_pblc_method = NULL;
-+
-+        libssh2_htonu32(session->userauth_pblc_s, sig_len);
-+        session->userauth_pblc_s += 4;
-+        memcpy(session->userauth_pblc_s, sig, sig_len);
-+        session->userauth_pblc_s += sig_len;
-+        LIBSSH2_FREE(session, sig);
-+
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Attempting publickey authentication -- phase 2");
-+
-+        session->userauth_pblc_state = libssh2_NB_state_sent1;
-+    }
-+
-+    if (session->userauth_pblc_state == libssh2_NB_state_sent1) {
-+        rc = libssh2_packet_write(session, session->userauth_pblc_packet,
-+                                  session->userauth_pblc_s -
-+                                  session->userauth_pblc_packet);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send userauth-publickey request", 0);
-+            LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+            session->userauth_pblc_packet = NULL;
-+            session->userauth_pblc_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+        LIBSSH2_FREE(session, session->userauth_pblc_packet);
-+        session->userauth_pblc_packet = NULL;
-+
-+        session->userauth_pblc_state = libssh2_NB_state_sent2;
-+    }
-+
-+    /* PK_OK is no longer valid */
-+    reply_codes[2] = 0;
-+
-+    rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                    &session->userauth_pblc_data,
-+                                    &session->userauth_pblc_data_len, 0, NULL,
-+                                    0,
-+                                    &session->
-+                                    userauth_pblc_packet_requirev_state);
-+    if (rc == PACKET_EAGAIN) {
-+        return PACKET_EAGAIN;
-+    } else if (rc) {
-+        session->userauth_pblc_state = libssh2_NB_state_idle;
-+        return -1;
-+    }
-+
-+    if (session->userauth_pblc_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Publickey authentication successful");
-+        /* We are us and we've proved it. */
-+        LIBSSH2_FREE(session, session->userauth_pblc_data);
-+        session->userauth_pblc_data = NULL;
-+        session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+        session->userauth_pblc_state = libssh2_NB_state_idle;
-+        return 0;
-+    }
-+
-+    /* This public key is not allowed for this user on this server */
-+    LIBSSH2_FREE(session, session->userauth_pblc_data);
-+    session->userauth_pblc_data = NULL;
-+    libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
-+                  "Invalid signature for supplied public key, or bad username/public key combination",
-+                  0);
-+    session->userauth_pblc_state = libssh2_NB_state_idle;
-+    return -1;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_userauth_keyboard_interactive
-+ * Authenticate using a challenge-response authentication
-+ */
-+LIBSSH2_API int
-+libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION * session,
-+                                         const char *username,
-+                                         unsigned int username_len,
-+                                         LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback)))
-+{
-+    unsigned char *s;
-+    int rc;
-+
-+    static const unsigned char reply_codes[4] = { SSH_MSG_USERAUTH_SUCCESS,
-+        SSH_MSG_USERAUTH_FAILURE, SSH_MSG_USERAUTH_INFO_REQUEST, 0
-+    };
-+    unsigned int language_tag_len;
-+    unsigned int i;
-+
-+    if (session->userauth_kybd_state == libssh2_NB_state_idle) {
-+        session->userauth_kybd_auth_name = NULL;
-+        session->userauth_kybd_auth_instruction = NULL;
-+        session->userauth_kybd_num_prompts = 0;
-+        session->userauth_kybd_auth_failure = 1;
-+        session->userauth_kybd_prompts = NULL;
-+        session->userauth_kybd_responses = NULL;
-+
-+        /* Zero the whole thing out */
-+        memset(&session->userauth_kybd_packet_requirev_state, 0,
-+               sizeof(session->userauth_kybd_packet_requirev_state));
-+
-+        session->userauth_kybd_packet_len = 1   /* byte      SSH_MSG_USERAUTH_REQUEST */
-+            + 4 + username_len  /* string    user name (ISO-10646 UTF-8, as defined in [RFC-3629]) */
-+            + 4 + 14            /* string    service name (US-ASCII) */
-+            + 4 + 20            /* string    "keyboard-interactive" (US-ASCII) */
-+            + 4 + 0             /* string    language tag (as defined in [RFC-3066]) */
-+            + 4 + 0             /* string    submethods (ISO-10646 UTF-8) */
-+            ;
-+
-+        session->userauth_kybd_data = s =
-+            LIBSSH2_ALLOC(session, session->userauth_kybd_packet_len);
-+        if (!s) {
-+            libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                          "Unable to allocate memory for keyboard-interactive authentication",
-+                          0);
-+            return -1;
-+        }
-+
-+        *s++ = SSH_MSG_USERAUTH_REQUEST;
-+
-+        /* user name */
-+        libssh2_htonu32(s, username_len);
-+        s += 4;
-+        memcpy(s, username, username_len);
-+        s += username_len;
-+
-+        /* service name */
-+        libssh2_htonu32(s, sizeof("ssh-connection") - 1);
-+        s += 4;
-+        memcpy(s, "ssh-connection", sizeof("ssh-connection") - 1);
-+        s += sizeof("ssh-connection") - 1;
-+
-+        /* "keyboard-interactive" */
-+        libssh2_htonu32(s, sizeof("keyboard-interactive") - 1);
-+        s += 4;
-+        memcpy(s, "keyboard-interactive", sizeof("keyboard-interactive") - 1);
-+        s += sizeof("keyboard-interactive") - 1;
-+
-+        /* language tag */
-+        libssh2_htonu32(s, 0);
-+        s += 4;
-+
-+        /* submethods */
-+        libssh2_htonu32(s, 0);
-+        s += 4;
-+
-+        _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                       "Attempting keyboard-interactive authentication");
-+
-+        session->userauth_kybd_state = libssh2_NB_state_created;
-+    }
-+
-+    if (session->userauth_kybd_state == libssh2_NB_state_created) {
-+        rc = libssh2_packet_write(session, session->userauth_kybd_data,
-+                                  session->userauth_kybd_packet_len);
-+        if (rc == PACKET_EAGAIN) {
-+            return PACKET_EAGAIN;
-+        } else if (rc) {
-+            libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                          "Unable to send keyboard-interactive request", 0);
-+            LIBSSH2_FREE(session, session->userauth_kybd_data);
-+            session->userauth_kybd_data = NULL;
-+            session->userauth_kybd_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+        LIBSSH2_FREE(session, session->userauth_kybd_data);
-+        session->userauth_kybd_data = NULL;
-+
-+        session->userauth_kybd_state = libssh2_NB_state_sent;
-+    }
-+
-+    for(;;) {
-+        if (session->userauth_kybd_state == libssh2_NB_state_sent) {
-+            rc = libssh2_packet_requirev_ex(session, reply_codes,
-+                                            &session->userauth_kybd_data,
-+                                            &session->userauth_kybd_data_len,
-+                                            0, NULL, 0,
-+                                            &session->
-+                                            userauth_kybd_packet_requirev_state);
-+            if (rc == PACKET_EAGAIN) {
-+                return PACKET_EAGAIN;
-+            } else if (rc) {
-+                session->userauth_kybd_state = libssh2_NB_state_idle;
-+                return -1;
-+            }
-+
-+            if (session->userauth_kybd_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
-+                _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                               "Keyboard-interactive authentication successful");
-+                LIBSSH2_FREE(session, session->userauth_kybd_data);
-+                session->userauth_kybd_data = NULL;
-+                session->state |= LIBSSH2_STATE_AUTHENTICATED;
-+                session->userauth_kybd_state = libssh2_NB_state_idle;
-+                return 0;
-+            }
-+
-+            if (session->userauth_kybd_data[0] == SSH_MSG_USERAUTH_FAILURE) {
-+                LIBSSH2_FREE(session, session->userauth_kybd_data);
-+                session->userauth_kybd_data = NULL;
-+                session->userauth_kybd_state = libssh2_NB_state_idle;
-+                return -1;
-+            }
-+
-+            /* server requested PAM-like conversation */
-+
-+            s = session->userauth_kybd_data + 1;
-+
-+            /* string    name (ISO-10646 UTF-8) */
-+            session->userauth_kybd_auth_name_len = libssh2_ntohu32(s);
-+            s += 4;
-+            session->userauth_kybd_auth_name =
-+                LIBSSH2_ALLOC(session, session->userauth_kybd_auth_name_len);
-+            if (!session->userauth_kybd_auth_name) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to allocate memory for keyboard-interactive 'name' request field",
-+                              0);
-+                goto cleanup;
-+            }
-+            memcpy(session->userauth_kybd_auth_name, s,
-+                   session->userauth_kybd_auth_name_len);
-+            s += session->userauth_kybd_auth_name_len;
-+
-+            /* string    instruction (ISO-10646 UTF-8) */
-+            session->userauth_kybd_auth_instruction_len = libssh2_ntohu32(s);
-+            s += 4;
-+            session->userauth_kybd_auth_instruction =
-+                LIBSSH2_ALLOC(session,
-+                              session->userauth_kybd_auth_instruction_len);
-+            if (!session->userauth_kybd_auth_instruction) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to allocate memory for keyboard-interactive 'instruction' request field",
-+                              0);
-+                goto cleanup;
-+            }
-+            memcpy(session->userauth_kybd_auth_instruction, s,
-+                   session->userauth_kybd_auth_instruction_len);
-+            s += session->userauth_kybd_auth_instruction_len;
-+
-+            /* string    language tag (as defined in [RFC-3066]) */
-+            language_tag_len = libssh2_ntohu32(s);
-+            s += 4;
-+            /* ignoring this field as deprecated */
-+            s += language_tag_len;
-+
-+            /* int       num-prompts */
-+            session->userauth_kybd_num_prompts = libssh2_ntohu32(s);
-+            s += 4;
-+
-+            session->userauth_kybd_prompts =
-+                LIBSSH2_ALLOC(session,
-+                              sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
-+                              session->userauth_kybd_num_prompts);
-+            if (!session->userauth_kybd_prompts) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to allocate memory for keyboard-interactive prompts array",
-+                              0);
-+                goto cleanup;
-+            }
-+            memset(session->userauth_kybd_prompts, 0,
-+                   sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
-+                   session->userauth_kybd_num_prompts);
-+
-+            session->userauth_kybd_responses =
-+                LIBSSH2_ALLOC(session,
-+                              sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
-+                              session->userauth_kybd_num_prompts);
-+            if (!session->userauth_kybd_responses) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to allocate memory for keyboard-interactive responses array",
-+                              0);
-+                goto cleanup;
-+            }
-+            memset(session->userauth_kybd_responses, 0,
-+                   sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
-+                   session->userauth_kybd_num_prompts);
-+
-+            for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
-+                /* string    prompt[1] (ISO-10646 UTF-8) */
-+                session->userauth_kybd_prompts[i].length = libssh2_ntohu32(s);
-+                s += 4;
-+                session->userauth_kybd_prompts[i].text =
-+                    LIBSSH2_ALLOC(session,
-+                                  session->userauth_kybd_prompts[i].length);
-+                if (!session->userauth_kybd_prompts[i].text) {
-+                    libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                                  "Unable to allocate memory for keyboard-interactive prompt message",
-+                                  0);
-+                    goto cleanup;
-+                }
-+                memcpy(session->userauth_kybd_prompts[i].text, s,
-+                       session->userauth_kybd_prompts[i].length);
-+                s += session->userauth_kybd_prompts[i].length;
-+
-+                /* boolean   echo[1] */
-+                session->userauth_kybd_prompts[i].echo = *s++;
-+            }
-+
-+            response_callback(session->userauth_kybd_auth_name,
-+                              session->userauth_kybd_auth_name_len,
-+                              session->userauth_kybd_auth_instruction,
-+                              session->userauth_kybd_auth_instruction_len,
-+                              session->userauth_kybd_num_prompts,
-+                              session->userauth_kybd_prompts,
-+                              session->userauth_kybd_responses,
-+                              &session->abstract);
-+
-+            _libssh2_debug(session, LIBSSH2_DBG_AUTH,
-+                           "Keyboard-interactive response callback function invoked");
-+
-+            session->userauth_kybd_packet_len = 1       /* byte      SSH_MSG_USERAUTH_INFO_RESPONSE */
-+                + 4             /* int       num-responses */
-+                ;
-+
-+            for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
-+                /* string    response[1] (ISO-10646 UTF-8) */
-+                session->userauth_kybd_packet_len +=
-+                    4 + session->userauth_kybd_responses[i].length;
-+            }
-+
-+            session->userauth_kybd_data = s =
-+                LIBSSH2_ALLOC(session, session->userauth_kybd_packet_len);
-+            if (!s) {
-+                libssh2_error(session, LIBSSH2_ERROR_ALLOC,
-+                              "Unable to allocate memory for keyboard-interactive response packet",
-+                              0);
-+                goto cleanup;
-+            }
-+
-+            *s = SSH_MSG_USERAUTH_INFO_RESPONSE;
-+            s++;
-+            libssh2_htonu32(s, session->userauth_kybd_num_prompts);
-+            s += 4;
-+
-+            for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
-+                libssh2_htonu32(s, session->userauth_kybd_responses[i].length);
-+                s += 4;
-+                memcpy(s, session->userauth_kybd_responses[i].text,
-+                       session->userauth_kybd_responses[i].length);
-+                s += session->userauth_kybd_responses[i].length;
-+            }
-+
-+            session->userauth_kybd_state = libssh2_NB_state_sent1;
-+        }
-+
-+        if (session->userauth_kybd_state == libssh2_NB_state_sent1) {
-+            rc = libssh2_packet_write(session, session->userauth_kybd_data,
-+                                      session->userauth_kybd_packet_len);
-+            if (rc == PACKET_EAGAIN) {
-+                return PACKET_EAGAIN;
-+            }
-+            if (rc) {
-+                libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
-+                              "Unable to send userauth-keyboard-interactive request",
-+                              0);
-+                goto cleanup;
-+            }
-+
-+            session->userauth_kybd_auth_failure = 0;
-+        }
-+
-+      cleanup:
-+        /*
-+         * It's safe to clean all the data here, because unallocated pointers
-+         * are filled by zeroes
-+         */
-+
-+        LIBSSH2_FREE(session, session->userauth_kybd_data);
-+        session->userauth_kybd_data = NULL;
-+
-+        if (session->userauth_kybd_prompts) {
-+            for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
-+                LIBSSH2_FREE(session, session->userauth_kybd_prompts[i].text);
-+                session->userauth_kybd_prompts[i].text = NULL;
-+            }
-+        }
-+
-+        if (session->userauth_kybd_responses) {
-+            for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
-+                LIBSSH2_FREE(session,
-+                             session->userauth_kybd_responses[i].text);
-+                session->userauth_kybd_responses[i].text = NULL;
-+            }
-+        }
-+
-+        LIBSSH2_FREE(session, session->userauth_kybd_prompts);
-+        session->userauth_kybd_prompts = NULL;
-+        LIBSSH2_FREE(session, session->userauth_kybd_responses);
-+        session->userauth_kybd_responses = NULL;
-+
-+        if (session->userauth_kybd_auth_failure) {
-+            session->userauth_kybd_state = libssh2_NB_state_idle;
-+            return -1;
-+        }
-+
-+        session->userauth_kybd_state = libssh2_NB_state_sent;
-+    }
-+}
-+
-+/* }}} */
-
-Property changes on: libssh2/src/userauth.c
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.2
-Added: svn:eol-style
-   + native
-
-Index: libssh2/src/mac.c
-===================================================================
---- libssh2/src/mac.c	(.../tags/RELEASE_0_11_0)
-+++ libssh2/src/mac.c	(.../trunk)
-@@ -0,0 +1,311 @@
-+/* Copyright (c) 2004-2007, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#include "libssh2_priv.h"
-+
-+#ifdef LIBSSH2_MAC_NONE
-+/* {{{ libssh2_mac_none_MAC
-+ * Minimalist MAC: No MAC
-+ */
-+static int
-+libssh2_mac_none_MAC(LIBSSH2_SESSION * session, unsigned char *buf,
-+                     unsigned long seqno, const unsigned char *packet,
-+                     unsigned long packet_len, const unsigned char *addtl,
-+                     unsigned long addtl_len, void **abstract)
-+{
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+
-+static LIBSSH2_MAC_METHOD libssh2_mac_method_none = {
-+    "none",
-+    0,
-+    0,
-+    NULL,
-+    libssh2_mac_none_MAC,
-+    NULL
-+};
-+#endif /* LIBSSH2_MAC_NONE */
-+
-+/* {{{ libssh2_mac_method_common_init
-+ * Initialize simple mac methods
-+ */
-+static int
-+libssh2_mac_method_common_init(LIBSSH2_SESSION * session, unsigned char *key,
-+                               int *free_key, void **abstract)
-+{
-+    *abstract = key;
-+    *free_key = 0;
-+    (void) session;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_mac_method_common_dtor
-+ * Cleanup simple mac methods
-+ */
-+static int
-+libssh2_mac_method_common_dtor(LIBSSH2_SESSION * session, void **abstract)
-+{
-+    if (*abstract) {
-+        LIBSSH2_FREE(session, *abstract);
-+    }
-+    *abstract = NULL;
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+/* {{{ libssh2_mac_method_hmac_sha1_hash
-+ * Calculate hash using full sha1 value
-+ */
-+static int
-+libssh2_mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session,
-+                                  unsigned char *buf, unsigned long seqno,
-+                                  const unsigned char *packet,
-+                                  unsigned long packet_len,
-+                                  const unsigned char *addtl,
-+                                  unsigned long addtl_len, void **abstract)
-+{
-+    libssh2_hmac_ctx ctx;
-+    unsigned char seqno_buf[4];
-+    (void) session;
-+
-+    libssh2_htonu32(seqno_buf, seqno);
-+
-+    libssh2_hmac_sha1_init(&ctx, *abstract, 20);
-+    libssh2_hmac_update(ctx, seqno_buf, 4);
-+    libssh2_hmac_update(ctx, packet, packet_len);
-+    if (addtl && addtl_len) {
-+        libssh2_hmac_update(ctx, addtl, addtl_len);
-+    }
-+    libssh2_hmac_final(ctx, buf);
-+    libssh2_hmac_cleanup(&ctx);
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_sha1 = {
-+    "hmac-sha1",
-+    20,
-+    20,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_sha1_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+
-+/* {{{ libssh2_mac_method_hmac_sha1_96_hash
-+ * Calculate hash using first 96 bits of sha1 value
-+ */
-+static int
-+libssh2_mac_method_hmac_sha1_96_hash(LIBSSH2_SESSION * session,
-+                                     unsigned char *buf, unsigned long seqno,
-+                                     const unsigned char *packet,
-+                                     unsigned long packet_len,
-+                                     const unsigned char *addtl,
-+                                     unsigned long addtl_len, void **abstract)
-+{
-+    unsigned char temp[SHA_DIGEST_LENGTH];
-+
-+    libssh2_mac_method_hmac_sha1_hash(session, temp, seqno, packet, packet_len,
-+                                      addtl, addtl_len, abstract);
-+    memcpy(buf, (char *) temp, 96 / 8);
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_sha1_96 = {
-+    "hmac-sha1-96",
-+    12,
-+    20,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_sha1_96_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+
-+/* {{{ libssh2_mac_method_hmac_md5_hash
-+ * Calculate hash using full md5 value
-+ */
-+static int
-+libssh2_mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf,
-+                                 unsigned long seqno,
-+                                 const unsigned char *packet,
-+                                 unsigned long packet_len,
-+                                 const unsigned char *addtl,
-+                                 unsigned long addtl_len, void **abstract)
-+{
-+    libssh2_hmac_ctx ctx;
-+    unsigned char seqno_buf[4];
-+    (void) session;
-+
-+    libssh2_htonu32(seqno_buf, seqno);
-+
-+    libssh2_hmac_md5_init(&ctx, *abstract, 16);
-+    libssh2_hmac_update(ctx, seqno_buf, 4);
-+    libssh2_hmac_update(ctx, packet, packet_len);
-+    if (addtl && addtl_len) {
-+        libssh2_hmac_update(ctx, addtl, addtl_len);
-+    }
-+    libssh2_hmac_final(ctx, buf);
-+    libssh2_hmac_cleanup(&ctx);
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_md5 = {
-+    "hmac-md5",
-+    16,
-+    16,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_md5_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+
-+/* {{{ libssh2_mac_method_hmac_md5_96_hash
-+ * Calculate hash using first 96 bits of md5 value
-+ */
-+static int
-+libssh2_mac_method_hmac_md5_96_hash(LIBSSH2_SESSION * session,
-+                                    unsigned char *buf, unsigned long seqno,
-+                                    const unsigned char *packet,
-+                                    unsigned long packet_len,
-+                                    const unsigned char *addtl,
-+                                    unsigned long addtl_len, void **abstract)
-+{
-+    unsigned char temp[MD5_DIGEST_LENGTH];
-+
-+    libssh2_mac_method_hmac_md5_hash(session, temp, seqno, packet, packet_len,
-+                                     addtl, addtl_len, abstract);
-+    memcpy(buf, (char *) temp, 96 / 8);
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_md5_96 = {
-+    "hmac-md5-96",
-+    12,
-+    16,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_md5_96_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+
-+#if LIBSSH2_HMAC_RIPEMD
-+/* {{{ libssh2_mac_method_hmac_ripemd160_hash
-+ * Calculate hash using ripemd160 value
-+ */
-+static int
-+libssh2_mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session,
-+                                       unsigned char *buf, unsigned long seqno,
-+                                       const unsigned char *packet,
-+                                       unsigned long packet_len,
-+                                       const unsigned char *addtl,
-+                                       unsigned long addtl_len,
-+                                       void **abstract)
-+{
-+    libssh2_hmac_ctx ctx;
-+    unsigned char seqno_buf[4];
-+    (void) session;
-+
-+    libssh2_htonu32(seqno_buf, seqno);
-+
-+    libssh2_hmac_ripemd160_init(&ctx, *abstract, 20);
-+    libssh2_hmac_update(ctx, seqno_buf, 4);
-+    libssh2_hmac_update(ctx, packet, packet_len);
-+    if (addtl && addtl_len) {
-+        libssh2_hmac_update(ctx, addtl, addtl_len);
-+    }
-+    libssh2_hmac_final(ctx, buf);
-+    libssh2_hmac_cleanup(&ctx);
-+
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_ripemd160 = {
-+    "hmac-ripemd160",
-+    20,
-+    20,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_ripemd160_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+
-+static const LIBSSH2_MAC_METHOD libssh2_mac_method_hmac_ripemd160_openssh_com = {
-+    "hmac-ripemd160 at openssh.com",
-+    20,
-+    20,
-+    libssh2_mac_method_common_init,
-+    libssh2_mac_method_hmac_ripemd160_hash,
-+    libssh2_mac_method_common_dtor,
-+};
-+#endif /* LIBSSH2_HMAC_RIPEMD */
-+
-+static const LIBSSH2_MAC_METHOD *_libssh2_mac_methods[] = {
-+    &libssh2_mac_method_hmac_sha1,
-+    &libssh2_mac_method_hmac_sha1_96,
-+    &libssh2_mac_method_hmac_md5,
-+    &libssh2_mac_method_hmac_md5_96,
-+#if LIBSSH2_HMAC_RIPEMD
-+    &libssh2_mac_method_hmac_ripemd160,
-+    &libssh2_mac_method_hmac_ripemd160_openssh_com,
-+#endif /* LIBSSH2_HMAC_RIPEMD */
-+#ifdef LIBSSH2_MAC_NONE
-+    &libssh2_mac_method_none,
-+#endif /* LIBSSH2_MAC_NONE */
-+    NULL
-+};
-+
-+const LIBSSH2_MAC_METHOD **
-+libssh2_mac_methods(void)
-+{
-+    return _libssh2_mac_methods;
-+}
-
-Property changes on: libssh2/src/mac.c
-___________________________________________________________________
-Added: svn:mime-type
-   + text/x-c
-Added: svn:keywords
-   + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
-Added: cvs2svn:cvs-rev
-   + 1.2
-Added: svn:eol-style
-   + native
-
-Index: libssh2/src/crypt.c
-===================================================================
---- libssh2/src/crypt.c	(.../tags/RELEASE_0_11_0)
-+++ libssh2/src/crypt.c	(.../trunk)
-@@ -0,0 +1,256 @@
-+/* Copyright (c) 2004-2007, Sara Golemon <sarag at libssh2.org>
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms,
-+ * with or without modification, are permitted provided
-+ * that the following conditions are met:
-+ *
-+ *   Redistributions of source code must retain the above
-+ *   copyright notice, this list of conditions and the
-+ *   following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above
-+ *   copyright notice, this list of conditions and the following
-+ *   disclaimer in the documentation and/or other materials
-+ *   provided with the distribution.
-+ *
-+ *   Neither the name of the copyright holder nor the names
-+ *   of any other contributors may be used to endorse or
-+ *   promote products derived from this software without
-+ *   specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+ * OF SUCH DAMAGE.
-+ */
-+
-+#include "libssh2_priv.h"
-+
-+#ifdef LIBSSH2_CRYPT_NONE
-+/* {{{ libssh2_crypt_none_crypt
-+ * Minimalist cipher: VERY secure *wink*
-+ */
-+static int
-+libssh2_crypt_none_crypt(LIBSSH2_SESSION * session, unsigned char *buf,
-+                         void **abstract)
-+{
-+    /* Do nothing to the data! */
-+    return 0;
-+}
-+
-+/* }}} */
-+
-+static const LIBSSH2_CRYPT_METHOD libssh2_crypt_method_none = {
-+    "none",
-+    8,                          /* blocksize (SSH2 defines minimum blocksize as 8) */
-+    0,                          /* iv_len */
-+    0,                          /* secret_len */
-+    0,                          /* flags */
-+    NULL,
-+    libssh2_crypt_none_crypt,
-+    NULL
-+};
-+#endif /* LIBSSH2_CRYPT_NONE */
-+
-+struct crypt_ctx
-+{
-+    int encrypt;
-+      _libssh2_cipher_type(algo);
-+    _libssh2_cipher_ctx h;
-+};
-+
-+static int
-+_libssh2_init(LIBSSH2_SESSION * session,
-+              const LIBSSH2_CRYPT_METHOD * method,
-+              unsigned char *iv, int *free_iv,
-+              unsigned char *secret, int *free_secret,
-+              int encrypt, void **abstract)
-+{
-+    struct crypt_ctx *ctx = LIBSSH2_ALLOC(session,
-+                                          sizeof(struct crypt_ctx));
-+    if (!ctx) {
-+        return -1;
-+    }
-+    ctx->encrypt = encrypt;
-+    ctx->algo = method->algo;
-+    if (_libssh2_cipher_init(&ctx->h, ctx->algo, iv, secret, encrypt)) {
-+        LIBSSH2_FREE(session, ctx);
-+        return -1;
-+    }
-+    *abstract = ctx;
-+    *free_iv = 1;
-+    *free_secret = 1;
-+    return 0;
-+}
-+
-+static int
-+_libssh2_encrypt(LIBSSH2_SESSION * session, unsigned char *block,
-+                 void **abstract)
-+{
-+    struct crypt_ctx *cctx = *(struct crypt_ctx **) abstract;
-+    (void) session;
-+    return _libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block);
-+}
-+
-+static int
-+_libssh2_dtor(LIBSSH2_SESSION * session, void **abstract)
-+{
-+    struct crypt_ctx **cctx = (struct crypt_ctx **) abstract;
-+    if (cctx && *cctx) {
-+        _libssh2_cipher_dtor(&(*cctx)->h);
-+        LIBSSH2_FREE(session, *cctx);
-+        *abstract = NULL;
<Skipped 15543 lines>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-pecl-ssh2.git/commitdiff/c179bae37976b682335095d394fc8ef6329bb0d3



More information about the pld-cvs-commit mailing list