mirror of
https://github.com/php-win-ext/libssh2.git
synced 2026-03-25 01:22:14 +01:00
Compare commits
1 Commits
libssh2-1.
...
libssh2-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4da10e055 |
101
CMakeLists.txt
Normal file
101
CMakeLists.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
project(libssh2 C)
|
||||
set(PROJECT_URL "https://www.libssh2.org/")
|
||||
set(PROJECT_DESCRIPTION "The SSH library")
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||
|
||||
# Parse version
|
||||
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h _HEADER_CONTENTS)
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
|
||||
LIBSSH2_VERSION "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MAJOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MINOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_PATCH[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_PATCH "${_HEADER_CONTENTS}")
|
||||
|
||||
if(NOT LIBSSH2_VERSION OR
|
||||
NOT LIBSSH2_VERSION_MAJOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_MINOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_PATCH MATCHES "^[0-9]+$")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Unable to parse version from"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h")
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
FILES docs/AUTHORS COPYING docs/HACKING README RELEASE-NOTES NEWS
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
include(max_warnings)
|
||||
include(FeatureSummary)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
option(BUILD_EXAMPLES "Build libssh2 examples" ON)
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
option(BUILD_TESTING "Build libssh2 test suite" ON)
|
||||
if(BUILD_TESTING)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
feature_summary(WHAT ALL)
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBSSH2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${LIBSSH2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${LIBSSH2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION ${LIBSSH2_VERSION})
|
||||
include(CPack)
|
||||
14
Makefile.am
14
Makefile.am
@@ -32,8 +32,20 @@ win32/libssh2_config.h win32/config.mk win32/rules.mk \
|
||||
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
|
||||
os400/os400sys.c os400/ccsid.c \
|
||||
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
|
||||
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
|
||||
os400/libssh2rpg/libssh2.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_publickey.rpgle \
|
||||
os400/libssh2rpg/libssh2_sftp.rpgle \
|
||||
Makefile.os400qc3.inc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
|
||||
CMakeLists.txt cmake $(OS400FILES)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
|
||||
64
Makefile.in
64
Makefile.in
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -16,7 +16,17 @@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -80,12 +90,6 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@BUILD_EXAMPLES_TRUE@am__append_1 = example
|
||||
DIST_COMMON = $(srcdir)/Makefile.inc $(srcdir)/Makefile.in \
|
||||
$(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(srcdir)/libssh2.pc.in \
|
||||
$(include_HEADERS) COPYING ChangeLog NEWS README compile \
|
||||
config.guess config.rpath config.sub depcomp install-sh \
|
||||
missing ltmain.sh
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
@@ -96,6 +100,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(include_HEADERS) $(am__DIST_COMMON)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
@@ -190,6 +196,10 @@ ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
DIST_SUBDIRS = src tests docs example
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.inc \
|
||||
$(srcdir)/libssh2.pc.in COPYING ChangeLog NEWS README compile \
|
||||
config.guess config.rpath config.sub depcomp install-sh \
|
||||
ltmain.sh missing
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
@@ -364,6 +374,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -398,8 +409,20 @@ win32/libssh2_config.h win32/config.mk win32/rules.mk \
|
||||
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
|
||||
os400/os400sys.c os400/ccsid.c \
|
||||
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
|
||||
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
|
||||
os400/libssh2rpg/libssh2.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_publickey.rpgle \
|
||||
os400/libssh2rpg/libssh2_sftp.rpgle \
|
||||
Makefile.os400qc3.inc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
|
||||
CMakeLists.txt cmake $(OS400FILES)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
@@ -435,7 +458,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/Ma
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -445,7 +467,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
$(srcdir)/Makefile.inc:
|
||||
$(srcdir)/Makefile.inc $(am__empty):
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
@@ -699,15 +721,15 @@ dist-xz: distdir
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__post_remove_distdir)
|
||||
@@ -743,17 +765,17 @@ distcheck: dist
|
||||
esac
|
||||
chmod -R a-w $(distdir)
|
||||
chmod u+w $(distdir)
|
||||
mkdir $(distdir)/_build $(distdir)/_inst
|
||||
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure \
|
||||
&& $(am__cd) $(distdir)/_build/sub \
|
||||
&& ../../configure \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=.. --prefix="$$dc_install_base" \
|
||||
--srcdir=../.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
@@ -935,6 +957,8 @@ uninstall-am: uninstall-includeHEADERS uninstall-pkgconfigDATA
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-includeHEADERS uninstall-pkgconfigDATA
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
.PHONY: ChangeLog
|
||||
ChangeLog:
|
||||
|
||||
2
Makefile.os400qc3.inc
Normal file
2
Makefile.os400qc3.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = os400qc3.c
|
||||
CRYPTO_HHEADERS = os400qc3.h
|
||||
912
NEWS
912
NEWS
@@ -1,5 +1,564 @@
|
||||
Changelog for the libssh2 project. Generated with git2news.pl
|
||||
|
||||
Version 1.7.0 (23 Feb 2016)
|
||||
|
||||
Daniel Stenberg (23 Feb 2016)
|
||||
- web: the site is now HTTPS
|
||||
|
||||
- RELEASE-NOTES: 1.7.0 release
|
||||
|
||||
- diffie_hellman_sha256: convert bytes to bits
|
||||
|
||||
As otherwise we get far too small numbers.
|
||||
|
||||
Reported-by: Andreas Schneider
|
||||
|
||||
CVE-2016-0787
|
||||
|
||||
Alexander Lamaison (18 Feb 2016)
|
||||
- Allow CI failures with VS 2008 x64.
|
||||
|
||||
Appveyor doesn't support this combination.
|
||||
|
||||
Daniel Stenberg (16 Feb 2016)
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
GNUmakefile: list system libs after user libs
|
||||
|
||||
Otherwise some referenced WinSock functions will fail to
|
||||
resolve when linking against LibreSSL 2.3.x static libraries
|
||||
with mingw.
|
||||
|
||||
Closes #80
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
openssl: apply new HAVE_OPAQUE_STRUCTS macro
|
||||
|
||||
Closes #81
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
openssl: fix LibreSSL support after OpenSSL 1.1.0-pre1/2 support
|
||||
|
||||
Alexander Lamaison (14 Feb 2016)
|
||||
- sftp.h: Fix non-C90 type.
|
||||
|
||||
uint64_t does not exist in C90. Use libssh2_uint64_t instead.
|
||||
|
||||
- Exclude sshd tests from AppVeyor.
|
||||
|
||||
They fail complaining that sshd wasn't invoked with an absolute path.
|
||||
|
||||
- Test on more versions of Visual Studio.
|
||||
|
||||
- Fix Appveyor builds.
|
||||
|
||||
Daniel Stenberg (14 Feb 2016)
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
openssl: add OpenSSL 1.1.0-pre3-dev compatibility
|
||||
|
||||
by using API instead of accessing an internal structure.
|
||||
|
||||
Closes #83
|
||||
|
||||
- RELEASE-NOTES: synced with 996b04ececdf
|
||||
|
||||
- include/libssh2.h: next version is 1.7.0
|
||||
|
||||
- configure: build "silent" if possible
|
||||
|
||||
- sftp: re-indented some minor stuff
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: ensure minimum read packet size
|
||||
|
||||
For optimum performance we need to ensure we don't request tiny packets.
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: Explicit return values & sanity checks
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: Check Read Packet File Offset
|
||||
|
||||
This commit adds a simple check to see if the offset of the read
|
||||
request matches the expected file offset.
|
||||
|
||||
We could try to recover, from this condition at some point in the future.
|
||||
Right now it is better to return an error instead of corrupted data.
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: Don't return EAGAIN if data was written to buffer
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: Send at least one read request before reading
|
||||
|
||||
This commit ensures that we have sent at least one read request before
|
||||
we try to read data in sftp_read().
|
||||
|
||||
Otherwise sftp_read() would return 0 bytes (indicating EOF) if the
|
||||
socket is not ready for writing.
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
sftp.c: stop reading when buffer is full
|
||||
|
||||
Since we can only store data from a single chunk in filep,
|
||||
we have to stop receiving data as soon as the buffer is full.
|
||||
|
||||
This adresses the following bug report:
|
||||
https://github.com/libssh2/libssh2/issues/50
|
||||
|
||||
Salvador Fandiño (21 Jan 2016)
|
||||
- agent_disconnect_unix: unset the agent fd after closing it
|
||||
|
||||
"agent_disconnect_unix", called by "libssh2_agent_disconnect", was
|
||||
leaving the file descriptor in the agent structure unchanged. Later,
|
||||
"libssh2_agent_free" would call again "libssh2_agent_disconnect" under
|
||||
the hood and it would try to close again the same file descriptor. In
|
||||
most cases that resulted in just a harmless error, but it is also
|
||||
possible that the file descriptor had been reused between the two
|
||||
calls resulting in the closing of an unrelated file descriptor.
|
||||
|
||||
This patch sets agent->fd to LIBSSH2_INVALID_SOCKET avoiding that
|
||||
issue.
|
||||
|
||||
Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
|
||||
|
||||
Daniel Stenberg (18 Jan 2016)
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3: support encrypted private keys
|
||||
|
||||
PKCS#8 EncryptedPrivateKeyinfo structures are recognized and decoded to get
|
||||
values accepted by the Qc3 crypto library.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3: New PKCS#5 decoder
|
||||
|
||||
The Qc3 library is not able to handle PKCS#8 EncryptedPrivateKeyInfo structures
|
||||
by itself. It is only capable of decrypting the (encrypted) PrivateKeyInfo
|
||||
part, providing a key encryption key and an encryption algorithm are given.
|
||||
Since the encryption key and algorithm description part in a PKCS#8
|
||||
EncryptedPrivateKeyInfo is a PKCS#5 structure, such a decoder is needed to
|
||||
get the derived key method and hash, as well as encryption algorith and
|
||||
initialisation vector.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3: force continuous update on non-final hash/hmac computation
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3: Be sure hmac keys have a minimum length
|
||||
|
||||
The Qc3 library requires a minimum key length depending on the target
|
||||
hash algorithm. Append binary zeroes to the given key if not long enough.
|
||||
This matches RFC 2104 specifications.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3: Slave descriptor for key encryption key
|
||||
|
||||
The Qc3 library requires the key encryption key to exist as long as
|
||||
the encrypted key is used. Its descriptor token is then kept as an
|
||||
"encrypted key slave" for recursive release.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3.c: comment PEM/DER decoding
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3.c: improve ASN.1 header byte checks
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400qc3.c: improve OID matching
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: os400qc3.c: replace malloc by LIBSSH2_ALLOC or alloca where possible
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: asn1_new_from_bytes(): use data from a single element only
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: fix an ILE/RPG prototype
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: implement character encoding conversion support
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: do not miss some external prototypes
|
||||
|
||||
Build procedure extproto() did not strip braces from header files, thus
|
||||
possibly prepended them to true prototypes. This prevented the prototype to
|
||||
be recognized as such.
|
||||
The solution implemented here is to map braces to semicolons, effectively
|
||||
considering them as potential prototype delimiters.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: Really add specific README
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: Add specific README and include new files in dist tarball
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: add compilation scripts
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: include files for ILE/RPG
|
||||
|
||||
In addition, file os400/macros.h declares all procedures originally
|
||||
defined as macros. It must not be used for real inclusion and is only
|
||||
intended to be used as a `database' for macro wrapping procedures generation.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
os400: add supplementary header files/wrappers. Define configuration.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
Protect callback function calls from macro substitution
|
||||
|
||||
Some structure fields holding callback addresses have the same name as the
|
||||
underlying system function (connect, send, recv). Set parentheses around
|
||||
their reference to suppress a possible macro substitution.
|
||||
|
||||
Use a macro for connect() on OS/400 to resolve a const/nonconst parameter
|
||||
problem.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
Add interface for OS/400 crypto library QC3
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
misc: include stdarg.h for debug code
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
Document crypto library interface
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
Feature an optional crypto-specific macro to rsa sign a data fragment vector
|
||||
|
||||
OS/400 crypto library is unable to sign a precomputed SHA1 hash: however
|
||||
it does support a procedure that hashes data fragments and rsa signs.
|
||||
If defined, the new macro _libssh2_rsa_sha1_signv() implements this function
|
||||
and disables use of _libssh2_rsa_sha1_sign().
|
||||
|
||||
The function described above requires that the struct iovec unused slacks are
|
||||
cleared: for this reason, macro libssh2_prepare_iovec() has been introduced.
|
||||
It should be defined as empty for crypto backends that are not sensitive
|
||||
to struct iovec unused slack values.
|
||||
|
||||
- [Patrick Monnerat brought this change]
|
||||
|
||||
Fold long lines in include files
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
kex.c: fix indentation
|
||||
|
||||
Closes #71
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
add OpenSSL-1.1.0-pre2 compatibility
|
||||
|
||||
Closes #70
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
add OpenSSL 1.1.0-pre1 compatibility
|
||||
|
||||
* close https://github.com/libssh2/libssh2/issues/69
|
||||
* sync a declaration with the rest of similar ones
|
||||
* handle EVP_MD_CTX_new() returning NULL with OpenSSL 1.1.0
|
||||
* fix potential memory leak with OpenSSL 1.1.0 in
|
||||
_libssh2_*_init() functions, when EVP_MD_CTX_new() succeeds,
|
||||
but EVP_DigestInit() fails.
|
||||
|
||||
Marc Hoersken (22 Dec 2015)
|
||||
- wincng.c: fixed _libssh2_wincng_hash_final return value
|
||||
|
||||
_libssh2_wincng_hash_final was returning the internal BCRYPT
|
||||
status code instead of a valid libssh2 return value (0 or -1).
|
||||
|
||||
This also means that _libssh2_wincng_hash never returned 0.
|
||||
|
||||
- wincng.c: fixed possible memory leak in _libssh2_wincng_hash
|
||||
|
||||
If _libssh2_wincng_hash_update failed _libssh2_wincng_hash_final
|
||||
would never have been called before.
|
||||
|
||||
Reported by Zenju.
|
||||
|
||||
Kamil Dudka (15 Dec 2015)
|
||||
- [Paul Howarth brought this change]
|
||||
|
||||
libssh2.pc.in: fix the output of pkg-config --libs
|
||||
|
||||
... such that it does not include LDFLAGS used to build libssh2 itself.
|
||||
There was a similar fix in the curl project long time ago:
|
||||
|
||||
https://github.com/bagder/curl/commit/curl-7_19_7-56-g4c8adc8
|
||||
|
||||
Bug: https://bugzilla.redhat.com/1279966
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
|
||||
Marc Hoersken (6 Dec 2015)
|
||||
- hostkey.c: align code path of ssh_rsa_init to ssh_dss_init
|
||||
|
||||
- hostkey.c: fix invalid memory access if libssh2_dsa_new fails
|
||||
|
||||
Reported by dimmaq, fixes #66
|
||||
|
||||
Daniel Stenberg (3 Nov 2015)
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
gcrypt: define libssh2_sha256_ctx
|
||||
|
||||
Looks like it didn't make it into the latest commit for whatever reason.
|
||||
|
||||
Closes #58
|
||||
|
||||
- [Salvador Fandino brought this change]
|
||||
|
||||
libssh2_session_set_last_error: Add function
|
||||
|
||||
Net::SSH2, the Perl wrapping module for libssh2 implements several features*
|
||||
on top of libssh2 that can fail and so need some mechanism to report the error
|
||||
condition to the user.
|
||||
|
||||
Until now, besides the error state maintained internally by libssh2, another
|
||||
error state was maintained at the Perl level for every session object and then
|
||||
additional logic was used to merge both error states. That is a maintenance
|
||||
nighmare, and actually there is no way to do it correctly and consistently.
|
||||
|
||||
In order to allow the high level language to add new features to the library
|
||||
but still rely in its error reporting features the new function
|
||||
libssh2_session_set_last_error (that just exposses _libssh2_error_flags) is
|
||||
introduced.
|
||||
|
||||
*) For instance, connecting to a remote SSH service giving the hostname and
|
||||
port.
|
||||
|
||||
Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
|
||||
Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
|
||||
|
||||
- [Salvador Fandino brought this change]
|
||||
|
||||
_libssh2_error: Support allocating the error message
|
||||
|
||||
Before this patch "_libssh2_error" required the error message to be a
|
||||
static string.
|
||||
|
||||
This patch adds a new function "_libssh2_error_flags" accepting an
|
||||
additional "flags" argument and specifically the flag
|
||||
"LIBSSH2_ERR_FLAG_DUP" indicating that the passed string must be
|
||||
duplicated into the heap.
|
||||
|
||||
Then, the method "_libssh2_error" has been rewritten to use that new
|
||||
function under the hood.
|
||||
|
||||
Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
|
||||
Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
|
||||
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
added engine.h include to fix warning
|
||||
|
||||
- [sune brought this change]
|
||||
|
||||
kex.c: removed dupe entry from libssh2_kex_methods[]
|
||||
|
||||
Closes #51
|
||||
|
||||
- [Salvador Fandiño brought this change]
|
||||
|
||||
userauth: Fix off by one error when reading public key file
|
||||
|
||||
After reading the public key from file the size was incorrectly
|
||||
decremented by one.
|
||||
|
||||
This was usually a harmless error as the last character on the public
|
||||
key file is an unimportant EOL. But if due to some error the public key
|
||||
file is empty, the public key size becomes (uint)(0 - 1), resulting in
|
||||
an unrecoverable out of memory error later.
|
||||
|
||||
Signed-off-by: Salvador Fandi??o <sfandino-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
|
||||
|
||||
- [Salvador Fandino brought this change]
|
||||
|
||||
channel: Detect bad usage of libssh2_channel_process_startup
|
||||
|
||||
A common novice programmer error (at least among those using the
|
||||
wrapping Perl module Net::SSH2), is to try to reuse channels.
|
||||
|
||||
This patchs detects that incorrect usage and fails with a
|
||||
LIBSSH2_ERROR_BAD_USE error instead of hanging.
|
||||
|
||||
Signed-off-by: Salvador Fandino <sfandino-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
|
||||
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
kex: Added diffie-hellman-group-exchange-sha256 support
|
||||
|
||||
... and fixed HMAC_Init depricated usage
|
||||
|
||||
Closes #48
|
||||
|
||||
Alexander Lamaison (21 Sep 2015)
|
||||
- Prefixed new #defines to prevent collisions.
|
||||
|
||||
Other libraries might have their own USE_WIN32_*FILES.
|
||||
|
||||
- [keith-daigle brought this change]
|
||||
|
||||
Update examples/scp.c to fix bug where large files on win32 would cause got to wrap and go negative
|
||||
|
||||
- [David Byron brought this change]
|
||||
|
||||
add libssh2_scp_recv2 to support large (> 2GB) files on windows
|
||||
|
||||
Daniel Stenberg (17 Sep 2015)
|
||||
- [sune brought this change]
|
||||
|
||||
WinCNG: support for SHA256/512 HMAC
|
||||
|
||||
Closes #47
|
||||
|
||||
- [brian m. carlson brought this change]
|
||||
|
||||
Add support for HMAC-SHA-256 and HMAC-SHA-512.
|
||||
|
||||
Implement support for these algorithms and wire them up to the libgcrypt
|
||||
and OpenSSL backends. Increase the maximum MAC buffer size to 64 bytes
|
||||
to prevent buffer overflows. Prefer HMAC-SHA-256 over HMAC-SHA-512, and
|
||||
that over HMAC-SHA-1, as OpenSSH does.
|
||||
|
||||
Closes #40
|
||||
|
||||
- [Zenju brought this change]
|
||||
|
||||
kex: free server host key before allocating it (again)
|
||||
|
||||
Fixes a memory leak when Synology server requests key exchange
|
||||
|
||||
Closes #43
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
GNUmakefile: up OpenSSL version
|
||||
|
||||
closes #23
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
GNUmakefile: add -m64 CFLAGS when targeting mingw64, add -m32/-m64 to LDFLAGS
|
||||
|
||||
libssh2 equivalent of curl patch https://github.com/bagder/curl/commit/d21b66835f2af781a3c2a685abc92ef9f0cd86be
|
||||
|
||||
This allows to build for the non-default target when using a multi-target mingw distro.
|
||||
Also bump default OpenSSL dependency path to 1.0.2c.
|
||||
|
||||
- [Viktor Szakats brought this change]
|
||||
|
||||
GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS
|
||||
|
||||
It is similar to existing LIBSSH2_CFLAG_EXTRAS, but for
|
||||
extra linker options.
|
||||
|
||||
Also delete some line/file ending whitespace.
|
||||
|
||||
closes #27
|
||||
|
||||
- [nasacj brought this change]
|
||||
|
||||
hostkey.c: Fix compiling error when OPENSSL_NO_MD5 is defined
|
||||
|
||||
Closes #32
|
||||
|
||||
- [Mizunashi Mana brought this change]
|
||||
|
||||
openssl.h: adjust the rsa/dsa includes
|
||||
|
||||
... to work when built without DSA support.
|
||||
|
||||
Closes #36
|
||||
|
||||
Alexander Lamaison (26 Jul 2015)
|
||||
- Let CMake build work as a subproject.
|
||||
|
||||
Patch contributed by JasonHaslam.
|
||||
|
||||
- Fix builds with Visual Studio 2015.
|
||||
|
||||
VS2015 moved stdio functions to the header files as inline function. That means check_function_exists can't detect them because it doesn't use header files - just does a link check. Instead we need to use check_symbol_exists with the correct headers.
|
||||
|
||||
Kamil Dudka (2 Jul 2015)
|
||||
- cmake: include CMake files in the release tarballs
|
||||
|
||||
Despite we announced the CMake support in libssh2-1.6.0 release notes,
|
||||
the files required by the CMake build system were not included in the
|
||||
release tarballs. Hence, the only way to use CMake for build was the
|
||||
upstream git repository.
|
||||
|
||||
This commit makes CMake actually supported in the release tarballs.
|
||||
|
||||
- tests/mansyntax.sh: fix 'make distcheck' with recent autotools
|
||||
|
||||
Do not create symbolic links off the build directory. Recent autotools
|
||||
verify that out-of-source build works even if the source directory tree
|
||||
is not writable.
|
||||
|
||||
- openssl: fix memleak in _libssh2_dsa_sha1_verify()
|
||||
|
||||
Daniel Stenberg (12 Jun 2015)
|
||||
- openssl: make libssh2_sha1 return error code
|
||||
|
||||
- use the internal prefix _libssh2_ for non-exported functions
|
||||
|
||||
- removed libssh2_md5() since it wasn't used
|
||||
|
||||
Reported-by: Kamil Dudka
|
||||
|
||||
- [LarsNordin-LNdata brought this change]
|
||||
|
||||
SFTP: Increase speed and datasize in SFTP read
|
||||
|
||||
The function sftp_read never return more then 2000 bytes (as it should
|
||||
when I asked Daniel). I increased the MAX_SFTP_READ_SIZE to 30000 but
|
||||
didn't get the same speed as a sftp read in SecureSSH. I analyzed the
|
||||
code and found that a return always was dona when a chunk has been read.
|
||||
I changed it to a sliding buffer and worked on all available chunks. I
|
||||
got an increase in speed and non of the test I have done has failed
|
||||
(both local net and over Internet). Please review and test. I think
|
||||
30000 is still not the optimal MAX_SFTP_READ_SIZE, my next goal is to
|
||||
make an API to enable changing this value (The SecureSSH sftp_read has
|
||||
more complete filled packages when comparing the network traffic)
|
||||
|
||||
- bump: start working on 1.6.1
|
||||
|
||||
Version 1.6.0 (5 Jun 2015)
|
||||
|
||||
Daniel Stenberg (5 Jun 2015)
|
||||
@@ -4869,356 +5428,3 @@ Guenter Knauf (6 Sep 2009)
|
||||
- added sys/select.h include to samples for fd_set on NetWare.
|
||||
|
||||
- accept CFLAGS from environment.
|
||||
|
||||
- some more .cvsignore / .gitignore fixes.
|
||||
|
||||
- renamed .cvsignore to .gitignore.
|
||||
|
||||
- changed conditional into make language.
|
||||
|
||||
- changed NetWare and MingW32 makefile to use Makefile.inc.
|
||||
|
||||
Daniel Stenberg (2 Sep 2009)
|
||||
- CVS leftovers removed
|
||||
|
||||
- libssh2_version() exists since 1.1
|
||||
|
||||
Hacki (2 Sep 2009)
|
||||
- added knownhost.c to makefiles.
|
||||
|
||||
Alexander Lamaison (2 Sep 2009)
|
||||
- Pass private-key to OpenSSL as a filename with BIO_new_file().
|
||||
|
||||
This keeps all FILE* handling on the OpenSSL side of the DLL boundary avoiding crashes on Windows while removing the need for libssh2 to read the private key file into memory. This is now done by OpenSSL which is likely to do a better job of it.
|
||||
|
||||
Daniel Stenberg (1 Sep 2009)
|
||||
- generate and install libssh2.pc
|
||||
|
||||
oh these are necessary libssh2.pc changes too
|
||||
|
||||
- first take at producing and installing a pkg-config file
|
||||
|
||||
- renamed to .ac
|
||||
|
||||
- renamed to the modern name "configure.ac"
|
||||
|
||||
- always braces and else and brace on the same line removed
|
||||
|
||||
I don't follow those particular guidelines myself so I think I'd
|
||||
rather remove them here and keep my style than the opposite. As
|
||||
I am the most frequent writer of code for the moment.
|
||||
|
||||
- _libssh2_channel_write() only sends the 32K first bytes
|
||||
|
||||
In theory we could split larger buffers into several smaller
|
||||
packets to pass to transport_write(), but for now we instead only
|
||||
deal with the first 32K in this call and assume the app will call
|
||||
this function again with the rest! The 32K size is a
|
||||
conservative limit based on the text in RFC4253 section 6.1.
|
||||
|
||||
- document _libssh2_channel_write's return code
|
||||
|
||||
- s/libssh2_channel_write_ex/_libssh2_channel_write internally
|
||||
|
||||
- call libssh2_error() when transport_write() returns EAGAIN
|
||||
|
||||
_libssh2_channel_write() should never return error without
|
||||
libssh2_error() getting called
|
||||
|
||||
- clarify that zero can be returned without meaning error
|
||||
|
||||
- remove debug leftovers
|
||||
|
||||
- channel_read() was changed to _libssh2_channel_read() as lots of
|
||||
internal code was changed to use that instead of wrongly using
|
||||
libssh2_channel_read_ex(). Some files now need to include
|
||||
channel.h to get this proto.
|
||||
|
||||
channel_read() calls libssh2_error() properly on transport_read()
|
||||
failures
|
||||
|
||||
channel_read() was adjusted to not "invent" EAGAIN return code in
|
||||
case the transport_read() didn't return it
|
||||
|
||||
channel_close() now returns 0 or error code, as
|
||||
documented. Previously it would return number of bytes read in
|
||||
the last read, which was confusing (and useless).
|
||||
|
||||
- changed all return EAGAIN to return the variable instead
|
||||
|
||||
I made this change just to easier grep for "return .*EAGAIN" cases
|
||||
as they should be very rare or done wrongly. Already worked to find
|
||||
a flaw, marked with "TODO FIXME THIS IS WRONG" in channel.c. I also
|
||||
fixed a few cases to become more general returns now when we have
|
||||
more unified return codes internally.
|
||||
|
||||
- _libssh2_channel_write() must not invent EAGAIN situations
|
||||
|
||||
it is important that only the transport layer can generate EAGAIN
|
||||
error codes so that we limit where we need to set direction bits
|
||||
and more. When the local window is too small to send data we simply
|
||||
stop trying to send and (risk) returning zero in
|
||||
_libssh2_channel_write()
|
||||
|
||||
- error code cleanup
|
||||
|
||||
- remove all libssh2pack_t leftovers
|
||||
|
||||
- removed the libssh2pack_t type
|
||||
|
||||
and a minor _libssh2_transport_read() simplification
|
||||
|
||||
- fix return codes, shortened a very long function name
|
||||
|
||||
- remove use of libssh2_channel_receive_window_adjust
|
||||
|
||||
_libssh2_channel_receive_window_adjust is the new replacement that
|
||||
is both the correct internal version instead of the external API one,
|
||||
and it has the return code flaw fixed. I also fixed more return
|
||||
codes to pass long the correct error found.
|
||||
|
||||
- more proper return codes, added a missing libssh2_error() call
|
||||
|
||||
- clear socket_block_directions bits before send/recv
|
||||
|
||||
These two places are the only places where send and recv are called
|
||||
outside of transport.c so make sure they clear/set the bits correctly.
|
||||
|
||||
- simplified fullpacket, clarified _libssh2_transport_write() comment
|
||||
|
||||
- cleaned up _libssh2_packet_add()
|
||||
|
||||
removed some code duplication, changed a few return -1 to return
|
||||
error codes instead and added a missing libssh2_error() invoke
|
||||
|
||||
- convert return -1 instances to return [proper error code]
|
||||
|
||||
- simplify code by removing code duplication
|
||||
|
||||
- fix several return -1 to return a proper error code
|
||||
|
||||
On many places in the code there have been laziness return -1
|
||||
statements lying around that should be fixed to return sensible
|
||||
error codes. Here's a take at fixing a few offenders.
|
||||
|
||||
- change transport to use unified error codes
|
||||
|
||||
I added three new public error codes, and then modified the return
|
||||
codes we use in the transport layer to use the generic error codes
|
||||
so that there won't be any risk of internal confusions due to
|
||||
different error code sets.
|
||||
|
||||
- changes from int to libssh2_socket_t for sokcets
|
||||
|
||||
modified two functions to use libssh2_socket_t instead of int
|
||||
when referring to a socket descriptor
|
||||
|
||||
- introducing libssh2_socket_t type and fixed iovec for windows
|
||||
|
||||
Steven Van Ingelgem introduces libssh2_socket_t as a generic socket
|
||||
type to use internally to avoid compiler warnings and mistakes. Also,
|
||||
the private struct iovec declaration for windows is now made to look
|
||||
like the POSIX struct does.
|
||||
|
||||
- linked list changes and minor bug fixes
|
||||
|
||||
- linked list code is now converted to new functions
|
||||
|
||||
- remove superfluous braces and re-indent somewhat
|
||||
|
||||
- move over lots of code to the _libssh2_list_* functions
|
||||
|
||||
and I fixed a few minor bugs at the same time
|
||||
|
||||
- converted listeners to the linked list functions
|
||||
|
||||
- moved the handling of SFTP handles to new linked list code
|
||||
|
||||
Each SFTP file handle is now handled by the "mother-struct"
|
||||
using the generic linked list functions. The goal is to move
|
||||
all custom linked list code to use this set of functions.
|
||||
|
||||
I also moved the list declarations to the misc.h where they
|
||||
belong and made misc.h no longer include libssh2_priv.h itself
|
||||
since now libssh2_priv.h needs misc.h...
|
||||
|
||||
In misc.c I added a #if 0'ed _libssh2_list_insert() function
|
||||
because I ended up writing one, and I believe we may need it here
|
||||
too once we move over more stuff to use the _libssh2_list* family.
|
||||
|
||||
- correct the comment for _libssh2_list_add()
|
||||
|
||||
it adds the new node to the _end_ of the list
|
||||
|
||||
Alexander Lamaison (16 Aug 2009)
|
||||
- [Steven Van Ingelgem brought this change]
|
||||
|
||||
Suppress signed/unsigned comparison warning.
|
||||
|
||||
Daniel Stenberg (11 Aug 2009)
|
||||
- added contributors from the 1.2 release notes
|
||||
|
||||
Simon Josefsson (11 Aug 2009)
|
||||
- Need to use $(EXEEXT) on programs in TESTS to fix mingw cross-compiles.
|
||||
|
||||
Daniel Stenberg (10 Aug 2009)
|
||||
- start working on 1.2.1
|
||||
|
||||
Version 1.2 (10 Aug 2009)
|
||||
|
||||
Daniel Stenberg (10 Aug 2009)
|
||||
- Version 1.2 (August 10, 2009)
|
||||
|
||||
- revert parts of the b95fe985af3c80a2babcaaaf7da69a15b1237c49 commit
|
||||
|
||||
Alexander Lamaison tracked down that my previous commit broke SFTP
|
||||
reads in some aspects. The reversion now gets back to always recv()
|
||||
until EAGAIN is returned so that the code no longer treats a short
|
||||
read as an indication that it is "enough for now".
|
||||
|
||||
The bad commit in particular had another independent change included,
|
||||
which is to clear the direction-bits first in the transport read
|
||||
and write functions, but this reversion does not revert that change.
|
||||
Clearing those bits first is a good thing.
|
||||
|
||||
- Fix some nroff formatting
|
||||
|
||||
Patch by Sofian Brabez
|
||||
|
||||
Alexander Lamaison (2 Aug 2009)
|
||||
- Replaced calls to OpenSSL FILE-pointer functions.
|
||||
|
||||
Passing a FILE* argument across a DLL boundary causes problems on Windows. Instead the keys are read into memory by libssh2 and passed to the OpenSSL functions as BIO* arguments.
|
||||
|
||||
Daniel Stenberg (31 Jul 2009)
|
||||
- Add missing names
|
||||
|
||||
I went over the NEWS and git log outputs and added all mentioned
|
||||
contributors through the project's history. I want us to make an
|
||||
effort to give credit to everyone who contributes, big or small.
|
||||
|
||||
- fix the C99 variadic macro use for _libssh2_debug()
|
||||
|
||||
George Neill pointed out that the C99 vararg marcro use was
|
||||
wrong, and I edited his suggested patch slightly and unified
|
||||
both prec99-GCC and C99 into the same macro.
|
||||
|
||||
- Include RELEASE-NOTES in the release package
|
||||
|
||||
- Release notes for the pending release
|
||||
|
||||
I hope to maintain this file during development so that we also add
|
||||
changes and bugfixes to it when we change things. Makes the daily
|
||||
snapshots better and makes less of a hurdle when the release day
|
||||
comes.
|
||||
|
||||
- bad debugdump() causes SIGSEGV, partial sends not done right
|
||||
|
||||
The anonymous bug report #2822910 pointed out that debugdump() was
|
||||
stupidly called within the send_existing() function. At closer
|
||||
inspection was the report not only right, but it also revealed
|
||||
another problem to me: when the _libssh2_send() function returns
|
||||
after sending only a part of the buffer, it would then misbehave.
|
||||
This probably is very rare though, which must be the reason we
|
||||
haven't seen a bigger problem with this.
|
||||
|
||||
Simon Josefsson (28 Jul 2009)
|
||||
- Silcen compiler warnings.
|
||||
|
||||
Daniel Stenberg (27 Jul 2009)
|
||||
- added two new issues to fix: socket type and better windowing
|
||||
|
||||
* make sure the windowing code adapts better to slow situations so that it
|
||||
doesn't then use as much memory as today
|
||||
|
||||
* Introduce a 'libssh2_socket_t' type for sockets in internal code
|
||||
|
||||
- remove superfluous check for large packets
|
||||
|
||||
as we're already doing the correct check further down anyway there's no point
|
||||
in doing the (wrong) check further up as well. Paul Veldkamp pointed this out.
|
||||
|
||||
Simon Josefsson (22 Jul 2009)
|
||||
- Fix make distcheck problems.
|
||||
|
||||
Daniel Stenberg (18 Jul 2009)
|
||||
- parts of the previous VS project files commit
|
||||
|
||||
- From: Neil Gierman <ngierman@roadrunn.com>
|
||||
|
||||
Makefile changes to generate MSVS project files
|
||||
|
||||
- I integrated the libssh2_lib.dsp and libssh2_dll.dsp into a single
|
||||
libssh2.dsp with different targets for lib vs dll
|
||||
- Since I run Visual Studio 2008 with VC++9 I did not do vcproj files since
|
||||
I would have newer vc8proj.head|foot than what others will be running
|
||||
- My patch only has changes to Makefile.am's. I noticed that Makefile.in's
|
||||
are included in the daily snapshots but they should be generated from the
|
||||
.am's
|
||||
- The 3 new files are msvcproj.head and msvcproj.foot for the beginning and
|
||||
ending of the dsp file, and a new Makefile.inc that will have the source and
|
||||
header file names. NOTE: All new source files will need to be added to
|
||||
Makefile.inc and NOT Makefile.am now.
|
||||
- I moved the win32 dir before the include dir
|
||||
- I modified the dsw file so it points to the new libssh2.dsp project file
|
||||
|
||||
- From: Alexander Lamaison <swish@lammy.co.uk>
|
||||
Make the public headers includable on their own
|
||||
|
||||
- From: Steven Van Ingelgem <steven@vaningelgem.be>
|
||||
check first for libtoolize, and then for glibtoolize
|
||||
|
||||
Mac OS X (and others?) needs this
|
||||
|
||||
- Fix knownhost checking of non-hashed hosts
|
||||
|
||||
From: Ben Kibbey <bjk@luxsci.net>
|
||||
|
||||
- Fix the functionality again with hashed host names again.
|
||||
|
||||
The breakage came with commit 8b46528c0476af50a43b6e619f2db318a0cad194.
|
||||
|
||||
- [Peter Stuge brought this change]
|
||||
|
||||
Update mailing list URL to new address
|
||||
|
||||
- const'ify two arguments to libssh2_knownhost_check()
|
||||
|
||||
- Fix compiler warnings appearing with VS2008. Based on Steven Van Ingelgem's
|
||||
patch in #2787839 with a bunch of additional edits by yours truly.
|
||||
|
||||
- Applied Francois Dupoux's extra checks for weird packet or padding length in
|
||||
incoming packets. We really need to bail out this way on weird input.
|
||||
bug report #2814613
|
||||
|
||||
- Mark McPherson posted bug report #2815836 pointing out that the custom memory
|
||||
functions were not given the correct data as argument. This is now fixed even
|
||||
if I personally don't quite grasp why abstract is passed as a pointer to
|
||||
pointer all over libssh2...
|
||||
|
||||
- Ben Kibbey added a type parameter to the libssh2_session_hostkey() function,
|
||||
which hasn't yet been in a public release so changing the API is fine!
|
||||
|
||||
- Guenter Knauf fixed this example to build on win32
|
||||
|
||||
- corrected (again)
|
||||
|
||||
- clarify
|
||||
|
||||
- Neil Gierman pointed out in bug report #2809163 that these two files cannot
|
||||
include the public libssh2.h header as it breaks the compile on window. I'll
|
||||
adapt to this now, but in the long run I think we should rather fix the
|
||||
includes so that we _can_ include the public headers properly.
|
||||
|
||||
- fixed the length check in knownhost_writeline() since <= is actually good
|
||||
enough when the size includes the trailing zero
|
||||
|
||||
- After a mention from Ben Kibbey we now let knownhost_writeline() return the
|
||||
length of the actual data it returns, excluding the trailing zero. I also
|
||||
updated the man page for libssh2_knownhost_writeline() accordingly.
|
||||
|
||||
- empty line removed
|
||||
|
||||
- Ben Kibbey fixed the hostline() when parsing lines using only one hostname
|
||||
|
||||
- Merge branch 'master' of ssh://bagder@git.stuge.se/var/lib/git/libssh2
|
||||
|
||||
@@ -1,45 +1,56 @@
|
||||
libssh2 1.6.0
|
||||
libssh2 1.7.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o Added CMake build system
|
||||
o Added libssh2_userauth_publickey_frommemory()
|
||||
o libssh2_session_set_last_error: Add function
|
||||
o mac: Add support for HMAC-SHA-256 and HMAC-SHA-512
|
||||
o WinCNG: support for SHA256/512 HMAC
|
||||
o kex: Added diffie-hellman-group-exchange-sha256 support
|
||||
o OS/400 crypto library QC3 support
|
||||
|
||||
This release includes the following security advisory:
|
||||
|
||||
o diffie_hellman_sha256: convert bytes to bits
|
||||
CVE-2016-0787: http://www.libssh2.org/adv_20160223.html
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o wait_socket: wrong use of difftime() [1]
|
||||
o userauth: Fixed prompt text no longer being copied to the prompts struct
|
||||
o mingw build: allow to pass custom CFLAGS
|
||||
o Let mansyntax.sh work regardless of where it is called from
|
||||
o Init HMAC_CTX before using it
|
||||
o direct_tcpip: Fixed channel write
|
||||
o WinCNG: fixed backend breakage
|
||||
o OpenSSL: caused by introducing libssh2_hmac_ctx_init
|
||||
o userauth.c: fix possible dereferences of a null pointer
|
||||
o wincng: Added explicit clear memory feature to WinCNG backend
|
||||
o openssl.c: fix possible segfault in case EVP_DigestInit fails
|
||||
o wincng: fix return code of libssh2_md5_init()
|
||||
o kex: do not ignore failure of libssh2_sha1_init()
|
||||
o scp: fix that scp_send may transmit not initialised memory [3]
|
||||
o scp.c: improved command length calculation
|
||||
o nonblocking examples: fix warning about unused tvdiff on Mac OS X
|
||||
o configure: make clear-memory default but WARN if backend unsupported
|
||||
o OpenSSL: Enable use of OpenSSL that doesn't have DSA
|
||||
o OpenSSL: Use correct no-blowfish #define
|
||||
o kex: fix libgcrypt memory leaks of bignum [2]
|
||||
o libssh2_channel_open: more detailed error message
|
||||
o wincng: fixed memleak in (block) cipher destructor
|
||||
|
||||
o SFTP: Increase speed and datasize in SFTP read
|
||||
o openssl: make libssh2_sha1 return error code
|
||||
o openssl: fix memleak in _libssh2_dsa_sha1_verify()
|
||||
o cmake: include CMake files in the release tarballs
|
||||
o Fix builds with Visual Studio 2015
|
||||
o hostkey.c: Fix compiling error when OPENSSL_NO_MD5 is defined
|
||||
o GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS
|
||||
o GNUmakefile: add -m64 CFLAGS when targeting mingw64
|
||||
o kex: free server host key before allocating it (again)
|
||||
o SCP: add libssh2_scp_recv2 to support large (> 2GB) files on windows
|
||||
o channel: Detect bad usage of libssh2_channel_process_startup
|
||||
o userauth: Fix off by one error when reading public key file
|
||||
o kex: removed dupe entry from libssh2_kex_methods
|
||||
o _libssh2_error: Support allocating the error message
|
||||
o hostkey: fix invalid memory access if libssh2_dsa_new fails
|
||||
o hostkey: align code path of ssh_rsa_init to ssh_dss_init
|
||||
o libssh2.pc.in: fix the output of pkg-config --libs
|
||||
o wincng: fixed possible memory leak in _libssh2_wincng_hash
|
||||
o wincng: fixed _libssh2_wincng_hash_final return value
|
||||
o add OpenSSL 1.1.0-pre2 compatibility
|
||||
o agent_disconnect_unix: unset the agent fd after closing it
|
||||
o sftp: stop reading when buffer is full
|
||||
o sftp: Send at least one read request before reading
|
||||
o sftp: Don't return EAGAIN if data was written to buffer
|
||||
o sftp: Check read packet file offset
|
||||
o configure: build "silent" if possible
|
||||
o openssl: add OpenSSL 1.1.0-pre3-dev compatibility
|
||||
o GNUmakefile: list system libs after user libs
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alexander Lamaison, Daniel Stenberg, David Calavera, Hannes Domani,
|
||||
Jakob Egger, Joe Turpin, Marc Hoersken, Viktor Szakáts, Will Cosgrove,
|
||||
(9 contributors)
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
Alexander Lamaison, Andreas Schneider, brian m. carlson, Daniel Stenberg,
|
||||
David Byron, Jakob Egger, Kamil Dudka, Marc Hoersken, Mizunashi Mana,
|
||||
Patrick Monnerat, Paul Howarth, Salvador Fandino, Salvador Fandiño,
|
||||
Salvador Fandiño, Viktor Szakats, Will Cosgrove,
|
||||
(16 contributors)
|
||||
|
||||
[1] = https://github.com/bagder/libssh2/issues/1
|
||||
[2] = https://trac.libssh2.org/ticket/168
|
||||
[3] = https://trac.libssh2.org/ticket/244
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
||||
57
aclocal.m4
vendored
57
aclocal.m4
vendored
@@ -1,6 +1,6 @@
|
||||
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.15 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.14'
|
||||
[am__api_version='1.15'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.14.1], [],
|
||||
m4_if([$1], [1.15], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.14.1])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.15])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -498,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
|
||||
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
|
||||
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
# We need awk for the "check" target (and possibly the TAP driver). The
|
||||
# system "awk" is bad on some platforms.
|
||||
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
@@ -573,6 +573,9 @@ END
|
||||
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
|
||||
fi
|
||||
fi
|
||||
dnl The trailing newline in this macro's definition is deliberate, for
|
||||
dnl backward compatibility and to allow trailing 'dnl'-style comments
|
||||
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
|
||||
])
|
||||
|
||||
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
|
||||
@@ -602,7 +605,7 @@ for _am_header in $config_headers :; do
|
||||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -613,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
|
||||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
if test x"${install_sh}" != xset; then
|
||||
if test x"${install_sh+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
@@ -623,7 +626,7 @@ if test x"${install_sh}" != xset; then
|
||||
fi
|
||||
AC_SUBST([install_sh])])
|
||||
|
||||
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -645,7 +648,7 @@ AC_SUBST([am__leading_dot])])
|
||||
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||
# From Jim Meyering
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -680,7 +683,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -730,7 +733,7 @@ rm -f confinc confmf
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -769,7 +772,7 @@ fi
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -798,7 +801,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -845,7 +848,7 @@ AC_LANG_POP([C])])
|
||||
# For backward compatibility.
|
||||
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -864,7 +867,7 @@ AC_DEFUN([AM_RUN_LOG],
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -945,7 +948,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
rm -f conftest.file
|
||||
])
|
||||
|
||||
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1005,7 +1008,7 @@ AC_SUBST([AM_BACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
|
||||
])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1033,7 +1036,7 @@ fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1052,7 +1055,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
# - check_function_exists_maybe_need_library(<function> <var> [lib1 ... libn])
|
||||
#
|
||||
# Check if function is available for linking, first without extra libraries, and
|
||||
# then, if not found that way, linking in each optional library as well. This
|
||||
# function is similar to autotools AC_SEARCH_LIBS.
|
||||
#
|
||||
# If the function if found, this will define <var>.
|
||||
#
|
||||
# If the function was only found by linking in an additional library, this
|
||||
# will define NEED_LIB_LIBX, where LIBX is the one of lib1 to libn that
|
||||
# makes the function available, in uppercase.
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
function(check_function_exists_may_need_library function variable)
|
||||
|
||||
check_function_exists(${function} ${variable})
|
||||
|
||||
if(NOT ${variable})
|
||||
foreach(lib ${ARGN})
|
||||
string(TOUPPER ${lib} UP_LIB)
|
||||
# Use new variable to prevent cache from previous step shortcircuiting
|
||||
# new test
|
||||
check_library_exists(${lib} ${function} "" HAVE_${function}_IN_${lib})
|
||||
if(HAVE_${function}_IN_${lib})
|
||||
set(${variable} 1 CACHE INTERNAL
|
||||
"Function ${function} found in library ${lib}")
|
||||
set(NEED_LIB_${UP_LIB} 1 CACHE INTERNAL
|
||||
"Need to link ${lib}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
@@ -0,0 +1,119 @@
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
# - check_nonblocking_socket_support()
|
||||
#
|
||||
# Check for how to set a socket to non-blocking state. There seems to exist
|
||||
# four known different ways, with the one used almost everywhere being POSIX
|
||||
# and XPG3, while the other different ways for different systems (old BSD,
|
||||
# Windows and Amiga).
|
||||
#
|
||||
# One of the following variables will be set indicating the supported
|
||||
# method (if any):
|
||||
# HAVE_O_NONBLOCK
|
||||
# HAVE_FIONBIO
|
||||
# HAVE_IOCTLSOCKET
|
||||
# HAVE_IOCTLSOCKET_CASE
|
||||
# HAVE_SO_NONBLOCK
|
||||
# HAVE_DISABLED_NONBLOCKING
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
macro(check_nonblocking_socket_support)
|
||||
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
|
||||
# O_NONBLOCK define is found but does not work.
|
||||
check_c_source_compiles("
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
# if defined(__SVR4) || defined(__srv4__)
|
||||
# define PLATFORM_SOLARIS
|
||||
# else
|
||||
# define PLATFORM_SUNOS4
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
|
||||
# define PLATFORM_AIX_V3
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
|
||||
#error \"O_NONBLOCK does not work on this platform\"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
||||
}"
|
||||
HAVE_O_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_O_NONBLOCK)
|
||||
check_c_source_compiles("/* FIONBIO test (old-style unix) */
|
||||
#include <unistd.h>
|
||||
#include <stropts.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = ioctl(socket, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_FIONBIO)
|
||||
|
||||
if(NOT HAVE_FIONBIO)
|
||||
check_c_source_compiles("/* ioctlsocket test (Windows) */
|
||||
#undef inline
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
SOCKET sd;
|
||||
unsigned long flags = 0;
|
||||
sd = socket(0, 0, 0);
|
||||
ioctlsocket(sd, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET)
|
||||
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = IoctlSocket(socket, FIONBIO, (long)1);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET_CASE)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET_CASE)
|
||||
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
|
||||
#include <socket.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
long b = 1;
|
||||
int socket;
|
||||
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
|
||||
}"
|
||||
HAVE_SO_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_SO_NONBLOCK)
|
||||
# No non-blocking socket method found
|
||||
set(HAVE_DISABLED_NONBLOCKING 1)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
72
cmake/CopyRuntimeDependencies.cmake
Normal file
72
cmake/CopyRuntimeDependencies.cmake
Normal file
@@ -0,0 +1,72 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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(CMakeParseArguments)
|
||||
|
||||
function(ADD_TARGET_TO_COPY_DEPENDENCIES)
|
||||
set(options)
|
||||
set(oneValueArgs TARGET)
|
||||
set(multiValueArgs DEPENDENCIES BEFORE_TARGETS)
|
||||
cmake_parse_arguments(COPY
|
||||
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT COPY_DEPENDENCIES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Using a custom target to drive custom commands stops multiple
|
||||
# parallel builds trying to kick off the commands at the same time
|
||||
add_custom_target(${COPY_TARGET})
|
||||
|
||||
foreach(target ${COPY_BEFORE_TARGETS})
|
||||
add_dependencies(${target} ${COPY_TARGET})
|
||||
endforeach()
|
||||
|
||||
foreach(dependency ${COPY_DEPENDENCIES})
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${COPY_TARGET}
|
||||
DEPENDS ${dependency}
|
||||
# Make directory first otherwise file is copied in place of
|
||||
# directory instead of into it
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${dependency} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
VERBATIM)
|
||||
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
53
cmake/FindLibgcrypt.cmake
Normal file
53
cmake/FindLibgcrypt.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
# - Try to find Libgcrypt
|
||||
# This will define all or none of:
|
||||
# LIBGCRYPT_FOUND - if Libgcrypt headers and library was found
|
||||
# LIBGCRYPT_INCLUDE_DIRS - The Libgcrypt include directories
|
||||
# LIBGCRYPT_LIBRARIES - The libraries needed to use Libgcrypt
|
||||
|
||||
find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h)
|
||||
|
||||
find_library(LIBGCRYPT_LIBRARY NAMES gcrypt libgcrypt)
|
||||
|
||||
set(LIBGCRYPT_LIBRARIES ${LIBGCRYPT_LIBRARY})
|
||||
set(LIBGCRYPT_INCLUDE_DIRS ${LIBGCRYPT_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libgcrypt DEFAULT_MSG
|
||||
LIBGCRYPT_LIBRARY LIBGCRYPT_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)
|
||||
64
cmake/SocketLibraries.cmake
Normal file
64
cmake/SocketLibraries.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Some systems have their socket functions in a library.
|
||||
# (Solaris -lsocket/-lnsl, Windows -lws2_32). This macro appends those
|
||||
# libraries to the given list
|
||||
macro(append_needed_socket_libraries LIBRARIES_LIST)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# x86 Windows uses STDCALL for these functions, so their names are mangled,
|
||||
# meaning the platform checks don't work. Hardcoding these until we get
|
||||
# a better solution.
|
||||
set(HAVE_SOCKET 1)
|
||||
set(HAVE_SELECT 1)
|
||||
set(HAVE_INET_ADDR 1)
|
||||
set(NEED_LIB_WS2_32 1)
|
||||
else()
|
||||
check_function_exists_may_need_library(socket HAVE_SOCKET socket ws2_32)
|
||||
check_function_exists_may_need_library(select HAVE_SELECT ws2_32)
|
||||
check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl ws2_32)
|
||||
endif()
|
||||
|
||||
if(NEED_LIB_SOCKET)
|
||||
list(APPEND ${LIBRARIES_LIST} socket)
|
||||
endif()
|
||||
if(NEED_LIB_NSL)
|
||||
list(APPEND ${LIBRARIES_LIST} nsl)
|
||||
endif()
|
||||
if(NEED_LIB_WS2_32)
|
||||
list(APPEND ${LIBRARIES_LIST} ws2_32)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
42
cmake/Toolchain-Linux-32.cmake
Normal file
42
cmake/Toolchain-Linux-32.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Cross-compile 32-bit binary on 64-bit linux host
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "i386")
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
|
||||
set(CMAKE_C_COMPILER_ARG1 "-m32")
|
||||
23
cmake/max_warnings.cmake
Normal file
23
cmake/max_warnings.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
if(MSVC)
|
||||
# Use the highest warning level for visual studio.
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
endif()
|
||||
|
||||
# Disable broken warnings
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif()
|
||||
if(NOT CMAKE_C_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
endif()
|
||||
endif()
|
||||
123
configure
vendored
123
configure
vendored
@@ -646,6 +646,8 @@ LIBZ_PREFIX
|
||||
LTLIBZ
|
||||
LIBZ
|
||||
HAVE_LIBZ
|
||||
OS400QC3_FALSE
|
||||
OS400QC3_TRUE
|
||||
WINCNG_FALSE
|
||||
WINCNG_TRUE
|
||||
LIBCRYPT32_PREFIX
|
||||
@@ -719,10 +721,6 @@ build_vendor
|
||||
build_cpu
|
||||
build
|
||||
LIBSSH2VER
|
||||
AM_BACKSLASH
|
||||
AM_DEFAULT_VERBOSITY
|
||||
AM_DEFAULT_V
|
||||
AM_V
|
||||
am__untar
|
||||
am__tar
|
||||
AMTAR
|
||||
@@ -747,6 +745,10 @@ INSTALL_DATA
|
||||
INSTALL_SCRIPT
|
||||
INSTALL_PROGRAM
|
||||
SED
|
||||
AM_BACKSLASH
|
||||
AM_DEFAULT_VERBOSITY
|
||||
AM_DEFAULT_V
|
||||
AM_V
|
||||
MAINT
|
||||
MAINTAINER_MODE_FALSE
|
||||
MAINTAINER_MODE_TRUE
|
||||
@@ -769,6 +771,7 @@ infodir
|
||||
docdir
|
||||
oldincludedir
|
||||
includedir
|
||||
runstatedir
|
||||
localstatedir
|
||||
sharedstatedir
|
||||
sysconfdir
|
||||
@@ -867,6 +870,7 @@ datadir='${datarootdir}'
|
||||
sysconfdir='${prefix}/etc'
|
||||
sharedstatedir='${prefix}/com'
|
||||
localstatedir='${prefix}/var'
|
||||
runstatedir='${localstatedir}/run'
|
||||
includedir='${prefix}/include'
|
||||
oldincludedir='/usr/include'
|
||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||
@@ -1119,6 +1123,15 @@ do
|
||||
| -silent | --silent | --silen | --sile | --sil)
|
||||
silent=yes ;;
|
||||
|
||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
||||
| --run | --ru | --r)
|
||||
ac_prev=runstatedir ;;
|
||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
||||
| --run=* | --ru=* | --r=*)
|
||||
runstatedir=$ac_optarg ;;
|
||||
|
||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||
ac_prev=sbindir ;;
|
||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||
@@ -1256,7 +1269,7 @@ fi
|
||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||
libdir localedir mandir
|
||||
libdir localedir mandir runstatedir
|
||||
do
|
||||
eval ac_val=\$$ac_var
|
||||
# Remove trailing slashes.
|
||||
@@ -1409,6 +1422,7 @@ Fine tuning of the installation directories:
|
||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||
--includedir=DIR C header files [PREFIX/include]
|
||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||
@@ -2421,6 +2435,45 @@ fi
|
||||
MAINT=$MAINTAINER_MODE_TRUE
|
||||
|
||||
|
||||
# Check whether --enable-silent-rules was given.
|
||||
if test "${enable_silent_rules+set}" = set; then :
|
||||
enableval=$enable_silent_rules;
|
||||
fi
|
||||
|
||||
case $enable_silent_rules in # (((
|
||||
yes) AM_DEFAULT_VERBOSITY=0;;
|
||||
no) AM_DEFAULT_VERBOSITY=1;;
|
||||
*) AM_DEFAULT_VERBOSITY=0;;
|
||||
esac
|
||||
am_make=${MAKE-make}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
|
||||
$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
|
||||
if ${am_cv_make_support_nested_variables+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if $as_echo 'TRUE=$(BAR$(V))
|
||||
BAR0=false
|
||||
BAR1=true
|
||||
V=1
|
||||
am__doit:
|
||||
@$(TRUE)
|
||||
.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
|
||||
am_cv_make_support_nested_variables=yes
|
||||
else
|
||||
am_cv_make_support_nested_variables=no
|
||||
fi
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
|
||||
$as_echo "$am_cv_make_support_nested_variables" >&6; }
|
||||
if test $am_cv_make_support_nested_variables = yes; then
|
||||
AM_V='$(V)'
|
||||
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
|
||||
else
|
||||
AM_V=$AM_DEFAULT_VERBOSITY
|
||||
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
|
||||
fi
|
||||
AM_BACKSLASH='\'
|
||||
|
||||
|
||||
# Extract the first word of "sed", so it can be a program name with args.
|
||||
set dummy sed; ac_word=$2
|
||||
@@ -2472,7 +2525,7 @@ $as_echo "$as_me: WARNING: sed was not found, this may ruin your chances to buil
|
||||
fi
|
||||
|
||||
LIBSSH2VER=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
|
||||
am__api_version='1.14'
|
||||
am__api_version='1.15'
|
||||
|
||||
ac_aux_dir=
|
||||
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
|
||||
@@ -2693,7 +2746,7 @@ else
|
||||
$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
|
||||
fi
|
||||
|
||||
if test x"${install_sh}" != xset; then
|
||||
if test x"${install_sh+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
@@ -2926,45 +2979,6 @@ else
|
||||
fi
|
||||
rmdir .tst 2>/dev/null
|
||||
|
||||
# Check whether --enable-silent-rules was given.
|
||||
if test "${enable_silent_rules+set}" = set; then :
|
||||
enableval=$enable_silent_rules;
|
||||
fi
|
||||
|
||||
case $enable_silent_rules in # (((
|
||||
yes) AM_DEFAULT_VERBOSITY=0;;
|
||||
no) AM_DEFAULT_VERBOSITY=1;;
|
||||
*) AM_DEFAULT_VERBOSITY=1;;
|
||||
esac
|
||||
am_make=${MAKE-make}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
|
||||
$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
|
||||
if ${am_cv_make_support_nested_variables+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if $as_echo 'TRUE=$(BAR$(V))
|
||||
BAR0=false
|
||||
BAR1=true
|
||||
V=1
|
||||
am__doit:
|
||||
@$(TRUE)
|
||||
.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
|
||||
am_cv_make_support_nested_variables=yes
|
||||
else
|
||||
am_cv_make_support_nested_variables=no
|
||||
fi
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
|
||||
$as_echo "$am_cv_make_support_nested_variables" >&6; }
|
||||
if test $am_cv_make_support_nested_variables = yes; then
|
||||
AM_V='$(V)'
|
||||
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
|
||||
else
|
||||
AM_V=$AM_DEFAULT_VERBOSITY
|
||||
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
|
||||
fi
|
||||
AM_BACKSLASH='\'
|
||||
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`"; then
|
||||
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
|
||||
# is not polluted with repeated "-I."
|
||||
@@ -3021,8 +3035,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
|
||||
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
|
||||
mkdir_p='$(MKDIR_P)'
|
||||
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
# We need awk for the "check" target (and possibly the TAP driver). The
|
||||
# system "awk" is bad on some platforms.
|
||||
# Always define AMTAR for backward compatibility. Yes, it's still used
|
||||
# in the wild :-( We should find a proper way to deprecate it ...
|
||||
AMTAR='$${TAR-tar}'
|
||||
@@ -15949,6 +15963,15 @@ else
|
||||
fi
|
||||
|
||||
|
||||
if false; then
|
||||
OS400QC3_TRUE=
|
||||
OS400QC3_FALSE='#'
|
||||
else
|
||||
OS400QC3_TRUE='#'
|
||||
OS400QC3_FALSE=
|
||||
fi
|
||||
|
||||
|
||||
# Check if crypto library was found
|
||||
if test "$found_crypto" = "none"; then
|
||||
as_fn_error $? "No crypto library found!
|
||||
@@ -17627,6 +17650,10 @@ if test -z "${WINCNG_TRUE}" && test -z "${WINCNG_FALSE}"; then
|
||||
as_fn_error $? "conditional \"WINCNG\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${OS400QC3_TRUE}" && test -z "${OS400QC3_FALSE}"; then
|
||||
as_fn_error $? "conditional \"OS400QC3\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${BUILD_EXAMPLES_TRUE}" && test -z "${BUILD_EXAMPLES_FALSE}"; then
|
||||
as_fn_error $? "conditional \"BUILD_EXAMPLES\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
|
||||
@@ -4,6 +4,7 @@ AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src])
|
||||
AC_CONFIG_HEADERS([src/libssh2_config.h example/libssh2_config.h])
|
||||
AM_MAINTAINER_MODE
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
dnl SED is needed by some of the tools
|
||||
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
|
||||
@@ -160,6 +161,8 @@ if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
fi
|
||||
AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes")
|
||||
|
||||
AM_CONDITIONAL(OS400QC3, false)
|
||||
|
||||
# Check if crypto library was found
|
||||
if test "$found_crypto" = "none"; then
|
||||
AC_MSG_ERROR([No crypto library found!
|
||||
|
||||
206
docs/CMakeLists.txt
Normal file
206
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,206 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
set(MAN_PAGES
|
||||
libssh2_agent_connect.3
|
||||
libssh2_agent_disconnect.3
|
||||
libssh2_agent_free.3
|
||||
libssh2_agent_get_identity.3
|
||||
libssh2_agent_init.3
|
||||
libssh2_agent_list_identities.3
|
||||
libssh2_agent_userauth.3
|
||||
libssh2_banner_set.3
|
||||
libssh2_base64_decode.3
|
||||
libssh2_channel_close.3
|
||||
libssh2_channel_direct_tcpip.3
|
||||
libssh2_channel_direct_tcpip_ex.3
|
||||
libssh2_channel_eof.3
|
||||
libssh2_channel_exec.3
|
||||
libssh2_channel_flush.3
|
||||
libssh2_channel_flush_ex.3
|
||||
libssh2_channel_flush_stderr.3
|
||||
libssh2_channel_forward_accept.3
|
||||
libssh2_channel_forward_cancel.3
|
||||
libssh2_channel_forward_listen.3
|
||||
libssh2_channel_forward_listen_ex.3
|
||||
libssh2_channel_free.3
|
||||
libssh2_channel_get_exit_signal.3
|
||||
libssh2_channel_get_exit_status.3
|
||||
libssh2_channel_handle_extended_data.3
|
||||
libssh2_channel_handle_extended_data2.3
|
||||
libssh2_channel_ignore_extended_data.3
|
||||
libssh2_channel_open_ex.3
|
||||
libssh2_channel_open_session.3
|
||||
libssh2_channel_process_startup.3
|
||||
libssh2_channel_read.3
|
||||
libssh2_channel_read_ex.3
|
||||
libssh2_channel_read_stderr.3
|
||||
libssh2_channel_receive_window_adjust.3
|
||||
libssh2_channel_receive_window_adjust2.3
|
||||
libssh2_channel_request_pty.3
|
||||
libssh2_channel_request_pty_ex.3
|
||||
libssh2_channel_request_pty_size.3
|
||||
libssh2_channel_request_pty_size_ex.3
|
||||
libssh2_channel_send_eof.3
|
||||
libssh2_channel_set_blocking.3
|
||||
libssh2_channel_setenv.3
|
||||
libssh2_channel_setenv_ex.3
|
||||
libssh2_channel_shell.3
|
||||
libssh2_channel_subsystem.3
|
||||
libssh2_channel_wait_closed.3
|
||||
libssh2_channel_wait_eof.3
|
||||
libssh2_channel_window_read.3
|
||||
libssh2_channel_window_read_ex.3
|
||||
libssh2_channel_window_write.3
|
||||
libssh2_channel_window_write_ex.3
|
||||
libssh2_channel_write.3
|
||||
libssh2_channel_write_ex.3
|
||||
libssh2_channel_write_stderr.3
|
||||
libssh2_channel_x11_req.3
|
||||
libssh2_channel_x11_req_ex.3
|
||||
libssh2_exit.3
|
||||
libssh2_free.3
|
||||
libssh2_hostkey_hash.3
|
||||
libssh2_init.3
|
||||
libssh2_keepalive_config.3
|
||||
libssh2_keepalive_send.3
|
||||
libssh2_knownhost_add.3
|
||||
libssh2_knownhost_addc.3
|
||||
libssh2_knownhost_check.3
|
||||
libssh2_knownhost_checkp.3
|
||||
libssh2_knownhost_del.3
|
||||
libssh2_knownhost_free.3
|
||||
libssh2_knownhost_get.3
|
||||
libssh2_knownhost_init.3
|
||||
libssh2_knownhost_readfile.3
|
||||
libssh2_knownhost_readline.3
|
||||
libssh2_knownhost_writefile.3
|
||||
libssh2_knownhost_writeline.3
|
||||
libssh2_poll.3
|
||||
libssh2_poll_channel_read.3
|
||||
libssh2_publickey_add.3
|
||||
libssh2_publickey_add_ex.3
|
||||
libssh2_publickey_init.3
|
||||
libssh2_publickey_list_fetch.3
|
||||
libssh2_publickey_list_free.3
|
||||
libssh2_publickey_remove.3
|
||||
libssh2_publickey_remove_ex.3
|
||||
libssh2_publickey_shutdown.3
|
||||
libssh2_scp_recv.3
|
||||
libssh2_scp_recv2.3
|
||||
libssh2_scp_send.3
|
||||
libssh2_scp_send64.3
|
||||
libssh2_scp_send_ex.3
|
||||
libssh2_session_abstract.3
|
||||
libssh2_session_banner_get.3
|
||||
libssh2_session_banner_set.3
|
||||
libssh2_session_block_directions.3
|
||||
libssh2_session_callback_set.3
|
||||
libssh2_session_disconnect.3
|
||||
libssh2_session_disconnect_ex.3
|
||||
libssh2_session_flag.3
|
||||
libssh2_session_free.3
|
||||
libssh2_session_get_blocking.3
|
||||
libssh2_session_get_timeout.3
|
||||
libssh2_session_hostkey.3
|
||||
libssh2_session_init.3
|
||||
libssh2_session_init_ex.3
|
||||
libssh2_session_last_errno.3
|
||||
libssh2_session_last_error.3
|
||||
libssh2_session_set_last_error.3
|
||||
libssh2_session_method_pref.3
|
||||
libssh2_session_methods.3
|
||||
libssh2_session_set_blocking.3
|
||||
libssh2_session_set_timeout.3
|
||||
libssh2_session_startup.3
|
||||
libssh2_session_supported_algs.3
|
||||
libssh2_sftp_close.3
|
||||
libssh2_sftp_close_handle.3
|
||||
libssh2_sftp_closedir.3
|
||||
libssh2_sftp_fsetstat.3
|
||||
libssh2_sftp_fstat.3
|
||||
libssh2_sftp_fstat_ex.3
|
||||
libssh2_sftp_fstatvfs.3
|
||||
libssh2_sftp_fsync.3
|
||||
libssh2_sftp_get_channel.3
|
||||
libssh2_sftp_init.3
|
||||
libssh2_sftp_last_error.3
|
||||
libssh2_sftp_lstat.3
|
||||
libssh2_sftp_mkdir.3
|
||||
libssh2_sftp_mkdir_ex.3
|
||||
libssh2_sftp_open.3
|
||||
libssh2_sftp_open_ex.3
|
||||
libssh2_sftp_opendir.3
|
||||
libssh2_sftp_read.3
|
||||
libssh2_sftp_readdir.3
|
||||
libssh2_sftp_readdir_ex.3
|
||||
libssh2_sftp_readlink.3
|
||||
libssh2_sftp_realpath.3
|
||||
libssh2_sftp_rename.3
|
||||
libssh2_sftp_rename_ex.3
|
||||
libssh2_sftp_rewind.3
|
||||
libssh2_sftp_rmdir.3
|
||||
libssh2_sftp_rmdir_ex.3
|
||||
libssh2_sftp_seek.3
|
||||
libssh2_sftp_seek64.3
|
||||
libssh2_sftp_setstat.3
|
||||
libssh2_sftp_shutdown.3
|
||||
libssh2_sftp_stat.3
|
||||
libssh2_sftp_stat_ex.3
|
||||
libssh2_sftp_statvfs.3
|
||||
libssh2_sftp_symlink.3
|
||||
libssh2_sftp_symlink_ex.3
|
||||
libssh2_sftp_tell.3
|
||||
libssh2_sftp_tell64.3
|
||||
libssh2_sftp_unlink.3
|
||||
libssh2_sftp_unlink_ex.3
|
||||
libssh2_sftp_write.3
|
||||
libssh2_trace.3
|
||||
libssh2_trace_sethandler.3
|
||||
libssh2_userauth_authenticated.3
|
||||
libssh2_userauth_hostbased_fromfile.3
|
||||
libssh2_userauth_hostbased_fromfile_ex.3
|
||||
libssh2_userauth_keyboard_interactive.3
|
||||
libssh2_userauth_keyboard_interactive_ex.3
|
||||
libssh2_userauth_list.3
|
||||
libssh2_userauth_password.3
|
||||
libssh2_userauth_password_ex.3
|
||||
libssh2_userauth_publickey.3
|
||||
libssh2_userauth_publickey_fromfile.3
|
||||
libssh2_userauth_publickey_fromfile_ex.3
|
||||
libssh2_version.3)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
||||
593
docs/HACKING.CRYPTO
Normal file
593
docs/HACKING.CRYPTO
Normal file
@@ -0,0 +1,593 @@
|
||||
Definitions needed to implement a specific crypto library
|
||||
|
||||
This document offers some hints about implementing a new crypto library
|
||||
interface.
|
||||
|
||||
A crypto library interface consists of at least a header file, defining
|
||||
entities referenced from the libssh2 core modules.
|
||||
Real code implementation (if needed), is left at the implementor's choice.
|
||||
|
||||
This document lists the entities that must/may be defined in the header file.
|
||||
|
||||
Procedures listed as "void" may indeed have a result type: the void indication
|
||||
indicates the libssh2 core modules never use the function result.
|
||||
|
||||
|
||||
1) Crypto library initialization/termination.
|
||||
|
||||
void libssh2_crypto_init(void);
|
||||
Initializes the crypto library. May be an empty macro if not needed.
|
||||
|
||||
void libssh2_crypto_exit(void);
|
||||
Terminates the crypto library use. May be an empty macro if not needed.
|
||||
|
||||
|
||||
2) HMAC
|
||||
|
||||
libssh2_hmac_ctx
|
||||
Type of an HMAC computation context. Generally a struct.
|
||||
Used for all hash algorithms.
|
||||
|
||||
void libssh2_hmac_ctx_init(libssh2_hmac_ctx ctx);
|
||||
Initializes the HMAC computation context ctx.
|
||||
Called before setting-up the hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_update(libssh2_hmac_ctx ctx,
|
||||
const unsigned char *data,
|
||||
int datalen);
|
||||
Continue computation of an HMAC on datalen bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_final(libssh2_hmac_ctx ctx,
|
||||
unsigned char output[]);
|
||||
Get the computed HMAC from context ctx into the output buffer. The
|
||||
minimum data buffer size depends on the HMAC hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx);
|
||||
Releases the HMAC computation context at ctx.
|
||||
|
||||
|
||||
3) Hash algorithms.
|
||||
|
||||
3.1) SHA-1
|
||||
Must always be implemented.
|
||||
|
||||
SHA_DIGEST_LENGTH
|
||||
#define to 20, the SHA-1 digest length.
|
||||
|
||||
libssh2_sha1_ctx
|
||||
Type of an SHA1 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha1_init(libssh2_sha1_ctx *x);
|
||||
Initializes the SHA-1 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha1_update(libssh2_sha1_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-1 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha1_final(libssh2_sha1_ctx ctx,
|
||||
unsigned char output[SHA1_DIGEST_LEN]);
|
||||
Get the computed SHA-1 signature from context ctx and store it into the
|
||||
output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_sha1_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-SHA-1 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.2) SHA-256
|
||||
Must always be implemented.
|
||||
|
||||
SHA256_DIGEST_LENGTH
|
||||
#define to 32, the SHA-256 digest length.
|
||||
|
||||
libssh2_sha256_ctx
|
||||
Type of an SHA-256 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha256_init(libssh2_sha256_ctx *x);
|
||||
Initializes the SHA-256 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha256_update(libssh2_sha256_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-256 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha256_final(libssh2_sha256_ctx ctx,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Gets the computed SHA-256 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
int libssh2_sha256(const unsigned char *message,
|
||||
unsigned long len,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Computes the SHA-256 signature over the given message of length len and
|
||||
store the result into the output buffer.
|
||||
Return 1 if error, else 0.
|
||||
Note: Seems unused in current code, but defined in each crypto library backend.
|
||||
|
||||
LIBSSH2_HMAC_SHA256
|
||||
#define as 1 if the crypto library supports HMAC-SHA-256, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_sha256_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-256 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.3) SHA-512
|
||||
LIBSSH2_HMAC_SHA512
|
||||
#define as 1 if the crypto library supports HMAC-SHA-512, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
SHA512_DIGEST_LENGTH
|
||||
#define to 64, the SHA-512 digest length.
|
||||
|
||||
void libssh2_hmac_sha512_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-512 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.4) MD5
|
||||
LIBSSH2_MD5
|
||||
#define to 1 if the crypto library supports MD5, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
MD5_DIGEST_LENGTH
|
||||
#define to 16, the MD5 digest length.
|
||||
|
||||
libssh2_md5_ctx
|
||||
Type of an MD5 computation context. Generally a struct.
|
||||
|
||||
int libssh2_md5_init(libssh2_md5_ctx *x);
|
||||
Initializes the MD5 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_md5_update(libssh2_md5_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continues computation of MD5 on len bytes at data using context ctx.
|
||||
Returns 1 for success and 0 for failure.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_md5_final(libssh2_md5_ctx ctx,
|
||||
unsigned char output[MD5_DIGEST_LENGTH]);
|
||||
Gets the computed MD5 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_md5_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-MD5 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.5) RIPEMD-160
|
||||
LIBSSH2_HMAC_RIPEMD
|
||||
#define as 1 if the crypto library supports HMAC-RIPEMD-160, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_ripemd160_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-RIPEMD-160 computation using
|
||||
the keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
Returns 1 for success and 0 for failure.
|
||||
|
||||
|
||||
4) Bidirectional Key ciphers.
|
||||
|
||||
_libssh2_cipher_ctx
|
||||
Type of a cipher computation context.
|
||||
|
||||
_libssh2_cipher_type(name);
|
||||
Macro defining name as storage identifying a cipher algorithm for
|
||||
the crypto library interface. No trailing semicolon.
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx *h,
|
||||
_libssh2_cipher_type(algo),
|
||||
unsigned char *iv,
|
||||
unsigned char *secret,
|
||||
int encrypt);
|
||||
Creates a cipher context for the given algorithm with the initialization vector
|
||||
iv and the secret key secret. Prepare for encryption or decryption depending on
|
||||
encrypt.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt,
|
||||
unsigned char *block,
|
||||
size_t blocksize);
|
||||
Encrypt or decrypt in-place data at (block, blocksize) using the given
|
||||
context and/or algorithm.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_cipher_dtor(_libssh2_cipher_ctx *ctx);
|
||||
Release cipher context at ctx.
|
||||
|
||||
4.1) AES
|
||||
4.1.1) AES in CBC block mode.
|
||||
LIBSSH2_AES
|
||||
#define as 1 if the crypto library supports AES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_aes128
|
||||
AES-128-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192
|
||||
AES-192-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256
|
||||
AES-256-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.1.2) AES in CTR block mode.
|
||||
LIBSSH2_AES_CTR
|
||||
#define as 1 if the crypto library supports AES in CTR mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void _libssh2_init_aes_ctr(void);
|
||||
Initialize static AES CTR ciphers.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
_libssh2_cipher_aes128ctr
|
||||
AES-128-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192ctr
|
||||
AES-192-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256ctr
|
||||
AES-256-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.2) Blowfish in CBC block mode.
|
||||
LIBSSH2_BLOWFISH
|
||||
#define as 1 if the crypto library supports blowfish in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_blowfish
|
||||
Blowfish-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.3) RC4.
|
||||
LIBSSH2_RC4
|
||||
#define as 1 if the crypto library supports RC4 (arcfour), else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_arcfour
|
||||
RC4 algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.4) CAST5 in CBC block mode.
|
||||
LIBSSH2_CAST
|
||||
#define 1 if the crypto library supports cast, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_cast5
|
||||
CAST5-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.5) Tripple DES in CBC block mode.
|
||||
LIBSSH2_3DES
|
||||
#define as 1 if the crypto library supports TripleDES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_3des
|
||||
TripleDES-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
|
||||
5) Big numbers.
|
||||
Positive multi-byte integers support is sufficient.
|
||||
|
||||
5.1) Computation contexts.
|
||||
This has a real meaning if the big numbers computations need some context
|
||||
storage. If not, use a dummy type and functions (macros).
|
||||
|
||||
_libssh2_bn_ctx
|
||||
Type of multiple precision computation context. May not be empty. if not used,
|
||||
#define as char, for example.
|
||||
|
||||
libssh2_bn_ctx _libssh2_bn_ctx_new(void);
|
||||
Returns a new multiple precision computation context.
|
||||
|
||||
void _libssh2_bn_ctx_free(_libssh2_bn_ctx ctx);
|
||||
Releases a multiple precision computation context.
|
||||
|
||||
5.2) Computation support.
|
||||
_libssh2_bn
|
||||
Type of multiple precision numbers (aka bignumbers or huge integers) for the
|
||||
crypto library.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init(void);
|
||||
Creates a multiple precision number (preset to zero).
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init_from_bin(void);
|
||||
Create a multiple precision number intended to be set by the
|
||||
_libssh2_bn_from_bin() function (see below). Unlike _libssh2_bn_init(), this
|
||||
code may be a dummy initializer if the _libssh2_bn_from_bin() actually
|
||||
allocates the number. Returns a value of type _libssh2_bn *.
|
||||
|
||||
void _libssh2_bn_free(_libssh2_bn *bn);
|
||||
Destroys the multiple precision number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bytes(libssh2_bn *bn);
|
||||
Get the number of bytes needed to store the bits of the multiple precision
|
||||
number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bits(_libssh2_bn *bn);
|
||||
Returns the number of bits of multiple precision number at bn.
|
||||
|
||||
int _libssh2_bn_set_word(_libssh2_bn *bn, unsigned long val);
|
||||
Sets the value of bn to val.
|
||||
Returns 1 on success, 0 otherwise.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_from_bin(_libssh2_bn *bn, int len,
|
||||
const unsigned char *val);
|
||||
Converts the positive integer in big-endian form of length len at val
|
||||
into a _libssh2_bn and place it in bn. If bn is NULL, a new _libssh2_bn is
|
||||
created.
|
||||
Returns a pointer to target _libssh2_bn or NULL if error.
|
||||
|
||||
int _libssh2_bn_to_bin(_libssh2_bn *bn, unsigned char *val);
|
||||
Converts the absolute value of bn into big-endian form and store it at
|
||||
val. val must point to _libssh2_bn_bytes(bn) bytes of memory.
|
||||
Returns the length of the big-endian number.
|
||||
|
||||
void _libssh2_bn_rand(_libssh2_bn *bn, int bits, int top, int bottom);
|
||||
Generates a cryptographically strong pseudo-random number of bits in
|
||||
length and stores it in bn. If top is -1, the most significant bit of the
|
||||
random number can be zero. If top is 0, it is set to 1, and if top is 1, the
|
||||
two most significant bits of the number will be set to 1, so that the product
|
||||
of two such random numbers will always have 2*bits length. If bottom is true,
|
||||
the number will be odd.
|
||||
|
||||
void _libssh2_bn_mod_exp(_libssh2_bn *r, _libssh2_bn *a,
|
||||
_libssh2_bn *p, _libssh2_bn *m,
|
||||
_libssh2_bn_ctx *ctx);
|
||||
Computes a to the p-th power modulo m and stores the result into r (r=a^p % m).
|
||||
May use the given context.
|
||||
|
||||
|
||||
6) Private key algorithms.
|
||||
Format of an RSA public key:
|
||||
a) "ssh-rsa".
|
||||
b) RSA exponent, MSB first, with high order bit = 0.
|
||||
c) RSA modulus, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
Format of a DSA public key:
|
||||
a) "ssh-dss".
|
||||
b) p, MSB first, with high order bit = 0.
|
||||
c) q, MSB first, with high order bit = 0.
|
||||
d) g, MSB first, with high order bit = 0.
|
||||
e) pub_key, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
Reads a private key from file privatekey and extract the public key -->
|
||||
(pubkeydata, pubkeydata_len). Store the associated method (ssh-rsa or ssh-dss)
|
||||
into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
Gets a private key from bytes at (privatekeydata, privatekeydata_len) and
|
||||
extract the public key --> (pubkeydata, pubkeydata_len). Store the associated
|
||||
method (ssh-rsa or ssh-dss) into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
6.1) RSA
|
||||
LIBSSH2_RSA
|
||||
#define as 1 if the crypto library supports RSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
libssh2_rsa_ctx
|
||||
Type of an RSA computation context. Generally a struct.
|
||||
|
||||
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);
|
||||
Creates a new context for RSA computations from key source values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
ndata, nlen Modulus n.
|
||||
edata, elen Exponent e.
|
||||
ddata, dlen e^-1 % phi(n) = private key. May be NULL if unknown.
|
||||
e1data, e1len dp = d % (p-1). Only used if private key known (dtata).
|
||||
e2data, e2len dq = d % (q-1). Only used if private key known (dtata).
|
||||
coeffdata, coefflen q^-1 % p. Only used if private key known.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: the current generic code only calls this function with e and n (public
|
||||
key parameters): unless used internally by the backend, it is not needed to
|
||||
support the private key and the other parameters here.
|
||||
|
||||
int _libssh2_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Reads an RSA private key from file filename into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets an RSA private key from data into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
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);
|
||||
Verify (sig, siglen) signature of (m, m_len) using an SHA-1 hash and the
|
||||
RSA context.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_sha1_signv(LIBSSH2_SESSION *session,
|
||||
unsigned char **sig, size_t *siglen,
|
||||
int count, const struct iovec vector[],
|
||||
libssh2_rsa_ctx *ctx);
|
||||
RSA signs the SHA-1 hash computed over the count data chunks in vector.
|
||||
Signature is stored at (sig, siglen).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
Note: this procedure is optional: if provided, it MUST be defined as a macro.
|
||||
|
||||
int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION *session,
|
||||
libssh2_rsa_ctx *rsactx,
|
||||
const unsigned char *hash,
|
||||
size_t hash_len,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len);
|
||||
RSA signs the (hash, hashlen) SHA-1 hash bytes and stores the allocated
|
||||
signature at (signature, signature_len).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: this procedure is not used if macro _libssh2_rsa_sha1_signv() is defined.
|
||||
|
||||
void _libssh2_rsa_free(libssh2_rsa_ctx *rsactx);
|
||||
Releases the RSA computation context at rsactx.
|
||||
|
||||
|
||||
6.2) DSA
|
||||
LIBSSH2_DSA
|
||||
#define as 1 if the crypto library supports DSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_dsa_ctx
|
||||
Type of a DSA computation context. Generally a struct.
|
||||
|
||||
int _libssh2_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
const unsigned char *qdata,
|
||||
unsigned long qlen,
|
||||
const unsigned char *gdata,
|
||||
unsigned long glen,
|
||||
const unsigned char *ydata,
|
||||
unsigned long ylen,
|
||||
const unsigned char *x, unsigned long x_len);
|
||||
Creates a new context for DSA computations from source key values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
gdata, glen G number.
|
||||
ydata, ylen Public key.
|
||||
xdata, xlen Private key. Only taken if xlen non-zero.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from file filename into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from the data_len-bytes data into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *sig,
|
||||
const unsigned char *m, unsigned long m_len);
|
||||
Verify (sig, siglen) signature of (m, m_len) using an SHA1 hash and the
|
||||
DSA context.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *hash,
|
||||
unsigned long hash_len, unsigned char *sig);
|
||||
DSA signs the (hash, hash_len) data using SHA-1 and store the signature at sig.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_dsa_free(libssh2_dsa_ctx *dsactx);
|
||||
Releases the DSA computation context at dsactx.
|
||||
|
||||
|
||||
7) Miscellaneous
|
||||
|
||||
void libssh2_prepare_iovec(struct iovec *vector, unsigned int len);
|
||||
Prepare len consecutive iovec slots before using them.
|
||||
In example, this is needed to preset unused structure slacks on platforms
|
||||
requiring it.
|
||||
If this is not needed, it should be defined as an empty macro.
|
||||
|
||||
void _libssh2_random(unsigned char *buf, int len);
|
||||
Store len random bytes at buf.
|
||||
@@ -1,7 +1,7 @@
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
AUTHORS CMakeLists.txt HACKING.CRYPTO
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
@@ -89,6 +89,7 @@ dist_man_MANS = \
|
||||
libssh2_publickey_remove_ex.3 \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_recv2.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
@@ -109,6 +110,7 @@ dist_man_MANS = \
|
||||
libssh2_session_init_ex.3 \
|
||||
libssh2_session_last_errno.3 \
|
||||
libssh2_session_last_error.3 \
|
||||
libssh2_session_set_last_error.3 \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -16,7 +16,17 @@
|
||||
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -80,8 +90,6 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = docs
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(dist_man_MANS) AUTHORS TODO
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -91,6 +99,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h \
|
||||
$(top_builddir)/example/libssh2_config.h
|
||||
@@ -147,6 +156,7 @@ am__installdirs = "$(DESTDIR)$(man3dir)"
|
||||
NROFF = nroff
|
||||
MANS = $(dist_man_MANS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in AUTHORS TODO
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -280,6 +290,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -289,7 +300,7 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
AUTHORS CMakeLists.txt HACKING.CRYPTO
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
@@ -377,6 +388,7 @@ dist_man_MANS = \
|
||||
libssh2_publickey_remove_ex.3 \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_recv2.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
@@ -397,6 +409,7 @@ dist_man_MANS = \
|
||||
libssh2_session_init_ex.3 \
|
||||
libssh2_session_last_errno.3 \
|
||||
libssh2_session_last_error.3 \
|
||||
libssh2_session_set_last_error.3 \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
@@ -475,7 +488,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign docs/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign docs/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -699,6 +711,8 @@ uninstall-man: uninstall-man3
|
||||
ps ps-am tags-am uninstall uninstall-am uninstall-man \
|
||||
uninstall-man3
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -8,6 +8,9 @@ LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function is \fBDEPRECATED\fP. Use \fIlibssh2_scp_recv2(3)\fP
|
||||
instead!
|
||||
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
|
||||
32
docs/libssh2_scp_recv2.3
Normal file
32
docs/libssh2_scp_recv2.3
Normal file
@@ -0,0 +1,32 @@
|
||||
.TH libssh2_scp_recv2 3 "29 Jun 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_scp_recv2 - request a remote file via SCP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv2(LIBSSH2_SESSION *session, const char *path, struct_stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIpath\fP - Full path and filename of file to transfer. That is the remote
|
||||
file name.
|
||||
|
||||
\fIsb\fP - Populated with remote file's size, mode, mtime, and atime
|
||||
|
||||
Request a file from the remote host via SCP.
|
||||
.SH RETURN VALUE
|
||||
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SCP_PROTOCOL\fP -
|
||||
|
||||
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
|
||||
block.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
.BR libssh2_channel_open_ex(3)
|
||||
|
||||
@@ -18,3 +18,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
||||
@@ -29,3 +29,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_errno(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
||||
33
docs/libssh2_session_set_last_error.3
Normal file
33
docs/libssh2_session_set_last_error.3
Normal file
@@ -0,0 +1,33 @@
|
||||
.TH libssh2_session_set_last_error 3 "26 Oct 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_set_last_error - sets the internal error state
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_session_set_last_error(LIBSSH2_SESSION *session, int errcode, const char *errmsg)
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIerrcode\fP - One of the error codes as defined in the public
|
||||
libssh2 header file.
|
||||
|
||||
\fIerrmsg\fP - If not NULL, a copy of the given string is stored
|
||||
inside the session object as the error message.
|
||||
|
||||
This function is provided for high level language wrappers
|
||||
(i.e. Python or Perl) and other libraries that may extend libssh2 with
|
||||
additional features while still relying on its error reporting
|
||||
mechanism.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH AVAILABILITY
|
||||
Added in 1.6.1
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_last_errno(3)
|
||||
100
example/CMakeLists.txt
Normal file
100
example/CMakeLists.txt
Normal file
@@ -0,0 +1,100 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CopyRuntimeDependencies)
|
||||
include(SocketLibraries)
|
||||
|
||||
set(EXAMPLES
|
||||
direct_tcpip
|
||||
ssh2
|
||||
scp
|
||||
scp_nonblock
|
||||
scp_write
|
||||
scp_write_nonblock
|
||||
sftp
|
||||
sftp_nonblock
|
||||
sftp_write
|
||||
sftp_write_nonblock
|
||||
sftp_mkdir
|
||||
sftp_mkdir_nonblock
|
||||
sftp_RW_nonblock
|
||||
sftp_write_sliding
|
||||
sftpdir
|
||||
sftpdir_nonblock
|
||||
ssh2_exec
|
||||
ssh2_agent
|
||||
ssh2_echo
|
||||
sftp_append
|
||||
subsystem_netconf
|
||||
tcpip-forward)
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
foreach(example ${EXAMPLES})
|
||||
add_executable(example-${example} ${example}.c)
|
||||
list(APPEND EXAMPLE_TARGETS example-${example})
|
||||
# to find generated header
|
||||
target_include_directories(example-${example} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(example-${example} libssh2 ${LIBRARIES})
|
||||
endforeach()
|
||||
add_target_to_copy_dependencies(
|
||||
TARGET copy_example_dependencies
|
||||
DEPENDENCIES ${RUNTIME_DEPENDENCIES}
|
||||
BEFORE_TARGETS ${EXAMPLE_TARGETS})
|
||||
|
||||
## Platform checks
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
|
||||
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP)
|
||||
check_symbol_exists(_stricmp string.h HAVE__STRICMP)
|
||||
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
|
||||
check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF)
|
||||
|
||||
check_symbol_exists(__func__ "" HAVE___FUNC__)
|
||||
check_symbol_exists(__FUNCTION__ "" HAVE___FUNCTION__)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
||||
@@ -1,6 +1,6 @@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
EXTRA_DIST = libssh2_config.h.in
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in CMakeLists.txt
|
||||
|
||||
# samples
|
||||
noinst_PROGRAMS = direct_tcpip ssh2 scp scp_nonblock scp_write \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -15,7 +15,17 @@
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -91,8 +101,6 @@ noinst_PROGRAMS = direct_tcpip$(EXEEXT) ssh2$(EXEEXT) scp$(EXEEXT) \
|
||||
$(am__EXEEXT_1)
|
||||
@HAVE_SYS_UN_H_TRUE@am__append_1 = x11
|
||||
subdir = example
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(srcdir)/libssh2_config.h.in $(top_srcdir)/depcomp
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -102,6 +110,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h libssh2_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -275,6 +284,8 @@ am__define_uniq_tagged_files = \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libssh2_config.h.in \
|
||||
$(top_srcdir)/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -408,6 +419,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -417,7 +429,7 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
EXTRA_DIST = libssh2_config.h.in
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in CMakeLists.txt
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example
|
||||
LDADD = $(top_builddir)/src/libssh2.la
|
||||
all: libssh2_config.h
|
||||
@@ -437,7 +449,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign example/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -828,6 +839,8 @@ uninstall-am:
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_SECUREZEROMEMORY
|
||||
|
||||
/* disabled non-blocking sockets */
|
||||
#undef HAVE_DISABLED_NONBLOCKING
|
||||
|
||||
|
||||
72
example/libssh2_config_cmake.h.in
Normal file
72
example/libssh2_config_cmake.h.in
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Headers */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
#cmakedefine HAVE_STDLIB_H
|
||||
#cmakedefine HAVE_SYS_SELECT_H
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
#cmakedefine HAVE_SYS_TIME_H
|
||||
#cmakedefine HAVE_ARPA_INET_H
|
||||
#cmakedefine HAVE_NETINET_IN_H
|
||||
#cmakedefine HAVE_WINSOCK2_H
|
||||
|
||||
/* Functions */
|
||||
#cmakedefine HAVE_STRCASECMP
|
||||
#cmakedefine HAVE__STRICMP
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
#cmakedefine HAVE__SNPRINTF
|
||||
|
||||
/* Workaround for platforms without POSIX strcasecmp (e.g. Windows) */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
# ifdef HAVE__STRICMP
|
||||
# define strcasecmp _stricmp
|
||||
# define HAVE_STRCASECMP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbols */
|
||||
#cmakedefine HAVE___FUNC__
|
||||
#cmakedefine HAVE___FUNCTION__
|
||||
|
||||
/* Workaround for platforms without C90 __func__ */
|
||||
#ifndef HAVE___FUNC__
|
||||
# ifdef HAVE___FUNCTION__
|
||||
# define __func__ __FUNCTION__
|
||||
# define HAVE___FUNC__
|
||||
# endif
|
||||
#endif
|
||||
@@ -41,9 +41,9 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
libssh2_struct_stat fileinfo;
|
||||
int rc;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Request a file via SCP */
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
fprintf(stderr, "Unable to open a session: %d\n",
|
||||
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
int amount=sizeof(mem);
|
||||
|
||||
if((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size -got;
|
||||
amount = (int)(fileinfo.st_size -got);
|
||||
}
|
||||
|
||||
rc = libssh2_channel_read(channel, mem, amount);
|
||||
|
||||
@@ -88,16 +88,16 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
libssh2_struct_stat fileinfo;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int total = 0;
|
||||
int spin = 0;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
libssh2_struct_stat_size total = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
@@ -207,9 +207,9 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
/* Request a file via SCP */
|
||||
fprintf(stderr, "libssh2_scp_recv()!\n");
|
||||
fprintf(stderr, "libssh2_scp_recv2()!\n");
|
||||
do {
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
@@ -235,7 +235,7 @@ int main(int argc, char *argv[])
|
||||
int amount=sizeof(mem);
|
||||
|
||||
if ((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size - got;
|
||||
amount = (int)(fileinfo.st_size - got);
|
||||
}
|
||||
|
||||
/* loop until we block */
|
||||
@@ -262,10 +262,10 @@ int main(int argc, char *argv[])
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
|
||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
|
||||
@@ -40,18 +40,18 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2015 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2016 The libssh2 project and its contributors."
|
||||
|
||||
/* We use underscore instead of dash when appending DEV 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 course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.6.0"
|
||||
#define LIBSSH2_VERSION "1.7.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 6
|
||||
#define LIBSSH2_VERSION_MINOR 7
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
@@ -69,7 +69,7 @@
|
||||
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 0x010600
|
||||
#define LIBSSH2_VERSION_NUM 0x010700
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -80,7 +80,7 @@
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBSSH2_TIMESTAMP "Fri Jun 12 06:58:26 UTC 2015"
|
||||
#define LIBSSH2_TIMESTAMP "tis 23 feb 2016 07:56:30 UTC"
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
@@ -145,6 +145,68 @@ typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*
|
||||
* Determine whether there is small or large file support on windows.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# else
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__POCC__)
|
||||
# undef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
|
||||
!defined(LIBSSH2_USE_WIN32_SMALL_FILES)
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Large file (>2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# include <io.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%I64d"
|
||||
typedef struct _stati64 libssh2_struct_stat;
|
||||
typedef __int64 libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Small file (<2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# ifndef _WIN32_WCE
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d"
|
||||
typedef struct _stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBSSH2_STRUCT_STAT_SIZE_FORMAT
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%zd"
|
||||
typedef struct stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/* Part of every banner, user specified or not */
|
||||
#define LIBSSH2_SSH_BANNER "SSH-2.0-libssh2_" LIBSSH2_VERSION
|
||||
|
||||
@@ -506,6 +568,9 @@ 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_set_last_error(LIBSSH2_SESSION* session,
|
||||
int errcode,
|
||||
const char* errmsg);
|
||||
LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag,
|
||||
@@ -596,7 +661,8 @@ 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)));
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(
|
||||
(*response_callback)));
|
||||
|
||||
#define libssh2_userauth_keyboard_interactive(session, username, \
|
||||
response_callback) \
|
||||
@@ -805,9 +871,14 @@ 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_scp_recv is DEPRECATED, do not use! */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
struct stat *sb);
|
||||
/* Use libssh2_scp_recv2 for large (> 2GB) file support on windows */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv2(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
libssh2_struct_stat *sb);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session,
|
||||
const char *path, int mode,
|
||||
size_t size, long mtime,
|
||||
|
||||
@@ -69,7 +69,8 @@ typedef struct _libssh2_publickey_list {
|
||||
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 */
|
||||
/* 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) \
|
||||
|
||||
@@ -12,6 +12,6 @@ URL: http://www.libssh2.org/
|
||||
Description: Library for SSH-based communication
|
||||
Version: @LIBSSH2VER@
|
||||
Requires.private: @LIBSREQUIRED@
|
||||
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
|
||||
Libs: -L${libdir} -lssh2 @LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -545,6 +545,7 @@ endif
|
||||
@echo $(DL) libssh2_knownhost_readfile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_writefile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv2,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send64,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_abstract,$(DL) >> $@
|
||||
|
||||
169
os400/README400
Normal file
169
os400/README400
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This is a true OS/400 implementation, not a PASE implementation (for PASE,
|
||||
use AIX implementation).
|
||||
|
||||
It uses ASCII as internal character set. This has been accomplished using the
|
||||
QADRT library and include files, a C and system procedures ASCII wrapper
|
||||
library. See IBM QADRT description for more information.
|
||||
This results in libssh2 being an ASCII library: any function string
|
||||
argument is taken/returned in ASCII and a C/C++ calling program built around
|
||||
QADRT may use libssh2 functions as on any other platform.
|
||||
QADRT does not define ASCII wrappers for all C/system procedures: an
|
||||
additional module (os400sys.c) define some more of them, that are used by
|
||||
libssh2 and that QADRT left out.
|
||||
Since standard library entry points expect and return ASCII character strings,
|
||||
additional procedures are provided for string transcoding (see below). No
|
||||
wrappers to standard procedures are provided: however, nested calls to
|
||||
transcoding procedures may be used.
|
||||
|
||||
Crypto API is provided by the IBM QC3 API library. It supports RSA, but not DSA.
|
||||
|
||||
|
||||
Standard compilation environment does support neither autotools nor make;
|
||||
in fact, very few common utilities are available. As a consequence, the
|
||||
libssh2_config.h has been coded manually and the compilation scripts are
|
||||
a set of shell scripts stored in subdirectory os400.
|
||||
|
||||
The test environment is currently not supported on OS/400.
|
||||
|
||||
|
||||
|
||||
Compiling on OS/400:
|
||||
|
||||
These instructions target people who knows about OS/400, compiling, IFS and
|
||||
archive extraction. Do not ask questions about these subjects if you're not
|
||||
familiar with.
|
||||
|
||||
_ As a prerequisite, QADRT development environment must be installed.
|
||||
_ Install the libssh2 sources directory in IFS.
|
||||
_ Enter shell (QSH)
|
||||
_ Change current directory to the libssh2 sources installation directory
|
||||
_ Change current directory to os400
|
||||
_ Edit file iniscript.sh. You may want to change tunable configuration
|
||||
parameters, like debug info generation, optimisation level, listing option,
|
||||
target library, zlib availability and location, etc.
|
||||
_ Copy any file in the current directory to makelog (i.e.:
|
||||
cp initscript.sh makelog): this is intended to create the makelog file with
|
||||
an ASCII CCSID!
|
||||
_ Enter the command "sh make.sh > makelog 2>&1'
|
||||
_ Examine the makelog file to check for compilation errors.
|
||||
|
||||
Leaving file initscript.sh unchanged, this will produce the following OS/400
|
||||
objects:
|
||||
_ Library LIBSSH2. All other objects will be stored in this library.
|
||||
_ Modules for all libssh2 units.
|
||||
_ Binding directory LIBSSH2_A, to be used at calling program link time for
|
||||
statically binding the modules (specify BNDSRVPGM(QADRTTS) when creating a
|
||||
program using LIBSSH2_A. Also give access to the zlib BNDDIR/SRVPGM if
|
||||
libssh2 is compiled with zlib).
|
||||
_ Service program LIBSSH2.<soname>, where <soname> is extracted from the
|
||||
src/Makefile.am VERSION variable. To be used at calling program run-time
|
||||
when this program has dynamically bound libssh2 at link time.
|
||||
_ Binding directory LIBSSH2. To be used to dynamically bind libssh2 when
|
||||
linking a calling program.
|
||||
_ Source file H. It contains all the include members needed to compile a C/C++
|
||||
module using libssh2.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file H. These are the C/C++ header
|
||||
files. Original fames have been mangled to fit member name allowed syntax.
|
||||
_ Source file LIBSSH2RPG. It contains all the ILE/RPG /INCLUDE members
|
||||
needed to compile an ILE/RPG program calling libssh2 procedures.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file LIBSSH2RPG. These are
|
||||
ILE/RPG translations of the corresponding C header files.
|
||||
|
||||
|
||||
|
||||
Special programming consideration:
|
||||
|
||||
QADRT being used, the following points must be considered:
|
||||
_ If static binding is used, service program QADRTTS must be linked too.
|
||||
_ Likewise, if libssh2 has been compiled with zlib support, access to the
|
||||
zlib objects must be provided at link time.
|
||||
_ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
|
||||
another EBCDIC CCSID is required, it must be set via a locale through a call
|
||||
to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
|
||||
LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
|
||||
object path before executing the program.
|
||||
_ Do not use original source include files unless you know what you are doing.
|
||||
Use the installed members instead (in /QSYS.LIB/LIBSSH2.LIB/H.FILE).
|
||||
|
||||
|
||||
|
||||
String transcoding support:
|
||||
|
||||
To help passing arbitrarily encoded string arguments and/or receiving string
|
||||
values from/to the libssh2 API, three non-standard additional procedures are
|
||||
provided. They use a session pointer and a "string cache" pointer.
|
||||
Each time a string is transcoded, it is cached in the given cache. It is
|
||||
the responsibility of the caller to release the cache when its associted strings
|
||||
are no longer needed. These procedures and the string cache type are defined
|
||||
in a new libssh2_ccsid.h header file.
|
||||
To create a string cache, use:
|
||||
|
||||
#include <libssh2_ccsid.h>
|
||||
libssh2_string_cache * cache = NULL;
|
||||
|
||||
To release all strings in a cache, call:
|
||||
|
||||
libssh2_release_string_cache(session, &cache);
|
||||
|
||||
The transcoding procedures are:
|
||||
|
||||
char * libssh2_from_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
char * libssh2_to_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
|
||||
where:
|
||||
session is a libssh2 session used for memory allocation.
|
||||
cache is the address of a string cache.
|
||||
ccsid is the external (i.e.: non libssh2) coded character set id.
|
||||
65535 means no conversion and 0 means the current job's CCSID.
|
||||
string is the string to convert.
|
||||
inlen is the source string length in bytes: set to -1 if
|
||||
null-terminated.
|
||||
outlen if not NULL, is the address of a variable that will receive
|
||||
the transcoded string length upon return.
|
||||
|
||||
libssh2_from_ccsid() transcodes the string from the given CCSID to libssh2
|
||||
internal encoding (UTF-8). It is intended to be used to convert API input
|
||||
parameters.
|
||||
libssh2_to_ccsid() transcodes the string from libssh2 internal encoding
|
||||
(UTF-8) to the given CCSID. This has been implemented to get standard API
|
||||
string results in a program's native encoding.
|
||||
|
||||
Both these functions return a pointer to the null-terminated converted string,
|
||||
or NULL if an error occurred. In addition, the variable pointed by outlen
|
||||
receives the effective byte length of the (cached) translated string, or -1
|
||||
in case of error.
|
||||
|
||||
|
||||
|
||||
ILE/RPG support:
|
||||
|
||||
Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
|
||||
/INCLUDE member is provided for this language. To include libssh2
|
||||
definitions in an ILE/RPG module, line
|
||||
|
||||
h bnddir('LIBSSH2/LIBSSH2')
|
||||
|
||||
must figure in the program header, and line
|
||||
|
||||
d/include libssh2/libssh2rpg,libssh2
|
||||
|
||||
in the global data section of the module's source code.
|
||||
If required, members ssh2_sftp, ssh2_pkey and ssh2_ccsid may also be included.
|
||||
|
||||
For IFS source compilations, include members are located in directory
|
||||
/libssh2/include/libssh2rpg and have their original names retained.
|
||||
|
||||
ILE/RPG lacks a serious macro preprocessor, thus C macros requiring this
|
||||
feature have not been translated. However, function-like C macros have been
|
||||
implemented as procedures and therefore supported in ILE/RPG.
|
||||
252
os400/ccsid.c
Normal file
252
os400/ccsid.c
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Character encoding wrappers. */
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
#include "libssh2_ccsid.h"
|
||||
|
||||
#include <qtqiconv.h>
|
||||
#include <iconv.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
#define CCSID_UTF8 1208
|
||||
#define CCSID_UTF16BE 13488
|
||||
#define STRING_GRANULE 256
|
||||
#define MAX_CHAR_SIZE 4
|
||||
|
||||
#define OFFSET_OF(t, f) ((size_t) ((char *) &((t *) 0)->f - (char *) 0))
|
||||
|
||||
|
||||
struct _libssh2_string_cache {
|
||||
libssh2_string_cache * next;
|
||||
char string[1];
|
||||
};
|
||||
|
||||
|
||||
static const QtqCode_T utf8code = { CCSID_UTF8 };
|
||||
|
||||
|
||||
static ssize_t
|
||||
terminator_size(unsigned short ccsid)
|
||||
{
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t ilen;
|
||||
size_t olen;
|
||||
char buf[MAX_CHAR_SIZE];
|
||||
|
||||
/* Return the null-terminator size for the given CCSID. */
|
||||
|
||||
/* Fast check usual CCSIDs. */
|
||||
switch (ccsid) {
|
||||
case CCSID_UTF8:
|
||||
case 0: /* Job CCSID is SBCS EBCDIC. */
|
||||
return 1;
|
||||
case CCSID_UTF16BE:
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Convert an UTF-8 NUL to the target CCSID: use the converted size as
|
||||
result. */
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
outcode.CCSID = ccsid;
|
||||
cd = QtqIconvOpen(&outcode, (QtqCode_T *) &utf8code);
|
||||
if (cd.return_value == -1)
|
||||
return -1;
|
||||
inp = "";
|
||||
ilen = 1;
|
||||
outp = buf;
|
||||
olen = sizeof buf;
|
||||
iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
iconv_close(cd);
|
||||
olen = sizeof buf - olen;
|
||||
return olen? olen: -1;
|
||||
}
|
||||
|
||||
static char *
|
||||
convert_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short outccsid, unsigned short inccsid,
|
||||
const char *instring, ssize_t inlen, size_t *outlen)
|
||||
{
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t olen;
|
||||
size_t ilen;
|
||||
size_t buflen;
|
||||
size_t curlen;
|
||||
ssize_t termsize;
|
||||
int i;
|
||||
char *dst;
|
||||
libssh2_string_cache *outstring;
|
||||
QtqCode_T incode;
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
|
||||
if (!instring) {
|
||||
if (outlen)
|
||||
*outlen = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (outlen)
|
||||
*outlen = -1;
|
||||
if (!session || !cache)
|
||||
return NULL;
|
||||
|
||||
/* Get terminator size. */
|
||||
termsize = terminator_size(outccsid);
|
||||
if (termsize < 0)
|
||||
return NULL;
|
||||
|
||||
/* Prepare conversion parameters. */
|
||||
memset((void *) &incode, 0, sizeof incode);
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
incode.CCSID = inccsid;
|
||||
outcode.CCSID = outccsid;
|
||||
curlen = OFFSET_OF(libssh2_string_cache, string);
|
||||
inp = (char *) instring;
|
||||
ilen = inlen;
|
||||
buflen = inlen + curlen;
|
||||
if (inlen < 0) {
|
||||
incode.length_option = 1;
|
||||
buflen = STRING_GRANULE;
|
||||
ilen = 0;
|
||||
}
|
||||
|
||||
/* Allocate output string buffer and open conversion descriptor. */
|
||||
dst = LIBSSH2_ALLOC(session, buflen + termsize);
|
||||
if (!dst)
|
||||
return NULL;
|
||||
cd = QtqIconvOpen(&outcode, &incode);
|
||||
if (cd.return_value == -1) {
|
||||
LIBSSH2_FREE(session, (char *) dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert string. */
|
||||
for (;;) {
|
||||
outp = dst + curlen;
|
||||
olen = buflen - curlen;
|
||||
i = iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
if (inlen < 0 && olen == buflen - curlen) {
|
||||
/* Special case: converted 0-length (sub)strings do not store the
|
||||
terminator. */
|
||||
if (termsize) {
|
||||
memset(outp, 0, termsize);
|
||||
olen -= termsize;
|
||||
}
|
||||
}
|
||||
curlen = buflen - olen;
|
||||
if (i >= 0 || errno != E2BIG)
|
||||
break;
|
||||
/* Must expand buffer. */
|
||||
buflen += STRING_GRANULE;
|
||||
outp = LIBSSH2_REALLOC(session, dst, buflen + termsize);
|
||||
if (!outp)
|
||||
break;
|
||||
dst = outp;
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
|
||||
/* Check for error. */
|
||||
if (i < 0 || !outp) {
|
||||
LIBSSH2_FREE(session, dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Process terminator. */
|
||||
if (inlen < 0)
|
||||
curlen -= termsize;
|
||||
else if (termsize)
|
||||
memset(dst + curlen, 0, termsize);
|
||||
|
||||
/* Shorten buffer if possible. */
|
||||
if (curlen < buflen)
|
||||
dst = LIBSSH2_REALLOC(session, dst, curlen + termsize);
|
||||
|
||||
/* Link to cache. */
|
||||
outstring = (libssh2_string_cache *) dst;
|
||||
outstring->next = *cache;
|
||||
*cache = outstring;
|
||||
|
||||
/* Return length if required. */
|
||||
if (outlen)
|
||||
*outlen = curlen - OFFSET_OF(libssh2_string_cache, string);
|
||||
|
||||
return outstring->string;
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
CCSID_UTF8, ccsid, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_to_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
ccsid, CCSID_UTF8, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API void
|
||||
libssh2_release_string_cache(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache)
|
||||
{
|
||||
libssh2_string_cache *p;
|
||||
|
||||
if (session && cache)
|
||||
while ((p = *cache)) {
|
||||
*cache = p->next;
|
||||
LIBSSH2_FREE(session, (char *) p);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
50
os400/include/alloca.h
Normal file
50
os400/include/alloca.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_ALLOCA_H
|
||||
#define LIBSSH2_ALLOCA_H
|
||||
|
||||
/* alloca() emulation. */
|
||||
|
||||
#include <modasa.mih>
|
||||
|
||||
#define alloca(n) _MODASA(n)
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
72
os400/include/stdio.h
Normal file
72
os400/include/stdio.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_STDIO_H
|
||||
#define LIBSSH2_STDIO_H
|
||||
|
||||
/*
|
||||
* <stdio.h> wrapper.
|
||||
* Its goal is to redefine snprintf/vsnprintf which are not supported by QADRT.
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#if __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <stdio.h>
|
||||
#elif __ILEC400_TGTVRM__ >= 510
|
||||
# ifndef __SRCSTMF__
|
||||
# include <QADRT/h/stdio>
|
||||
# else
|
||||
# include </QIBM/ProdData/qadrt/include/stdio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_vsnprintf(char *dst, size_t len,
|
||||
const char *fmt, va_list args);
|
||||
extern int _libssh2_os400_snprintf(char *dst, size_t len,
|
||||
const char *fmt, ...);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
# define vsnprintf(dst, len, fmt, args) \
|
||||
_libssh2_os400_vsnprintf((dst), (len), (fmt), (args))
|
||||
# define snprintf _libssh2_os400_snprintf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
75
os400/include/sys/socket.h
Normal file
75
os400/include/sys/socket.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_SYS_SOCKET_H
|
||||
#define LIBSSH2_SYS_SOCKET_H
|
||||
|
||||
/*
|
||||
* <sys/socket.h> wrapper.
|
||||
* Redefines connect().
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#ifndef _QADRT_LT
|
||||
# define _QADRT_LT <
|
||||
#endif
|
||||
#ifndef _QADRT_GT
|
||||
# define _QADRT_GT >
|
||||
#endif
|
||||
|
||||
#ifdef QADRT_SYSINC
|
||||
# include _QADRT_LT QADRT_SYSINC/sys/socket.h _QADRT_GT
|
||||
#elif __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <sys/socket.h>
|
||||
#elif !defined(__SRCSTMF__)
|
||||
# include <QSYSINC/sys/socket>
|
||||
#else
|
||||
# include </QIBM/include/sys/socket.h>
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_connect(int sd,
|
||||
struct sockaddr * destaddr, int addrlen);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
#define connect(sd, addr, len) _libssh2_os400_connect((sd), (addr), (len))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
243
os400/initscript.sh
Normal file
243
os400/initscript.sh
Normal file
@@ -0,0 +1,243 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
setenv()
|
||||
|
||||
{
|
||||
# Define and export.
|
||||
|
||||
eval ${1}="${2}"
|
||||
export ${1}
|
||||
}
|
||||
|
||||
|
||||
case "${SCRIPTDIR}" in
|
||||
/*) ;;
|
||||
*) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
|
||||
esac
|
||||
|
||||
while true
|
||||
do case "${SCRIPTDIR}" in
|
||||
*/.) SCRIPTDIR="${SCRIPTDIR%/.}";;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# The script directory is supposed to be in $TOPDIR/os400.
|
||||
|
||||
TOPDIR=`dirname "${SCRIPTDIR}"`
|
||||
export SCRIPTDIR TOPDIR
|
||||
|
||||
# Extract the SONAME from the library makefile.
|
||||
|
||||
SONAME=`sed -e '/^VERSION=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
|
||||
< "${TOPDIR}/src/Makefile.am"`
|
||||
export SONAME
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Tunable configuration parameters.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
setenv TARGETLIB 'LIBSSH2' # Target OS/400 program library.
|
||||
setenv STATBNDDIR 'LIBSSH2_A' # Static binding directory.
|
||||
setenv DYNBNDDIR 'LIBSSH2' # Dynamic binding directory.
|
||||
setenv SRVPGM "LIBSSH2.${SONAME}" # Service program.
|
||||
setenv TGTCCSID '500' # Target CCSID of objects.
|
||||
setenv DEBUG '*ALL' # Debug level.
|
||||
setenv OPTIMIZE '10' # Optimisation level
|
||||
setenv OUTPUT '*NONE' # Compilation output option.
|
||||
setenv TGTRLS 'V5R3M0' # Target OS release.
|
||||
setenv IFSDIR '/libssh2' # Installation IFS directory.
|
||||
|
||||
# Define ZLIB availability and locations.
|
||||
|
||||
setenv WITH_ZLIB 0 # Define to 1 to enable.
|
||||
setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
|
||||
setenv ZLIB_LIB 'ZLIB' # ZLIB library.
|
||||
setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
# Need to get the version definitions.
|
||||
|
||||
LIBSSH2_VERSION=`grep '^#define *LIBSSH2_VERSION ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
LIBSSH2_VERSION_MAJOR=`grep '^#define *LIBSSH2_VERSION_MAJOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MAJOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_MINOR=`grep '^#define *LIBSSH2_VERSION_MINOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MINOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_PATCH=`grep '^#define *LIBSSH2_VERSION_PATCH ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_PATCH *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_NUM=`grep '^#define *LIBSSH2_VERSION_NUM ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_NUM *0x\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_TIMESTAMP=`grep '^#define *LIBSSH2_TIMESTAMP ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
export LIBSSH2_VERSION
|
||||
export LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH
|
||||
export LIBSSH2_VERSION_NUM LIBSSH2_TIMESTAMP
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# OS/400 specific definitions.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Procedures.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# action_needed dest [src]
|
||||
#
|
||||
# dest is an object to build
|
||||
# if specified, src is an object on which dest depends.
|
||||
#
|
||||
# exit 0 (succeeds) if some action has to be taken, else 1.
|
||||
|
||||
action_needed()
|
||||
|
||||
{
|
||||
[ ! -e "${1}" ] && return 0
|
||||
[ "${2}" ] || return 1
|
||||
[ "${1}" -ot "${2}" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# canonicalize_path path
|
||||
#
|
||||
# Return canonicalized path as:
|
||||
# - Absolute
|
||||
# - No . or .. component.
|
||||
|
||||
canonicalize_path()
|
||||
|
||||
{
|
||||
if expr "${1}" : '^/' > /dev/null
|
||||
then P="${1}"
|
||||
else P="`pwd`/${1}"
|
||||
fi
|
||||
|
||||
R=
|
||||
IFSSAVE="${IFS}"
|
||||
IFS="/"
|
||||
|
||||
for C in ${P}
|
||||
do IFS="${IFSSAVE}"
|
||||
case "${C}" in
|
||||
.) ;;
|
||||
..) R=`expr "${R}" : '^\(.*/\)..*'`
|
||||
;;
|
||||
?*) R="${R}${C}/"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS="${IFSSAVE}"
|
||||
echo "/`expr "${R}" : '^\(.*\)/'`"
|
||||
}
|
||||
|
||||
|
||||
# make_module module_name source_name [additional_definitions]
|
||||
#
|
||||
# Compile source name into ASCII module if needed.
|
||||
# As side effect, append the module name to variable MODULES.
|
||||
# Set LINK to "YES" if the module has been compiled.
|
||||
|
||||
make_module()
|
||||
|
||||
{
|
||||
MODULES="${MODULES} ${1}"
|
||||
MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
|
||||
action_needed "${MODIFSNAME}" "${2}" || return 0;
|
||||
SRCDIR=`dirname \`canonicalize_path "${2}"\``
|
||||
|
||||
# #pragma convert has to be in the source file itself, i.e.
|
||||
# putting it in an include file makes it only active
|
||||
# for that include file.
|
||||
# Thus we build a temporary file with the pragma prepended to
|
||||
# the source file and we compile that temporary file.
|
||||
|
||||
echo "#line 1 \"${2}\"" > __tmpsrcf.c
|
||||
echo "#pragma convert(819)" >> __tmpsrcf.c
|
||||
echo "#line 1" >> __tmpsrcf.c
|
||||
cat "${2}" >> __tmpsrcf.c
|
||||
CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
|
||||
# CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
|
||||
CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
|
||||
CMD="${CMD} LOCALETYPE(*LOCALE)"
|
||||
CMD="${CMD} INCDIR('${TOPDIR}/os400/include'"
|
||||
CMD="${CMD} '/QIBM/ProdData/qadrt/include' '${TOPDIR}/include'"
|
||||
CMD="${CMD} '${TOPDIR}/os400' '${SRCDIR}'"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then CMD="${CMD} '${ZLIB_INCLUDE}'"
|
||||
fi
|
||||
|
||||
CMD="${CMD} ${INCLUDES})"
|
||||
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
|
||||
CMD="${CMD} OUTPUT(${OUTPUT})"
|
||||
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
|
||||
CMD="${CMD} DBGVIEW(${DEBUG})"
|
||||
|
||||
DEFINES="${3}"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then DEFINES="${DEFINES} HAVE_LIBZ LIBSSH2_HAVE_ZLIB"
|
||||
fi
|
||||
|
||||
if [ "${DEFINES}" ]
|
||||
then CMD="${CMD} DEFINE(${DEFINES})"
|
||||
fi
|
||||
|
||||
system "${CMD}"
|
||||
rm -f __tmpsrcf.c
|
||||
LINK=YES
|
||||
}
|
||||
|
||||
|
||||
# Determine DB2 object name from IFS name.
|
||||
|
||||
db2_name()
|
||||
|
||||
{
|
||||
if [ "${2}" = 'nomangle' ]
|
||||
then basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^\(.\).*\(.........\)$/\1\2/'
|
||||
else basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^LIBSSH2_/SSH2_/' \
|
||||
-e 's/^\(.\).*\(.........\)$/\1\2/' \
|
||||
-e 's/^SPUBLICKEY$/SSH2_PKEY/'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Copy stream replacing version info.
|
||||
|
||||
versioned_copy()
|
||||
|
||||
{
|
||||
sed -e "s/@LIBSSH2_VERSION@/${LIBSSH2_VERSION}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MAJOR@/${LIBSSH2_VERSION_MAJOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MINOR@/${LIBSSH2_VERSION_MINOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_PATCH@/${LIBSSH2_VERSION_PATCH}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_NUM@/${LIBSSH2_VERSION_NUM}/g" \
|
||||
-e "s/@LIBSSH2_TIMESTAMP@/${LIBSSH2_TIMESTAMP}/g"
|
||||
}
|
||||
63
os400/libssh2_ccsid.h
Normal file
63
os400/libssh2_ccsid.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* CCSID conversion support. */
|
||||
|
||||
#ifndef LIBSSH2_CCSID_H_
|
||||
#define LIBSSH2_CCSID_H_
|
||||
|
||||
#include "libssh2.h"
|
||||
|
||||
typedef struct _libssh2_string_cache libssh2_string_cache;
|
||||
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
LIBSSH2_API char *
|
||||
libssh2_to_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
LIBSSH2_API void
|
||||
libssh2_release_string_cache(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache);
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
299
os400/libssh2_config.h
Normal file
299
os400/libssh2_config.h
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_CONFIG_H
|
||||
#define LIBSSH2_CONFIG_H
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
#undef AC_APPLE_UNIVERSAL_BUILD
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_SECUREZEROMEMORY
|
||||
|
||||
/* disabled non-blocking sockets */
|
||||
#undef HAVE_DISABLED_NONBLOCKING
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_aes_128_ctr' function. */
|
||||
#undef HAVE_EVP_AES_128_CTR
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* use FIONBIO for non-blocking sockets */
|
||||
#undef HAVE_FIONBIO
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* use ioctlsocket() for non-blocking sockets */
|
||||
#undef HAVE_IOCTLSOCKET
|
||||
|
||||
/* use Ioctlsocket() for non-blocking sockets */
|
||||
#undef HAVE_IOCTLSOCKET_CASE
|
||||
|
||||
/* Define if you have the bcrypt library. */
|
||||
#undef HAVE_LIBBCRYPT
|
||||
|
||||
/* Define if you have the crypt32 library. */
|
||||
#undef HAVE_LIBCRYPT32
|
||||
|
||||
/* Define if you have the gcrypt library. */
|
||||
#undef HAVE_LIBGCRYPT
|
||||
|
||||
/* Define if you have the ssl library. */
|
||||
#undef HAVE_LIBSSL
|
||||
|
||||
/* Define if you have the z library. */
|
||||
/* #undef HAVE_LIBZ */
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <ntdef.h> header file. */
|
||||
#undef HAVE_NTDEF_H
|
||||
|
||||
/* Define to 1 if you have the <ntstatus.h> header file. */
|
||||
#undef HAVE_NTSTATUS_H
|
||||
|
||||
/* use O_NONBLOCK for non-blocking sockets */
|
||||
#define HAVE_O_NONBLOCK 1
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define to 1 if you have the select function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* use SO_NONBLOCK for non-blocking sockets */
|
||||
#undef HAVE_SO_NONBLOCK
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strtoll' function. */
|
||||
#define HAVE_STRTOLL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/un.h> header file. */
|
||||
#define HAVE_SYS_UN_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <windows.h> header file. */
|
||||
#undef HAVE_WINDOWS_H
|
||||
|
||||
/* Define to 1 if you have the <winsock2.h> header file. */
|
||||
#undef HAVE_WINSOCK2_H
|
||||
|
||||
/* Define to 1 if you have the <ws2tcpip.h> header file. */
|
||||
#undef HAVE_WS2TCPIP_H
|
||||
|
||||
/* to make a symbol visible */
|
||||
#undef LIBSSH2_API
|
||||
|
||||
/* Enable clearing of memory before being freed */
|
||||
#define LIBSSH2_CLEAR_MEMORY 1
|
||||
|
||||
/* Enable "none" cipher -- NOT RECOMMENDED */
|
||||
#undef LIBSSH2_CRYPT_NONE
|
||||
|
||||
/* Enable newer diffie-hellman-group-exchange-sha1 syntax */
|
||||
#define LIBSSH2_DH_GEX_NEW 1
|
||||
|
||||
/* Compile in zlib support */
|
||||
/* #undef LIBSSH2_HAVE_ZLIB */
|
||||
|
||||
/* Use libgcrypt */
|
||||
#undef LIBSSH2_LIBGCRYPT
|
||||
|
||||
/* Enable "none" MAC -- NOT RECOMMENDED */
|
||||
#undef LIBSSH2_MAC_NONE
|
||||
|
||||
/* Use OpenSSL */
|
||||
#undef LIBSSH2_OPENSSL
|
||||
|
||||
/* Use Windows CNG */
|
||||
#undef LIBSSH2_WINCNG
|
||||
|
||||
/* Use OS/400 Qc3 */
|
||||
#define LIBSSH2_OS400QC3
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
#undef NEED_REENTRANT
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libssh2"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "libssh2-devel@cool.haxx.se"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libssh2"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libssh2 -"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libssh2"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "-"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "-"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#define WORDS_BIGENDIAN 1
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
/* Remap zlib procedures to ASCII versions. */
|
||||
#pragma map(inflateInit_, "_libssh2_os400_inflateInit_")
|
||||
#pragma map(deflateInit_, "_libssh2_os400_deflateInit_")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
1704
os400/libssh2rpg/libssh2.rpgle.in
Normal file
1704
os400/libssh2rpg/libssh2.rpgle.in
Normal file
File diff suppressed because it is too large
Load Diff
69
os400/libssh2rpg/libssh2_ccsid.rpgle.in
Normal file
69
os400/libssh2rpg/libssh2_ccsid.rpgle.in
Normal file
@@ -0,0 +1,69 @@
|
||||
* Copyright (c) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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.
|
||||
|
||||
/if not defined(LIBSSH2_CCSID_H_)
|
||||
/define LIBSSH2_CCSID_H_
|
||||
|
||||
/include "libssh2rpg/libssh2"
|
||||
|
||||
d libssh2_from_ccsid...
|
||||
d pr * extproc('libssh2_from_ccsid') char *
|
||||
d session * value LIBSSH2_SESSION *
|
||||
d cache * libssh2_string_cache
|
||||
d *(*)
|
||||
d ccsid value like(libssh2_Cushort)
|
||||
d string * value options(*string) const char *
|
||||
d inlen value like(libssh2_Cssize_t)
|
||||
d outlen like(libssh2_Csize_t) options(*omit)
|
||||
|
||||
d libssh2_to_ccsid...
|
||||
d pr * extproc('libssh2_to_ccsid') char *
|
||||
d session * value LIBSSH2_SESSION *
|
||||
d cache * libssh2_string_cache
|
||||
d *(*)
|
||||
d ccsid value like(libssh2_Cushort)
|
||||
d string * value options(*string) const char *
|
||||
d inlen value like(libssh2_Cssize_t)
|
||||
d outlen like(libssh2_Csize_t) options(*omit)
|
||||
|
||||
d libssh2_release_string_cache...
|
||||
d pr extproc(
|
||||
d 'libssh2_release_string_cache')
|
||||
d session * value LIBSSH2_SESSION *
|
||||
d cache * libssh2_string_cache
|
||||
d *(*)
|
||||
|
||||
/endif LIBSSH2_CCSID_H_
|
||||
141
os400/libssh2rpg/libssh2_publickey.rpgle
Normal file
141
os400/libssh2rpg/libssh2_publickey.rpgle
Normal file
@@ -0,0 +1,141 @@
|
||||
* Copyright (c) 2015, Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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
|
||||
|
||||
/if not defined(LIBSSH2_PUBLICKEY_H_)
|
||||
/define LIBSSH2_PUBLICKEY_H_
|
||||
|
||||
/include "libssh2rpg/libssh2"
|
||||
|
||||
d libssh2_publickey_attribute...
|
||||
d ds based(######typedef######)
|
||||
d align qualified
|
||||
d name * const char *
|
||||
d name_len like(libssh2_Culong)
|
||||
d value * const char *
|
||||
d value_len like(libssh2_Culong)
|
||||
d mandatory like(libssh2_Cchar)
|
||||
|
||||
d libssh2_publickey_list...
|
||||
d ds based(######typedef######)
|
||||
d align qualified
|
||||
d name * const char *
|
||||
d name_len like(libssh2_Culong)
|
||||
d blob * const uns char *
|
||||
d blob_len like(libssh2_Culong)
|
||||
d num_attrs like(libssh2_Culong)
|
||||
d attrs * libssh2_publickey...
|
||||
d attribute *
|
||||
|
||||
* Publickey Subsystem.
|
||||
d libssh2_publickey_init...
|
||||
d pr * extproc('libssh2_publickey_init') LIBSSH2_PUBLICKEY *
|
||||
d session * value LIBSSH2_SESSION *
|
||||
|
||||
d libssh2_publickey_add_ex...
|
||||
d pr extproc('libssh2_publickey_add_ex')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d name * value options(*string) const uns char *
|
||||
d name_len value like(libssh2_Culong)
|
||||
d blob * value options(*string) const uns char *
|
||||
d blob_len value like(libssh2_Culong)
|
||||
d overwrite value like(libssh2_Cchar)
|
||||
d num_attrs value like(libssh2_Culong)
|
||||
d attrs likeds(libssh2_publickey_attribute)
|
||||
d dim(1000)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_publickey_add...
|
||||
d pr extproc('libssh2_publickey_add')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d name * value options(*string) const unsigned char
|
||||
d *
|
||||
d blob * value options(*string) const unsigned char
|
||||
d *
|
||||
d blob_len value like(libssh2_Culong)
|
||||
d overwrite value like(libssh2_Cchar)
|
||||
d num_attrs value like(libssh2_Culong)
|
||||
d attrs likeds(libssh2_publickey_attribute)
|
||||
d dim(1000)
|
||||
|
||||
d libssh2_publickey_remove_ex...
|
||||
d pr extproc(
|
||||
d 'libssh2_publickey_remove_ex')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d name * value options(*string) const uns char *
|
||||
d name_len value like(libssh2_Culong)
|
||||
d blob * value options(*string) const uns char *
|
||||
d blob_len value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_publickey_remove...
|
||||
d pr extproc('libssh2_publickey_remove')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d name * value options(*string) const uns char *
|
||||
d blob * value options(*string) const uns char *
|
||||
d blob_len value like(libssh2_Culong)
|
||||
|
||||
d libssh2_publickey_list_fetch...
|
||||
d pr extproc(
|
||||
d 'libssh2_publickey_list_fetch')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d num_keys * value unsigned long *
|
||||
d pkey_list * libssh2_publickey...
|
||||
d _list *(*)
|
||||
|
||||
d libssh2_publickey_list_free...
|
||||
d pr extproc(
|
||||
d 'libssh2_publickey_list_free')
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
d pkey_list likeds(libssh2_publickey_list)
|
||||
|
||||
d libssh2_publickey_shutdown...
|
||||
d pr extproc('libssh2_publickey_shutdown')
|
||||
d like(libssh2_Cint)
|
||||
d pkey * value LIBSSH2_PUBLICKEY *
|
||||
|
||||
/endif LIBSSH2_PUBLICKEY_H_
|
||||
621
os400/libssh2rpg/libssh2_sftp.rpgle
Normal file
621
os400/libssh2rpg/libssh2_sftp.rpgle
Normal file
@@ -0,0 +1,621 @@
|
||||
* Copyright (c) 2015, Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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.
|
||||
|
||||
/if not defined(LIBSSH2_SFTP_H_)
|
||||
/define LIBSSH2_SFTP_H_
|
||||
|
||||
/include "libssh2rpg/libssh2"
|
||||
|
||||
* 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.
|
||||
d LIBSSH2_SFTP_VERSION...
|
||||
d c 3
|
||||
|
||||
* Flags for open_ex().
|
||||
d LIBSSH2_SFTP_OPENFILE...
|
||||
d c 0
|
||||
d LIBSSH2_SFTP_OPENDIR...
|
||||
d c 1
|
||||
|
||||
* Flags for rename_ex().
|
||||
d LIBSSH2_SFTP_RENAME_OVERWRITE...
|
||||
d c X'00000001'
|
||||
d LIBSSH2_SFTP_RENAME_ATOMIC...
|
||||
d c X'00000002'
|
||||
d LIBSSH2_SFTP_RENAME_NATIVE...
|
||||
d c X'00000004'
|
||||
|
||||
* Flags for stat_ex().
|
||||
d LIBSSH2_SFTP_STAT...
|
||||
d c 0
|
||||
d LIBSSH2_SFTP_LSTAT...
|
||||
d c 1
|
||||
d LIBSSH2_SFTP_SETSTAT...
|
||||
d c 2
|
||||
|
||||
* Flags for symlink_ex().
|
||||
d LIBSSH2_SFTP_SYMLINK...
|
||||
d c 0
|
||||
d LIBSSH2_SFTP_READLINK...
|
||||
d c 1
|
||||
d LIBSSH2_SFTP_REALPATH...
|
||||
d c 2
|
||||
|
||||
* SFTP attribute flag bits.
|
||||
d LIBSSH2_SFTP_ATTR_SIZE...
|
||||
d c X'00000001'
|
||||
d LIBSSH2_SFTP_ATTR_UIDGID...
|
||||
d c X'00000002'
|
||||
d LIBSSH2_SFTP_ATTR_PERMISSIONS...
|
||||
d c X'00000004'
|
||||
d LIBSSH2_SFTP_ATTR_ACMODTIME...
|
||||
d c X'00000008'
|
||||
d LIBSSH2_SFTP_ATTR_EXTENDED...
|
||||
d c X'80000000'
|
||||
|
||||
* SFTP statvfs flag bits.
|
||||
d LIBSSH2_SFTP_ST_RDONLY...
|
||||
d c X'00000001'
|
||||
d LIBSSH2_SFTP_ST_NOSUID...
|
||||
d c X'00000002'
|
||||
|
||||
d #LIBSSH2_SFTP_ATTRIBUTES...
|
||||
d ds based(######typedef######)
|
||||
d align qualified
|
||||
* If flags & ATTR_* bit is set, then the value in this struct will be
|
||||
* meaningful Otherwise it should be ignored.
|
||||
d flags like(libssh2_Culong)
|
||||
d filesize like(libssh2_uint64_t)
|
||||
d uid like(libssh2_Culong)
|
||||
d gid like(libssh2_Culong)
|
||||
d permissions like(libssh2_Culong)
|
||||
d atime like(libssh2_Culong)
|
||||
d mtime like(libssh2_Culong)
|
||||
|
||||
d #LIBSSH2_SFTP_STATVFS...
|
||||
d ds based(######typedef######)
|
||||
d align qualified
|
||||
d f_bsize like(libssh2_uint64_t) Filesys block size
|
||||
d f_frsize like(libssh2_uint64_t) Fragment size
|
||||
d f_blocks like(libssh2_uint64_t) FS size in f_frsize
|
||||
d f_bfree like(libssh2_uint64_t) Free blocks
|
||||
d f_bavail like(libssh2_uint64_t) Free blks f. nonroot
|
||||
d f_files like(libssh2_uint64_t) Inodes
|
||||
d f_ffree like(libssh2_uint64_t) Free inodes
|
||||
d f_favail like(libssh2_uint64_t) Free inds f. nonroot
|
||||
d f_fsid like(libssh2_uint64_t) File system ID
|
||||
d f_flag like(libssh2_uint64_t) Mount flags
|
||||
d f_namemax like(libssh2_uint64_t) Max filename length
|
||||
|
||||
* SFTP filetypes.
|
||||
d LIBSSH2_SFTP_TYPE_REGULAR...
|
||||
d c 1
|
||||
d LIBSSH2_SFTP_TYPE_DIRECTORY...
|
||||
d c 2
|
||||
d LIBSSH2_SFTP_TYPE_SYMLINK...
|
||||
d c 3
|
||||
d LIBSSH2_SFTP_TYPE_SPECIAL...
|
||||
d c 4
|
||||
d LIBSSH2_SFTP_TYPE_UNKNOWN...
|
||||
d c 5
|
||||
d LIBSSH2_SFTP_TYPE_SOCKET...
|
||||
d c 6
|
||||
d LIBSSH2_SFTP_TYPE_CHAR_DEVICE...
|
||||
d c 7
|
||||
d LIBSSH2_SFTP_TYPE_BLOCK_DEVICE...
|
||||
d c 8
|
||||
d LIBSSH2_SFTP_TYPE_FIFO...
|
||||
d c 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.
|
||||
d LIBSSH2_SFTP_S_IFMT... type of file mask
|
||||
d c X'F000'
|
||||
d LIBSSH2_SFTP_S_IFIFO... named pipe (fifo)
|
||||
d c X'1000'
|
||||
d LIBSSH2_SFTP_S_IFCHR... character special
|
||||
d c X'2000'
|
||||
d LIBSSH2_SFTP_S_IFDIR... directory
|
||||
d c X'4000'
|
||||
d LIBSSH2_SFTP_S_IFBLK... block special
|
||||
d c X'6000'
|
||||
d LIBSSH2_SFTP_S_IFREG... regular
|
||||
d c X'8000'
|
||||
d LIBSSH2_SFTP_S_IFLNK... symbolic link
|
||||
d c X'A000'
|
||||
d LIBSSH2_SFTP_S_IFSOCK... socket
|
||||
d c X'C000'
|
||||
|
||||
* File mode.
|
||||
* Read, write, execute/search by owner.
|
||||
d LIBSSH2_SFTP_S_IRWXU... RWX mask for owner
|
||||
d c X'01C0'
|
||||
d LIBSSH2_SFTP_S_IRUSR... R for owner
|
||||
d c X'0100'
|
||||
d LIBSSH2_SFTP_S_IWUSR... W for owner
|
||||
d c X'0080'
|
||||
d LIBSSH2_SFTP_S_IXUSR... X for owner
|
||||
d c X'0040'
|
||||
* Read, write, execute/search by group.
|
||||
d LIBSSH2_SFTP_S_IRWXG... RWX mask for group
|
||||
d c X'0038'
|
||||
d LIBSSH2_SFTP_S_IRGRP... R for group
|
||||
d c X'0020'
|
||||
d LIBSSH2_SFTP_S_IWGRP... W for group
|
||||
d c X'0010'
|
||||
d LIBSSH2_SFTP_S_IXGRP... X for group
|
||||
d c X'0008'
|
||||
* Read, write, execute/search by others.
|
||||
d LIBSSH2_SFTP_S_IRWXO... RWX mask for other
|
||||
d c X'0007'
|
||||
d LIBSSH2_SFTP_S_IROTH... R for other
|
||||
d c X'0004'
|
||||
d LIBSSH2_SFTP_S_IWOTH... W for other
|
||||
d c X'0002'
|
||||
d LIBSSH2_SFTP_S_IXOTH... X for other
|
||||
d c X'0001'
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISLNK...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISLNK')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISREG...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISREG')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISDIR...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISDIR')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISCHR...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISCHR')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISBLK...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISBLK')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISFIFO...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISFIFO')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* C macro implementation.
|
||||
d LIBSSH2_SFTP_S_ISSOCK...
|
||||
d pr extproc('LIBSSH2_SFTP_S_ISSOCK')
|
||||
d like(libssh2_Cint)
|
||||
d permissions value like(libssh2_Culong)
|
||||
|
||||
* SFTP File Transfer Flags -- (e.g. flags parameter to sftp_open())
|
||||
* Danger will robinson... APPEND doesn't have any effect on OpenSSH
|
||||
* servers.
|
||||
d LIBSSH2_FXF_READ...
|
||||
d c X'00000001'
|
||||
d LIBSSH2_FXF_WRITE...
|
||||
d c X'00000002'
|
||||
d LIBSSH2_FXF_APPEND...
|
||||
d c X'00000004'
|
||||
d LIBSSH2_FXF_CREAT...
|
||||
d c X'00000008'
|
||||
d LIBSSH2_FXF_TRUNC...
|
||||
d c X'00000010'
|
||||
d LIBSSH2_FXF_EXCL...
|
||||
d c X'00000020'
|
||||
|
||||
* SFTP Status Codes (returned by libssh2_sftp_last_error()).
|
||||
d LIBSSH2_FX_OK...
|
||||
d c 0
|
||||
d LIBSSH2_FX_EOF...
|
||||
d c 1
|
||||
d LIBSSH2_FX_NO_SUCH_FILE...
|
||||
d c 2
|
||||
d LIBSSH2_FX_PERMISSION_DENIED...
|
||||
d c 3
|
||||
d LIBSSH2_FX_FAILURE...
|
||||
d c 4
|
||||
d LIBSSH2_FX_BAD_MESSAGE...
|
||||
d c 5
|
||||
d LIBSSH2_FX_NO_CONNECTION...
|
||||
d c 6
|
||||
d LIBSSH2_FX_CONNECTION_LOST...
|
||||
d c 7
|
||||
d LIBSSH2_FX_OP_UNSUPPORTED...
|
||||
d c 8
|
||||
d LIBSSH2_FX_INVALID_HANDLE...
|
||||
d c 9
|
||||
d LIBSSH2_FX_NO_SUCH_PATH...
|
||||
d c 10
|
||||
d LIBSSH2_FX_FILE_ALREADY_EXISTS...
|
||||
d c 11
|
||||
d LIBSSH2_FX_WRITE_PROTECT...
|
||||
d c 12
|
||||
d LIBSSH2_FX_NO_MEDIA...
|
||||
d c 13
|
||||
d LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM...
|
||||
d c 14
|
||||
d LIBSSH2_FX_QUOTA_EXCEEDED...
|
||||
d c 15
|
||||
d LIBSSH2_FX_UNKNOWN_PRINCIPAL...
|
||||
d c 16
|
||||
d LIBSSH2_FX_LOCK_CONFLICT...
|
||||
d c 17
|
||||
d LIBSSH2_FX_DIR_NOT_EMPTY...
|
||||
d c 18
|
||||
d LIBSSH2_FX_NOT_A_DIRECTORY...
|
||||
d c 19
|
||||
d LIBSSH2_FX_INVALID_FILENAME...
|
||||
d c 20
|
||||
d LIBSSH2_FX_LINK_LOOP...
|
||||
d c 21
|
||||
|
||||
* Returned by any function that would block during a read/write operation.
|
||||
d LIBSSH2SFTP_EAGAIN...
|
||||
d c -37
|
||||
|
||||
* SFTP API.
|
||||
d libssh2_sftp_init...
|
||||
d pr * extproc('libssh2_sftp_init') LIBSSH2_SFTP *
|
||||
d session * value LIBSSH2_SESSION *
|
||||
|
||||
d libssh2_sftp_shutdown...
|
||||
d pr extproc('libssh2_sftp_shutdown')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
|
||||
d libssh2_sftp_last_error...
|
||||
d pr extproc('libssh2_sftp_last_error')
|
||||
d like(libssh2_Culong)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
|
||||
d libssh2_sftp_get_channel...
|
||||
d pr * extproc('libssh2_sftp_get_channel') LIBSSH2_CHANNEL *
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
|
||||
* File / Directory Ops.
|
||||
d libssh2_sftp_open_ex...
|
||||
d pr * extproc('libssh2_sftp_open_ex') LIBSSH2_SFTP_HANDLE*
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d filename * value options(*string) const char *
|
||||
d filename_len value like(libssh2_Cuint)
|
||||
d flags value like(libssh2_Culong)
|
||||
d mode value like(libssh2_Clong)
|
||||
d open_type value like(libssh2_Cint)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_open...
|
||||
d pr * extproc('libssh2_sftp_open') LIBSSH2_SFTP_HANDLE
|
||||
d *
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d filename * value options(*string) const char *
|
||||
d flags value like(libssh2_Culong)
|
||||
d mode value like(libssh2_Clong)
|
||||
|
||||
* C macro libssh2_sftp_opendir implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_open_dir...
|
||||
d pr * extproc('libssh2_sftp_opendir') LIBSSH2_SFTP_HANDLE
|
||||
d *
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
|
||||
d libssh2_sftp_read...
|
||||
d pr extproc('libssh2_sftp_read')
|
||||
d like(libssh2_Cssize_t)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d buffer * value options(*string) char *
|
||||
d buffer_maxlen value like(libssh2_Csize_t)
|
||||
|
||||
d libssh2_sftp_readdir_ex...
|
||||
d pr extproc('libssh2_sftp_readdir_ex')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d buffer * value char *
|
||||
d buffer_maxlen value like(libssh2_Csize_t)
|
||||
d longentry * value char *
|
||||
d longentry_maxlen...
|
||||
d value like(libssh2_Csize_t)
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_readdir...
|
||||
d pr extproc('libssh2_sftp_readdir')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d buffer * value char *
|
||||
d buffer_maxlen value like(libssh2_Csize_t)
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
d libssh2_sftp_write...
|
||||
d pr extproc('libssh2_sftp_write')
|
||||
d like(libssh2_Cssize_t)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d buffer * value options(*string) const char *
|
||||
d count value like(libssh2_Csize_t)
|
||||
|
||||
d libssh2_sftp_fsync...
|
||||
d pr extproc('libssh2_sftp_fsync')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
d libssh2_sftp_close_handle...
|
||||
d pr extproc('libssh2_sftp_close_handle')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_close...
|
||||
d pr extproc('libssh2_sftp_close_handle')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_closedir...
|
||||
d pr extproc('libssh2_sftp_close_handle')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
d libssh2_sftp_seek...
|
||||
d pr extproc('libssh2_sftp_seek')
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d offset value like(libssh2_Csize_t)
|
||||
|
||||
d libssh2_sftp_seek64...
|
||||
d pr extproc('libssh2_sftp_seek64')
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d offset value like(libssh2_uint64_t)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_rewind...
|
||||
d pr extproc('libssh2_sftp_rewind')
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
d libssh2_sftp_tell...
|
||||
d pr extproc('libssh2_sftp_tell')
|
||||
d like(libssh2_Csize_t)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
d libssh2_sftp_tell64...
|
||||
d pr extproc('libssh2_sftp_tell64')
|
||||
d like(libssh2_uint64_t)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
|
||||
d libssh2_sftp_fstat_ex...
|
||||
d pr extproc('libssh2_sftp_fstat_ex')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
d setstat value like(libssh2_Cint)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_fstat...
|
||||
d pr extproc('libssh2_sftp_fstat')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_fsetstat...
|
||||
d pr extproc('libssh2_sftp_fsetstat')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* Miscellaneous Ops.
|
||||
d libssh2_sftp_rename_ex...
|
||||
d pr extproc('libssh2_sftp_rename_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d source_filename...
|
||||
d * value options(*string) const char *
|
||||
d source_filename_len...
|
||||
d value like(libssh2_Cuint)
|
||||
d dest_filename * value options(*string) const char *
|
||||
d dest_filename_len...
|
||||
d value like(libssh2_Cuint)
|
||||
d flags value like(libssh2_Clong)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_rename...
|
||||
d pr extproc('libssh2_sftp_rename')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d source_filename...
|
||||
d * value options(*string) const char *
|
||||
d dest_filename * value options(*string) const char *
|
||||
|
||||
d libssh2_sftp_unlink_ex...
|
||||
d pr extproc('libssh2_sftp_unlink_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d filename * value options(*string) const char *
|
||||
d filename_len value like(libssh2_Cuint)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_unlink...
|
||||
d pr extproc('libssh2_sftp_unlink')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d filename * value options(*string) const char *
|
||||
|
||||
d libssh2_sftp_fstatvfs...
|
||||
d pr extproc('libssh2_sftp_fstatvfs')
|
||||
d like(libssh2_Cint)
|
||||
d handle * value LIBSSH2_SFTP_HANDLE*
|
||||
d st * value LIBSSH2_SFTP_STATVFS
|
||||
d *
|
||||
|
||||
d libssh2_sftp_statvfs...
|
||||
d pr extproc('libssh2_sftp_statvfs')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d path_len value like(libssh2_Csize_t)
|
||||
d st * value LIBSSH2_SFTP_STATVFS
|
||||
d *
|
||||
|
||||
d libssh2_sftp_mkdir_ex...
|
||||
d pr extproc('libssh2_sftp_mkdir_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d path_len value like(libssh2_Cuint)
|
||||
d mode value like(libssh2_Clong)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_mkdir...
|
||||
d pr extproc('libssh2_sftp_mkdir')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d mode value like(libssh2_Clong)
|
||||
|
||||
d libssh2_sftp_rmdir_ex...
|
||||
d pr extproc('libssh2_sftp_rmdir_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d path_len value like(libssh2_Cuint)
|
||||
|
||||
* C macro implementation.
|
||||
d libssh2_sftp_rmdir...
|
||||
d pr extproc('libssh2_sftp_rmdir')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
|
||||
d libssh2_sftp_stat_ex...
|
||||
d pr extproc('libssh2_sftp_stat_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d path_len value like(libssh2_Cuint)
|
||||
d stat_type value like(libssh2_Cint)
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* C macro libssh2_sftp_stat implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_get_stat...
|
||||
d pr extproc('libssh2_sftp_stat')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* C macro libssh2_sftp_lstat implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_get_lstat...
|
||||
d pr extproc('libssh2_sftp_lstat')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
* C macro libssh2_sftp_setstat implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_set_stat...
|
||||
d pr extproc('libssh2_sftp_setstat')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d attrs * value LIBSSH2_SFTP_...
|
||||
d ATTRIBUTES *
|
||||
|
||||
d libssh2_sftp_symlink_ex...
|
||||
d pr extproc('libssh2_sftp_symlink_ex')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d path_len value like(libssh2_Cuint)
|
||||
d target * value options(*string) char *
|
||||
d target_len value like(libssh2_Cuint)
|
||||
d link_type value like(libssh2_Cint)
|
||||
|
||||
* C macro libssh2_sftp_symlink implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_sym_link...
|
||||
d pr extproc('libssh2_sftp_symlink')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d orig * value options(*string) const char *
|
||||
d linkpath * value options(*string) char *
|
||||
|
||||
* C macro libssh2_sftp_readlink implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_read_link...
|
||||
d pr extproc('libssh2_sftp_readlink')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d target * value char *
|
||||
d maxlen value like(libssh2_Cuint)
|
||||
|
||||
* C macro libssh2_sftp_realpath implementation.
|
||||
* Renamed to avoid upper/lower case name clash.
|
||||
d libssh2_sftp_real_path...
|
||||
d pr extproc('libssh2_sftp_realpath')
|
||||
d like(libssh2_Cint)
|
||||
d sftp * value LIBSSH2_SFTP *
|
||||
d path * value options(*string) const char *
|
||||
d target * value char *
|
||||
d maxlen value like(libssh2_Cuint)
|
||||
|
||||
/endif LIBSSH2_SFTP_H_
|
||||
168
os400/macros.h
Normal file
168
os400/macros.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_MACROS_H_
|
||||
#define LIBSSH2_MACROS_H_
|
||||
|
||||
#include "libssh2.h"
|
||||
#include "libssh2_publickey.h"
|
||||
#include "libssh2_sftp.h"
|
||||
|
||||
/*
|
||||
* Dummy prototypes to generate wrapper procedures to C macros.
|
||||
* This is a helper for languages without a clever preprocessor (ILE/RPG).
|
||||
*/
|
||||
|
||||
LIBSSH2_API LIBSSH2_SESSION * libssh2_session_init(void);
|
||||
LIBSSH2_API int libssh2_session_disconnect(LIBSSH2_SESSION *session,
|
||||
const char *description);
|
||||
LIBSSH2_API int libssh2_userauth_password(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const char *password);
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey_fromfile(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase,
|
||||
const char *hostname);
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_keyboard_interactive(LIBSSH2_SESSION* session,
|
||||
const char *username,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(
|
||||
(*response_callback)));
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
libssh2_channel_open_session(LIBSSH2_SESSION *session);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host,
|
||||
int port);
|
||||
LIBSSH2_API LIBSSH2_LISTENER *
|
||||
libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_setenv(LIBSSH2_CHANNEL *channel,
|
||||
const char *varname, const char *value);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_request_pty(LIBSSH2_CHANNEL *channel, const char *term);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_request_pty_size(LIBSSH2_CHANNEL *channel,
|
||||
int width, int height);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_shell(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_exec(LIBSSH2_CHANNEL *channel, const char *command);
|
||||
LIBSSH2_API int
|
||||
libssh2_channel_subsystem(LIBSSH2_CHANNEL *channel, const char *subsystem);
|
||||
LIBSSH2_API ssize_t
|
||||
libssh2_channel_read(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
|
||||
LIBSSH2_API ssize_t
|
||||
libssh2_channel_read_stderr(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
|
||||
LIBSSH2_API unsigned long
|
||||
libssh2_channel_window_read(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API ssize_t
|
||||
libssh2_channel_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen);
|
||||
LIBSSH2_API ssize_t
|
||||
libssh2_channel_write_stderr(LIBSSH2_CHANNEL *channel,
|
||||
const char *buf, size_t buflen);
|
||||
LIBSSH2_API unsigned long
|
||||
libssh2_channel_window_write(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_flush(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_flush_stderr(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
libssh2_scp_send(LIBSSH2_SESSION *session,
|
||||
const char *path, int mode, libssh2_int64_t size);
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_publickey_add(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name,
|
||||
const unsigned char *blob, unsigned long blob_len,
|
||||
char overwrite, unsigned long num_attrs,
|
||||
const libssh2_publickey_attribute attrs[]);
|
||||
LIBSSH2_API int
|
||||
libssh2_publickey_remove(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name,
|
||||
const unsigned char *blob, unsigned long blob_len);
|
||||
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISLNK(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISREG(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISDIR(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISCHR(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISBLK(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISFIFO(unsigned long permissions);
|
||||
LIBSSH2_API int LIBSSH2_SFTP_S_ISSOCK(unsigned long permissions);
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
|
||||
unsigned long flags, long mode);
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_opendir(LIBSSH2_SFTP *sftp, const char *path);
|
||||
LIBSSH2_API int libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle,
|
||||
char *buffer, size_t buffer_maxlen,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle);
|
||||
LIBSSH2_API int libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle);
|
||||
LIBSSH2_API void libssh2_sftp_rewind(LIBSSH2_SFTP_HANDLE *handle);
|
||||
LIBSSH2_API int libssh2_sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_fsetstat(LIBSSH2_SFTP_HANDLE *handle,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_rename(LIBSSH2_SFTP *sftp,
|
||||
const char *source_filename,
|
||||
const char *dest_filename);
|
||||
LIBSSH2_API int libssh2_sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename);
|
||||
LIBSSH2_API int libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp,
|
||||
const char *path, long mode);
|
||||
LIBSSH2_API int libssh2_sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path);
|
||||
LIBSSH2_API int libssh2_sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_lstat(LIBSSH2_SFTP *sftp, const char *path,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_setstat(LIBSSH2_SFTP *sftp, const char *path,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_symlink(LIBSSH2_SFTP *sftp, const char *orig,
|
||||
char *linkpath);
|
||||
LIBSSH2_API int libssh2_sftp_readlink(LIBSSH2_SFTP *sftp, const char *path,
|
||||
char *target, unsigned int maxlen);
|
||||
LIBSSH2_API int libssh2_sftp_realpath(LIBSSH2_SFTP *sftp, const char *path,
|
||||
char *target, unsigned int maxlen);
|
||||
|
||||
#endif
|
||||
56
os400/make-include.sh
Normal file
56
os400/make-include.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Installation of the header files in the OS/400 library.
|
||||
#
|
||||
|
||||
SCRIPTDIR=`dirname "${0}"`
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/include"
|
||||
|
||||
|
||||
# Create the OS/400 source program file for the header files.
|
||||
|
||||
SRCPF="${LIBIFSNAME}/H.FILE"
|
||||
|
||||
if action_needed "${SRCPF}"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
|
||||
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libssh2: Header files')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Create the IFS directory for the header files.
|
||||
|
||||
IFSINCLUDE="${IFSDIR}/include"
|
||||
|
||||
if action_needed "${IFSINCLUDE}"
|
||||
then mkdir -p "${IFSINCLUDE}"
|
||||
fi
|
||||
|
||||
|
||||
copy_hfile()
|
||||
|
||||
{
|
||||
destfile="${1}"
|
||||
srcfile="${2}"
|
||||
shift
|
||||
shift
|
||||
sed -e '1i\
|
||||
#pragma datamodel(P128)\
|
||||
' "${@}" -e '$a\
|
||||
#pragma datamodel(pop)\
|
||||
' < "${srcfile}" > "${destfile}"
|
||||
}
|
||||
|
||||
# Copy the header files.
|
||||
|
||||
for HFILE in *.h "${TOPDIR}/os400/libssh2_ccsid.h"
|
||||
do DEST="${SRCPF}/`db2_name \"${HFILE}\"`.MBR"
|
||||
|
||||
if action_needed "${DEST}" "${HFILE}"
|
||||
then copy_hfile "${DEST}" "${HFILE}"
|
||||
IFSDEST="${IFSINCLUDE}/`basename \"${HFILE}\"`"
|
||||
rm -f "${IFSDEST}"
|
||||
ln -s "${DEST}" "${IFSDEST}"
|
||||
fi
|
||||
done
|
||||
92
os400/make-rpg.sh
Normal file
92
os400/make-rpg.sh
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Installation of the ILE/RPG header files in the OS/400 library.
|
||||
#
|
||||
|
||||
SCRIPTDIR=`dirname "${0}"`
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/os400/libssh2rpg"
|
||||
|
||||
|
||||
# Create the OS/400 source program file for the ILE/RPG header files.
|
||||
|
||||
SRCPF="${LIBIFSNAME}/LIBSSH2RPG.FILE"
|
||||
|
||||
if action_needed "${SRCPF}"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBSSH2RPG) RCDLEN(112)"
|
||||
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libssh2: ILE/RPG header files')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Map file names to DB2 name syntax.
|
||||
|
||||
for HFILE in *.rpgle *.rpgle.in
|
||||
do NAME="`basename \"${HFILE}\" .in`"
|
||||
VAR="`basename \"${NAME}\" .rpgle`"
|
||||
VAL="`db2_name \"${NAME}\"`"
|
||||
|
||||
eval "VAR_${VAR}=\"${VAL}\""
|
||||
echo "${VAR} s/${VAR}/${VAL}/g"
|
||||
done > tmpsubstfile1
|
||||
|
||||
# Order substitution commands so that a prefix appears after all
|
||||
# file names beginning with the prefix.
|
||||
|
||||
sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2
|
||||
|
||||
|
||||
change_include()
|
||||
|
||||
{
|
||||
sed -e '\#^....../include *"libssh2rpg/#{' \
|
||||
-e 's///' \
|
||||
-e 's/".*//' \
|
||||
-f tmpsubstfile2 \
|
||||
-e 's#.*# /include libssh2rpg,&#' \
|
||||
-e '}'
|
||||
}
|
||||
|
||||
|
||||
# Create the IFS directory for the ILE/RPG header files.
|
||||
|
||||
RPGIFSDIR="${IFSDIR}/include/libssh2rpg"
|
||||
|
||||
if action_needed "${RPGIFSDIR}"
|
||||
then mkdir -p "${RPGIFSDIR}"
|
||||
fi
|
||||
|
||||
# Copy the header files to IFS ILE/RPG include directory.
|
||||
# Copy them with include path editing to the DB2 library.
|
||||
|
||||
for HFILE in *.rpgle *.rpgle.in
|
||||
do IFSCMD="cat \"${HFILE}\""
|
||||
DB2CMD="change_include < \"${HFILE}\""
|
||||
IFSFILE="`basename \"${HFILE}\" .in`"
|
||||
|
||||
case "${HFILE}" in
|
||||
|
||||
*.in) IFSCMD="${IFSCMD} | versioned_copy"
|
||||
DB2CMD="${DB2CMD} | versioned_copy"
|
||||
;;
|
||||
esac
|
||||
|
||||
IFSDEST="${RPGIFSDIR}/${IFSFILE}"
|
||||
|
||||
if action_needed "${IFSDEST}" "${HFILE}"
|
||||
then eval "${IFSCMD}" > "${IFSDEST}"
|
||||
fi
|
||||
|
||||
eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\""
|
||||
DB2DEST="${SRCPF}/${DB2MBR}.MBR"
|
||||
|
||||
if action_needed "${DB2DEST}" "${HFILE}"
|
||||
then eval "${DB2CMD}" | change_include > tmphdrfile
|
||||
|
||||
# Need to translate to target CCSID.
|
||||
|
||||
CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')"
|
||||
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
|
||||
system "${CMD}"
|
||||
fi
|
||||
done
|
||||
208
os400/make-src.sh
Normal file
208
os400/make-src.sh
Normal file
@@ -0,0 +1,208 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# libssh2 compilation script for the OS/400.
|
||||
#
|
||||
|
||||
SCRIPTDIR=`dirname "${0}"`
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/src"
|
||||
|
||||
|
||||
# Function to extract external prototypes from header files.
|
||||
# Input: concatenated header files.
|
||||
# Output: external prototypes, one per (long) line.
|
||||
|
||||
extproto()
|
||||
{
|
||||
sed -e 'x;G;s/^\n//;s/\n/ /g' \
|
||||
-e 's#[[:space:]]*/\*[^*]*\(\*\([^/*][^*]*\)\{0,1\}\)*\*/[[:space:]]*##g' \
|
||||
-e 'h' \
|
||||
-e '/\/\*/!{' \
|
||||
-e '/^#/{s/^.*[^\\]$//;h;d' \
|
||||
-e '}' \
|
||||
-e 's/[{}]/;/g;s/\\$//' \
|
||||
-e ':loop1' \
|
||||
-e '/;/{' \
|
||||
-e 's/^[^;]*;//;x;s/;.*//' \
|
||||
-e '/^[[:space:]]*LIBSSH2_API[[:space:]].*(/{' \
|
||||
-e 's/^[[:space:]]*LIBSSH2_API[[:space:]]*//' \
|
||||
-e 's/[[:space:]]*$//' \
|
||||
-e 's/[[:space:]][[:space:]]*/ /g' \
|
||||
-e 'p' \
|
||||
-e '}' \
|
||||
-e 'g;bloop1' \
|
||||
-e '}' \
|
||||
-e '}' \
|
||||
-n
|
||||
}
|
||||
|
||||
# Need to have IFS access to the mih/modasa header file.
|
||||
|
||||
if action_needed modasa.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/MODASA.MBR'
|
||||
then rm -f modasa.mih
|
||||
ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/MODASA.MBR' modasa.mih
|
||||
fi
|
||||
|
||||
|
||||
# Create and compile the identification source file.
|
||||
|
||||
echo '#pragma comment(user, "libssh2 version '"${LIBSSH2_VERSION}"'")' > os400.c
|
||||
echo '#pragma comment(user, __DATE__)' >> os400.c
|
||||
echo '#pragma comment(user, __TIME__)' >> os400.c
|
||||
echo '#pragma comment(copyright, "See COPYING file. OS/400 version by P. Monnerat")' >> os400.c
|
||||
make_module OS400 os400.c
|
||||
LINK= # No need to rebuild service program yet.
|
||||
MODULES=
|
||||
|
||||
|
||||
# Generate the procedures implementing macros.
|
||||
|
||||
if action_needed macros.c "${TOPDIR}/os400/macros.h"
|
||||
then (
|
||||
echo '#include "libssh2_publickey.h"'
|
||||
echo '#include "libssh2_sftp.h"'
|
||||
extproto < "${TOPDIR}/os400/macros.h" |
|
||||
sed -e 'h;s/^[^(]*[ *]\([^ (]*\) *(.*/\1/' \
|
||||
-e 's/.*/#pragma map(_&, "&")/;p' \
|
||||
-e 'g;s/^\([^(]*[ *]\)\([^ (]*\)\( *(.*\)/\1_\2\3 {/;p' \
|
||||
-e 'g;s/^[^(]*(\(.*\))$/,\1,/;s/[^A-Za-z0-9_,]/ /g' \
|
||||
-e 's/ *,/,/g;s/,[^,]* \([^ ,]*\)/,\1/g' \
|
||||
-e 's/ //g;s/^,void,$/,,/' \
|
||||
-e 's/^,\(.*\),$/(\1); }/;s/,/, /g' \
|
||||
-e 'x;s/(.*//;s/ *$//;G;s/\n//g' \
|
||||
-e 's/^void\([ *]\)/\1/;s/^ *//' \
|
||||
-e 's/^[^(]*[ *]\([A-Za-z][A-Za-z0-9_]* *(\)/return \1/' \
|
||||
-e 's/.*/ &/'
|
||||
) > macros.c
|
||||
fi
|
||||
|
||||
# Get source list.
|
||||
|
||||
cat ../Makefile.inc ../Makefile.os400qc3.inc |
|
||||
sed -e ':begin' \
|
||||
-e '/\\$/{' \
|
||||
-e 's/\\$/ /' \
|
||||
-e 'N' \
|
||||
-e 'bbegin' \
|
||||
-e '}' \
|
||||
-e 's/\n//g' \
|
||||
-e 's/[[:space:]]*$//' \
|
||||
-e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
|
||||
-e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
|
||||
> tmpscript.sh
|
||||
. ./tmpscript.sh
|
||||
|
||||
|
||||
# Compile the sources into modules.
|
||||
|
||||
INCLUDES="'`pwd`'"
|
||||
|
||||
for SRC in "${TOPDIR}/os400/os400sys.c" "${TOPDIR}/os400/ccsid.c" \
|
||||
${CSOURCES} ${CRYPTO_CSOURCES} macros.c
|
||||
do MODULE=`db2_name "${SRC}"`
|
||||
make_module "${MODULE}" "${SRC}"
|
||||
done
|
||||
|
||||
|
||||
# If needed, (re)create the static binding directory.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
||||
CMD="${CMD} TEXT('libssh2 API static binding directory')"
|
||||
system "${CMD}"
|
||||
|
||||
for MODULE in ${MODULES}
|
||||
do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
||||
CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
|
||||
system "${CMD}"
|
||||
done
|
||||
|
||||
# V6R1M0 does not list system service program QC3PBEXT in the
|
||||
# implicit binding directory: thus we add it here in ours.
|
||||
|
||||
CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
||||
CMD="${CMD} OBJ((QSYS/QC3PBEXT *SRVPGM))"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# The exportation file for service program creation must be in a DB2
|
||||
# source file, so make sure it exists.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/TOOLS.FILE"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
|
||||
CMD="${CMD} TEXT('libssh2: build tools')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Gather the list of symbols to export.
|
||||
|
||||
EXPORTS=`cat "${TOPDIR}"/include/*.h "${TOPDIR}/os400/macros.h" \
|
||||
"${TOPDIR}/os400/libssh2_ccsid.h" |
|
||||
extproto |
|
||||
sed -e 's/(.*//;s/[^A-Za-z0-9_]/ /g;s/ *$//;s/^.* //'`
|
||||
|
||||
# Create the service program exportation file in DB2 member if needed.
|
||||
|
||||
BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
|
||||
|
||||
if action_needed "${BSF}" Makefile.am
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBSSH2_${SONAME}')" \
|
||||
> "${BSF}"
|
||||
for EXPORT in ${EXPORTS}
|
||||
do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
|
||||
done
|
||||
|
||||
echo ' ENDPGMEXP' >> "${BSF}"
|
||||
fi
|
||||
|
||||
|
||||
# Build the service program if needed.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
|
||||
CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
|
||||
CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
|
||||
CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
|
||||
if [ "${WITH_ZLIB}" != 0 ]
|
||||
then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
|
||||
liblist -a "${ZLIB_LIB}"
|
||||
fi
|
||||
CMD="${CMD})"
|
||||
CMD="${CMD} BNDSRVPGM(QADRTTS)"
|
||||
CMD="${CMD} TEXT('libssh2 API library')"
|
||||
CMD="${CMD} TGTRLS(${TGTRLS})"
|
||||
system "${CMD}"
|
||||
LINK=YES
|
||||
fi
|
||||
|
||||
|
||||
# If needed, (re)create the dynamic binding directory.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
||||
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
|
||||
CMD="${CMD} TEXT('libssh2 API dynamic binding directory')"
|
||||
system "${CMD}"
|
||||
CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
|
||||
CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
|
||||
system "${CMD}"
|
||||
fi
|
||||
49
os400/make.sh
Normal file
49
os400/make.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# libssh2 compilation script for the OS/400.
|
||||
#
|
||||
#
|
||||
# This is a shell script since make is not a standard component of OS/400.
|
||||
|
||||
SCRIPTDIR=`dirname "${0}"`
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}"
|
||||
|
||||
|
||||
# Create the OS/400 library if it does not exist.
|
||||
|
||||
if action_needed "${LIBIFSNAME}"
|
||||
then CMD="CRTLIB LIB(${TARGETLIB}) TEXT('libssh2: SSH2 protocol API')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Create the DOCS source file if it does not exist.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/DOCS.FILE"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(240)"
|
||||
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Copy some documentation files if needed.
|
||||
|
||||
for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README400" \
|
||||
"${TOPDIR}/NEWS" "${TOPDIR}/README" "${TOPDIR}/docs/AUTHORS" \
|
||||
"${TOPDIR}/docs/BINDINGS"
|
||||
do MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${TEXT}\"`.MBR"
|
||||
|
||||
if action_needed "${MEMBER}" "${TEXT}"
|
||||
then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
|
||||
CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
|
||||
system "${CMD}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Build in each directory.
|
||||
|
||||
for SUBDIR in include rpg src
|
||||
do "${SCRIPTDIR}/make-${SUBDIR}.sh"
|
||||
done
|
||||
218
os400/os400sys.c
Normal file
218
os400/os400sys.c
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* OS/400 additional support. */
|
||||
|
||||
#define LIBSSH2_DISABLE_QADRT_EXT
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <alloca.h>
|
||||
#include <netdb.h>
|
||||
#include <qadrt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifdef LIBSSH2_HAVE_ZLIB
|
||||
# include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*** QADRT OS/400 ASCII runtime defines only the most used procedures, but
|
||||
*** a lot of them are not supported. This module implements
|
||||
*** ASCII wrappers for those that are used by libssh2, but not
|
||||
*** defined by QADRT.
|
||||
**/
|
||||
|
||||
#pragma convert(37) /* Restore EBCDIC. */
|
||||
|
||||
|
||||
static int
|
||||
convert_sockaddr(struct sockaddr_storage * dstaddr,
|
||||
const struct sockaddr * srcaddr, int srclen)
|
||||
|
||||
{
|
||||
const struct sockaddr_un * srcu;
|
||||
struct sockaddr_un * dstu;
|
||||
unsigned int i;
|
||||
unsigned int dstsize;
|
||||
|
||||
/* Convert a socket address into job CCSID, if needed. */
|
||||
|
||||
if(!srcaddr || srclen < offsetof(struct sockaddr, sa_family) +
|
||||
sizeof srcaddr->sa_family || srclen > sizeof *dstaddr) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy((char *) dstaddr, (char *) srcaddr, srclen);
|
||||
|
||||
switch (srcaddr->sa_family) {
|
||||
|
||||
case AF_UNIX:
|
||||
srcu = (const struct sockaddr_un *) srcaddr;
|
||||
dstu = (struct sockaddr_un *) dstaddr;
|
||||
dstsize = sizeof *dstaddr - offsetof(struct sockaddr_un, sun_path);
|
||||
srclen -= offsetof(struct sockaddr_un, sun_path);
|
||||
i = QadrtConvertA2E(dstu->sun_path, srcu->sun_path, dstsize - 1, srclen);
|
||||
dstu->sun_path[i] = '\0';
|
||||
i += offsetof(struct sockaddr_un, sun_path);
|
||||
srclen = i;
|
||||
}
|
||||
|
||||
return srclen;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_libssh2_os400_connect(int sd, struct sockaddr * destaddr, int addrlen)
|
||||
|
||||
{
|
||||
int i;
|
||||
struct sockaddr_storage laddr;
|
||||
|
||||
i = convert_sockaddr(&laddr, destaddr, addrlen);
|
||||
|
||||
if(i < 0)
|
||||
return -1;
|
||||
|
||||
return connect(sd, (struct sockaddr *) &laddr, i);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_libssh2_os400_vsnprintf(char *dst, size_t len, const char *fmt, va_list args)
|
||||
{
|
||||
size_t l = 4096;
|
||||
int i;
|
||||
char *buf;
|
||||
|
||||
if (!dst || !len) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (l < len)
|
||||
l = len;
|
||||
|
||||
buf = alloca(l);
|
||||
|
||||
if (!buf) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
i = vsprintf(buf, fmt, args);
|
||||
|
||||
if (i < 0)
|
||||
return i;
|
||||
|
||||
if (--len > i)
|
||||
len = i;
|
||||
|
||||
if (len)
|
||||
memcpy(dst, buf, len);
|
||||
|
||||
dst[len] = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
/* VARARGS3 */
|
||||
int
|
||||
_libssh2_os400_snprintf(char *dst, size_t len, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, fmt);
|
||||
ret = _libssh2_os400_vsnprintf(dst, len, fmt, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef LIBSSH2_HAVE_ZLIB
|
||||
int
|
||||
_libssh2_os400_inflateInit_(z_streamp strm,
|
||||
const char *version, int stream_size)
|
||||
{
|
||||
char *ebcversion;
|
||||
int i;
|
||||
|
||||
if (!version)
|
||||
return Z_VERSION_ERROR;
|
||||
i = strlen(version);
|
||||
ebcversion = alloca(i + 1);
|
||||
if (!ebcversion)
|
||||
return Z_VERSION_ERROR;
|
||||
i = QadrtConvertA2E(ebcversion, version, i, i - 1);
|
||||
ebcversion[i] = '\0';
|
||||
return inflateInit_(strm, ebcversion, stream_size);
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_os400_deflateInit_(z_streamp strm, int level,
|
||||
const char *version, int stream_size)
|
||||
{
|
||||
char *ebcversion;
|
||||
int i;
|
||||
|
||||
if (!version)
|
||||
return Z_VERSION_ERROR;
|
||||
i = strlen(version);
|
||||
ebcversion = alloca(i + 1);
|
||||
if (!ebcversion)
|
||||
return Z_VERSION_ERROR;
|
||||
i = QadrtConvertA2E(ebcversion, version, i, i - 1);
|
||||
ebcversion[i] = '\0';
|
||||
return deflateInit_(strm, level, ebcversion, stream_size);
|
||||
}
|
||||
|
||||
#endif
|
||||
398
src/CMakeLists.txt
Normal file
398
src/CMakeLists.txt
Normal file
@@ -0,0 +1,398 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExistsMayNeedLibrary)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckTypeSize)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckNonblockingSocketSupport)
|
||||
include(SocketLibraries)
|
||||
|
||||
## Cryptography backend choice
|
||||
|
||||
set(CRYPTO_BACKEND
|
||||
""
|
||||
CACHE
|
||||
STRING
|
||||
"The backend to use for cryptography: OpenSSL, Libgcrypt or WinCNG,
|
||||
or empty to try any available")
|
||||
|
||||
# If the crypto backend was given, rather than searching for the first
|
||||
# we are able to find, the find_package commands must abort configuration
|
||||
# and report to the user.
|
||||
if(CRYPTO_BACKEND)
|
||||
set(SPECIFIC_CRYPTO_REQUIREMENT REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
set(CRYPTO_BACKEND "OpenSSL")
|
||||
set(CRYPTO_SOURCES openssl.c openssl.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_OPENSSL)
|
||||
list(APPEND PRIVATE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
|
||||
list(APPEND LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
list(APPEND PC_REQUIRES_PRIVATE libssl libcrypto)
|
||||
|
||||
if (WIN32)
|
||||
find_file(DLL_LIBEAY32
|
||||
NAMES libeay32.dll crypto.dll
|
||||
HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}
|
||||
PATH_SUFFIXES bin)
|
||||
if (NOT DLL_LIBEAY32)
|
||||
message(WARNING
|
||||
"Unable to find OpenSSL libeay32 DLL, executables may not run")
|
||||
endif()
|
||||
|
||||
find_file(DLL_SSLEAY32
|
||||
NAMES ssleay32.dll ssl.dll
|
||||
HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}
|
||||
PATH_SUFFIXES bin)
|
||||
if (NOT DLL_SSLEAY32)
|
||||
message(WARNING
|
||||
"Unable to find OpenSSL ssleay32 DLL, executables may not run")
|
||||
endif()
|
||||
|
||||
if(DLL_LIBEAY32 AND DLL_SSLEAY32)
|
||||
list(APPEND _RUNTIME_DEPENDENCIES ${DLL_LIBEAY32} ${DLL_SSLEAY32})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
check_function_exists(EVP_aes_128_ctr HAVE_EVP_AES_128_CTR)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "Libgcrypt" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
find_package(Libgcrypt ${SPECIFIC_CRYPTO_REQUIREMENT})
|
||||
|
||||
if(LIBGCRYPT_FOUND)
|
||||
set(CRYPTO_BACKEND "Libgcrypt")
|
||||
set(CRYPTO_SOURCES libgcrypt.c libgcrypt.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_LIBGCRYPT)
|
||||
list(APPEND PRIVATE_INCLUDE_DIRECTORIES ${LIBGCRYPT_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${LIBGCRYPT_LIBRARIES})
|
||||
list(APPEND PC_LIBS -lgcrypt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
# The check actually compiles the header. This requires windows.h.
|
||||
check_include_files("windows.h;bcrypt.h" HAVE_BCRYPT_H)
|
||||
|
||||
if(HAVE_BCRYPT_H)
|
||||
set(CRYPTO_BACKEND "WinCNG")
|
||||
set(CRYPTO_SOURCES wincng.c wincng.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_WINCNG)
|
||||
|
||||
set(HAVE_LIBCRYPT32 TRUE)
|
||||
list(APPEND LIBRARIES bcrypt)
|
||||
list(APPEND PC_LIBS -lbcrypt)
|
||||
|
||||
check_include_files(ntdef.h HAVE_NTDEF_H)
|
||||
check_include_files(ntstatus.h HAVE_NTSTATUS_H)
|
||||
|
||||
# Reading keys from files is optional and depends on Wincrypt
|
||||
check_include_files("windows.h;wincrypt.h" HAVE_WINCRYPT_H)
|
||||
|
||||
if(HAVE_WINCRYPT_H)
|
||||
list(APPEND LIBRARIES crypt32)
|
||||
list(APPEND PC_LIBS -lcrypt32)
|
||||
endif()
|
||||
|
||||
elseif(${SPECIFIC_CRYPTO_REQUIREMENT} STREQUAL ${REQUIRED})
|
||||
message(FATAL_ERROR "WinCNG not available")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CRYPTO_BACKEND)
|
||||
message(FATAL_ERROR "No suitable cryptography backend found.")
|
||||
endif()
|
||||
|
||||
## Library definition
|
||||
|
||||
include(GNUInstallDirs)
|
||||
set(SOURCES
|
||||
${CRYPTO_SOURCES}
|
||||
agent.c
|
||||
channel.c
|
||||
channel.h
|
||||
comp.c
|
||||
comp.h
|
||||
crypt.c
|
||||
crypto.h
|
||||
global.c
|
||||
hostkey.c
|
||||
keepalive.c
|
||||
kex.c
|
||||
knownhost.c
|
||||
libssh2_priv.h
|
||||
mac.c
|
||||
mac.h
|
||||
misc.c
|
||||
misc.h
|
||||
packet.c
|
||||
packet.h
|
||||
pem.c
|
||||
publickey.c
|
||||
scp.c
|
||||
session.c
|
||||
session.h
|
||||
sftp.c
|
||||
sftp.h
|
||||
transport.c
|
||||
transport.h
|
||||
userauth.c
|
||||
userauth.h
|
||||
version.c)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/win32/libssh2.rc)
|
||||
endif()
|
||||
|
||||
add_library(libssh2 ${SOURCES})
|
||||
# we want it to be called libssh2 on all platforms
|
||||
set_target_properties(libssh2 PROPERTIES PREFIX "")
|
||||
|
||||
target_compile_definitions(libssh2 PRIVATE ${PRIVATE_COMPILE_DEFINITIONS})
|
||||
target_include_directories(libssh2
|
||||
PRIVATE ${PRIVATE_INCLUDE_DIRECTORIES}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
## Options
|
||||
|
||||
add_feature_info("Shared library" BUILD_SHARED_LIBS
|
||||
"creating libssh2 as a shared library (.so/.dll)")
|
||||
|
||||
option(ENABLE_ZLIB_COMPRESSION "Use zlib for compression")
|
||||
add_feature_info(Compression ENABLE_ZLIB_COMPRESSION
|
||||
"using zlib for compression")
|
||||
if(ENABLE_ZLIB_COMPRESSION)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
target_include_directories(libssh2 PRIVATE ${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
|
||||
list(APPEND PC_REQUIRES_PRIVATE zlib)
|
||||
if(ZLIB_FOUND)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_HAVE_ZLIB=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_CRYPT_NONE "Permit \"none\" cipher -- NOT RECOMMENDED")
|
||||
add_feature_info("\"none\" cipher" ENABLE_CRYPT_NONE "")
|
||||
if(ENABLE_CRYPT_NONE)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_CRYPT_NONE=1)
|
||||
endif()
|
||||
|
||||
option(ENABLE_MAC_NONE "Permit \"none\" MAC -- NOT RECOMMMENDED")
|
||||
add_feature_info("\"none\" MAC" ENABLE_MAC_NONE "")
|
||||
if(ENABLE_MAC_NONE)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_MAC_NONE=1)
|
||||
endif()
|
||||
|
||||
option(ENABLE_GEX_NEW
|
||||
"Enable diffie-hellman-group-exchange-sha1 method" ON)
|
||||
add_feature_info("diffie-hellman-group-exchange-sha1" ENABLE_GEX_NEW
|
||||
"\"new\" diffie-hellman-group-exchange-sha1 method")
|
||||
if(ENABLE_GEX_NEW)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_DH_GEX_NEW=1)
|
||||
endif()
|
||||
|
||||
# Enable debugging logging by default if the user configured a debug build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEBUG_LOGGING_DEFAULT ON)
|
||||
else()
|
||||
set(DEBUG_LOGGING_DEFAULT OFF)
|
||||
endif()
|
||||
option(ENABLE_DEBUG_LOGGING "log execution with debug trace"
|
||||
${DEBUG_LOGGING_DEFAULT})
|
||||
add_feature_info(Logging ENABLE_DEBUG_LOGGING
|
||||
"Logging of execution with debug trace")
|
||||
if(ENABLE_DEBUG_LOGGING)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2DEBUG)
|
||||
endif()
|
||||
|
||||
## Platform checks
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
||||
|
||||
check_include_files(sys/uio.h HAVE_SYS_UIO_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_files(sys/un.h HAVE_SYS_UN_H)
|
||||
check_include_files(windows.h HAVE_WINDOWS_H)
|
||||
check_include_files(ws2tcpip.h HAVE_WS2TCPIP_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
check_type_size("long long" LONGLONG)
|
||||
|
||||
if(HAVE_SYS_TIME_H)
|
||||
check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
|
||||
else()
|
||||
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
|
||||
endif()
|
||||
if(HAVE_STDLIB_H)
|
||||
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
|
||||
else()
|
||||
check_function_exists(strtoll HAVE_STRTOLL)
|
||||
endif()
|
||||
if (NOT HAVE_STRTOLL)
|
||||
# Try _strtoi64 if strtoll isn't available
|
||||
check_symbol_exists(_strtoi64 stdlib.h HAVE_STRTOI64)
|
||||
endif()
|
||||
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
|
||||
${CMAKE_SYSTEM_NAME} STREQUAL "Interix")
|
||||
# poll() does not work on these platforms
|
||||
#
|
||||
# Interix: "does provide poll(), but the implementing developer must
|
||||
# have been in a bad mood, because poll() only works on the /proc
|
||||
# filesystem here"
|
||||
#
|
||||
# Mac OS X's poll has funny behaviors, like:
|
||||
# not being able to do poll on no fildescriptors (10.3?)
|
||||
# not being able to poll on some files (like anything in /dev)
|
||||
# not having reliable timeout support
|
||||
# inconsistent return of POLLHUP where other implementations give POLLIN
|
||||
message("poll use is disabled on this platform")
|
||||
else()
|
||||
check_function_exists(poll HAVE_POLL)
|
||||
endif()
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
# Non-blocking socket support tests. Must be after after library tests to
|
||||
# link correctly
|
||||
set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBRARIES})
|
||||
check_nonblocking_socket_support()
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
||||
# to find generated header
|
||||
target_include_directories(libssh2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Check for the OS.
|
||||
# Daniel's note: this should not be necessary and we need to work to
|
||||
# get this removed.
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_WIN32)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_DARWIN)
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "2.8.12")
|
||||
# Fall back to over-linking dependencies
|
||||
target_link_libraries(libssh2 ${LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(libssh2 PRIVATE ${LIBRARIES})
|
||||
endif()
|
||||
|
||||
## Installation
|
||||
|
||||
install(FILES
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2.h
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2_publickey.h
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2_sftp.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
install(TARGETS libssh2
|
||||
EXPORT Libssh2Config
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
list(APPEND _RUNTIME_DEPENDENCIES $<TARGET_FILE:libssh2>)
|
||||
endif()
|
||||
|
||||
set(RUNTIME_DEPENDENCIES ${_RUNTIME_DEPENDENCIES} CACHE INTERNAL
|
||||
"Files that must be in the same directory as the executables at runtime.")
|
||||
|
||||
# Package config
|
||||
|
||||
## During package installation, install Libssh2Config.cmake
|
||||
install(EXPORT Libssh2Config
|
||||
NAMESPACE Libssh2::
|
||||
DESTINATION lib/cmake/libssh2)
|
||||
|
||||
## During build, register directly from build tree
|
||||
# create Libssh2Config.cmake
|
||||
export(TARGETS libssh2 NAMESPACE Libssh2:: FILE Libssh2Config.cmake)
|
||||
export(PACKAGE Libssh2) # register it
|
||||
|
||||
## Export a .pc file for client projects not using CMaek
|
||||
if(PC_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" "," PC_REQUIRES_PRIVATE "${PC_REQUIRES_PRIVATE}")
|
||||
endif()
|
||||
if(PC_LIBS)
|
||||
string(REPLACE ";" " " PC_LIBS "${PC_LIBS}")
|
||||
endif()
|
||||
configure_file(libssh2.pc.in libssh2.pc @ONLY)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/libssh2.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
## Versioning
|
||||
|
||||
set_target_properties(libssh2 PROPERTIES
|
||||
SOVERSION 1
|
||||
VERSION 1.0.1)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
|
||||
VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}"
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
|
||||
DESTINATION lib/cmake/libssh2)
|
||||
@@ -11,13 +11,17 @@ endif
|
||||
if WINCNG
|
||||
include ../Makefile.WinCNG.inc
|
||||
endif
|
||||
if OS400QC3
|
||||
include ../Makefile.os400qc3.inc
|
||||
endif
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include ../Makefile.inc
|
||||
|
||||
libssh2_la_SOURCES = $(CSOURCES) $(HHEADERS)
|
||||
|
||||
EXTRA_DIST = libssh2_config.h.in NMakefile
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in libssh2.pc.in
|
||||
EXTRA_DIST += CMakeLists.txt NMakefile
|
||||
|
||||
lib_LTLIBRARIES = libssh2.la
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -15,7 +15,17 @@
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -78,11 +88,6 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
DIST_COMMON = $(srcdir)/../Makefile.OpenSSL.inc \
|
||||
$(srcdir)/../Makefile.libgcrypt.inc \
|
||||
$(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.inc \
|
||||
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(srcdir)/libssh2_config.h.in $(top_srcdir)/depcomp
|
||||
subdir = src
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
@@ -93,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = libssh2_config.h \
|
||||
$(top_builddir)/example/libssh2_config.h
|
||||
@@ -131,12 +137,13 @@ libssh2_la_LIBADD =
|
||||
am__libssh2_la_SOURCES_DIST = channel.c comp.c crypt.c hostkey.c kex.c \
|
||||
mac.c misc.c packet.c publickey.c scp.c session.c sftp.c \
|
||||
userauth.c transport.c version.c knownhost.c agent.c \
|
||||
libgcrypt.c openssl.c wincng.c pem.c keepalive.c global.c \
|
||||
libssh2_priv.h libgcrypt.h openssl.h wincng.h transport.h \
|
||||
channel.h comp.h mac.h misc.h packet.h userauth.h session.h \
|
||||
sftp.h crypto.h
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_FALSE@@WINCNG_TRUE@am__objects_1 = \
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_FALSE@@WINCNG_TRUE@ wincng.lo
|
||||
libgcrypt.c openssl.c os400qc3.c wincng.c pem.c keepalive.c \
|
||||
global.c libssh2_priv.h libgcrypt.h openssl.h os400qc3.h \
|
||||
wincng.h transport.h channel.h comp.h mac.h misc.h packet.h \
|
||||
userauth.h session.h sftp.h crypto.h
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_FALSE@@OS400QC3_FALSE@@WINCNG_TRUE@am__objects_1 = wincng.lo
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_FALSE@@OS400QC3_TRUE@am__objects_1 = \
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_FALSE@@OS400QC3_TRUE@ os400qc3.lo
|
||||
@LIBGCRYPT_FALSE@@OPENSSL_TRUE@am__objects_1 = openssl.lo
|
||||
@LIBGCRYPT_TRUE@am__objects_1 = libgcrypt.lo
|
||||
am__objects_2 = channel.lo comp.lo crypt.lo hostkey.lo kex.lo mac.lo \
|
||||
@@ -215,6 +222,11 @@ am__define_uniq_tagged_files = \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/../Makefile.OpenSSL.inc \
|
||||
$(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.inc \
|
||||
$(srcdir)/../Makefile.libgcrypt.inc \
|
||||
$(srcdir)/../Makefile.os400qc3.inc $(srcdir)/Makefile.in \
|
||||
$(srcdir)/libssh2_config.h.in $(top_srcdir)/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -348,6 +360,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -361,9 +374,11 @@ top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
@LIBGCRYPT_TRUE@CRYPTO_CSOURCES = libgcrypt.c
|
||||
@OPENSSL_TRUE@CRYPTO_CSOURCES = openssl.c
|
||||
@OS400QC3_TRUE@CRYPTO_CSOURCES = os400qc3.c
|
||||
@WINCNG_TRUE@CRYPTO_CSOURCES = wincng.c
|
||||
@LIBGCRYPT_TRUE@CRYPTO_HHEADERS = libgcrypt.h
|
||||
@OPENSSL_TRUE@CRYPTO_HHEADERS = openssl.h
|
||||
@OS400QC3_TRUE@CRYPTO_HHEADERS = os400qc3.h
|
||||
@WINCNG_TRUE@CRYPTO_HHEADERS = wincng.h
|
||||
CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
|
||||
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
|
||||
@@ -377,7 +392,8 @@ HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
libssh2_la_SOURCES = $(CSOURCES) $(HHEADERS)
|
||||
EXTRA_DIST = libssh2_config.h.in NMakefile
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in \
|
||||
libssh2.pc.in CMakeLists.txt NMakefile
|
||||
lib_LTLIBRARIES = libssh2.la
|
||||
|
||||
# srcdir/include for the shipped headers
|
||||
@@ -421,7 +437,7 @@ all: libssh2_config.h
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../Makefile.OpenSSL.inc $(srcdir)/../Makefile.libgcrypt.inc $(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.inc $(am__configure_deps)
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../Makefile.OpenSSL.inc $(srcdir)/../Makefile.libgcrypt.inc $(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.os400qc3.inc $(srcdir)/../Makefile.inc $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
@@ -433,7 +449,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/..
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -442,7 +457,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
$(srcdir)/../Makefile.OpenSSL.inc $(srcdir)/../Makefile.libgcrypt.inc $(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.inc:
|
||||
$(srcdir)/../Makefile.OpenSSL.inc $(srcdir)/../Makefile.libgcrypt.inc $(srcdir)/../Makefile.WinCNG.inc $(srcdir)/../Makefile.os400qc3.inc $(srcdir)/../Makefile.inc $(am__empty):
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
@@ -525,6 +540,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os400qc3.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pem.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/publickey.Plo@am__quote@
|
||||
@@ -770,6 +786,8 @@ uninstall-am: uninstall-libLTLIBRARIES
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-libLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -239,8 +239,9 @@ agent_disconnect_unix(LIBSSH2_AGENT *agent)
|
||||
{
|
||||
int ret;
|
||||
ret = close(agent->fd);
|
||||
|
||||
if(ret == -1)
|
||||
if(ret != -1)
|
||||
agent->fd = LIBSSH2_INVALID_SOCKET;
|
||||
else
|
||||
return _libssh2_error(agent->session, LIBSSH2_ERROR_SOCKET_DISCONNECT,
|
||||
"failed closing the agent socket");
|
||||
return LIBSSH2_ERROR_NONE;
|
||||
@@ -688,7 +689,7 @@ libssh2_agent_connect(LIBSSH2_AGENT *agent)
|
||||
int i, rc = -1;
|
||||
for (i = 0; supported_backends[i].name; i++) {
|
||||
agent->ops = supported_backends[i].ops;
|
||||
rc = agent->ops->connect(agent);
|
||||
rc = (agent->ops->connect)(agent);
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1252,6 +1252,11 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
{ SSH_MSG_CHANNEL_SUCCESS, SSH_MSG_CHANNEL_FAILURE, 0 };
|
||||
int rc;
|
||||
|
||||
if (channel->process_state == libssh2_NB_state_end) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_BAD_USE,
|
||||
"Channel can not be reused");
|
||||
}
|
||||
|
||||
if (channel->process_state == libssh2_NB_state_idle) {
|
||||
/* 10 = packet_type(1) + channel(4) + request_len(4) + want_reply(1) */
|
||||
channel->process_packet_len = request_len + 10;
|
||||
@@ -1298,7 +1303,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
else if (rc) {
|
||||
LIBSSH2_FREE(session, channel->process_packet);
|
||||
channel->process_packet = NULL;
|
||||
channel->process_state = libssh2_NB_state_idle;
|
||||
channel->process_state = libssh2_NB_state_end;
|
||||
return _libssh2_error(session, rc,
|
||||
"Unable to send channel request");
|
||||
}
|
||||
@@ -1320,14 +1325,14 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
channel->process_state = libssh2_NB_state_idle;
|
||||
channel->process_state = libssh2_NB_state_end;
|
||||
return _libssh2_error(session, rc,
|
||||
"Failed waiting for channel success");
|
||||
}
|
||||
|
||||
code = data[0];
|
||||
LIBSSH2_FREE(session, data);
|
||||
channel->process_state = libssh2_NB_state_idle;
|
||||
channel->process_state = libssh2_NB_state_end;
|
||||
|
||||
if (code == SSH_MSG_CHANNEL_SUCCESS)
|
||||
return 0;
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
#include "wincng.h"
|
||||
#endif
|
||||
|
||||
#ifdef LIBSSH2_OS400QC3
|
||||
#include "os400qc3.h"
|
||||
#endif
|
||||
|
||||
int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
||||
const unsigned char *edata,
|
||||
unsigned long elen,
|
||||
|
||||
@@ -66,6 +66,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
||||
libssh2_rsa_ctx *rsactx;
|
||||
const unsigned char *s, *e, *n;
|
||||
unsigned long len, e_len, n_len;
|
||||
int ret;
|
||||
|
||||
(void) hostkey_data_len;
|
||||
|
||||
@@ -92,9 +93,11 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
||||
s += 4;
|
||||
n = s;
|
||||
|
||||
if (_libssh2_rsa_new(&rsactx, e, e_len, n, n_len, NULL, 0,
|
||||
NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0))
|
||||
ret = _libssh2_rsa_new(&rsactx, e, e_len, n, n_len, NULL, 0,
|
||||
NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*abstract = rsactx;
|
||||
|
||||
@@ -197,6 +200,11 @@ hostkey_method_ssh_rsa_signv(LIBSSH2_SESSION * session,
|
||||
void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||
|
||||
#ifdef _libssh2_rsa_sha1_signv
|
||||
return _libssh2_rsa_sha1_signv(session, signature, signature_len,
|
||||
veccount, datavec, rsactx);
|
||||
#else
|
||||
int ret;
|
||||
int i;
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
@@ -215,6 +223,7 @@ hostkey_method_ssh_rsa_signv(LIBSSH2_SESSION * session,
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -235,6 +244,10 @@ hostkey_method_ssh_rsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#endif
|
||||
|
||||
static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_rsa = {
|
||||
"ssh-rsa",
|
||||
MD5_DIGEST_LENGTH,
|
||||
@@ -270,6 +283,8 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
||||
libssh2_dsa_ctx *dsactx;
|
||||
const unsigned char *p, *q, *g, *y, *s;
|
||||
unsigned long p_len, q_len, g_len, y_len, len;
|
||||
int ret;
|
||||
|
||||
(void) hostkey_data_len;
|
||||
|
||||
if (*abstract) {
|
||||
@@ -302,7 +317,11 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
||||
y = s;
|
||||
/* s += y_len; */
|
||||
|
||||
_libssh2_dsa_new(&dsactx, p, p_len, q, q_len, g, g_len, y, y_len, NULL, 0);
|
||||
ret = _libssh2_dsa_new(&dsactx, p, p_len, q, q_len,
|
||||
g, g_len, y, y_len, NULL, 0);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*abstract = dsactx;
|
||||
|
||||
|
||||
831
src/kex.c
831
src/kex.c
@@ -60,7 +60,7 @@
|
||||
SHA_DIGEST_LENGTH); \
|
||||
if (len > 0) { \
|
||||
libssh2_sha1_update(hash, value, len); \
|
||||
} else { \
|
||||
} else { \
|
||||
libssh2_sha1_update(hash, (version), 1); \
|
||||
libssh2_sha1_update(hash, session->session_id, \
|
||||
session->session_id_len); \
|
||||
@@ -70,6 +70,35 @@
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/* Helper macro called from kex_method_diffie_hellman_group1_sha256_key_exchange */
|
||||
#define LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(value, reqlen, version) \
|
||||
{ \
|
||||
libssh2_sha256_ctx hash; \
|
||||
unsigned long len = 0; \
|
||||
if (!(value)) { \
|
||||
value = LIBSSH2_ALLOC(session, reqlen + SHA256_DIGEST_LENGTH); \
|
||||
} \
|
||||
if (value) \
|
||||
while (len < (unsigned long)reqlen) { \
|
||||
libssh2_sha256_init(&hash); \
|
||||
libssh2_sha256_update(hash, exchange_state->k_value, \
|
||||
exchange_state->k_value_len); \
|
||||
libssh2_sha256_update(hash, exchange_state->h_sig_comp, \
|
||||
SHA256_DIGEST_LENGTH); \
|
||||
if (len > 0) { \
|
||||
libssh2_sha256_update(hash, value, len); \
|
||||
} else { \
|
||||
libssh2_sha256_update(hash, (version), 1); \
|
||||
libssh2_sha256_update(hash, session->session_id, \
|
||||
session->session_id_len); \
|
||||
} \
|
||||
libssh2_sha256_final(hash, (value) + len); \
|
||||
len += SHA256_DIGEST_LENGTH; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* diffie_hellman_sha1
|
||||
*
|
||||
@@ -83,10 +112,11 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
unsigned char packet_type_reply,
|
||||
unsigned char *midhash,
|
||||
unsigned long midhash_len,
|
||||
kmdhgGPsha1kex_state_t *exchange_state)
|
||||
kmdhgGPshakex_state_t *exchange_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
libssh2_sha1_ctx exchange_hash_ctx;
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_idle) {
|
||||
/* Setup initial values */
|
||||
@@ -202,6 +232,10 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
|
||||
session->server_hostkey_len = _libssh2_ntohu32(exchange_state->s);
|
||||
exchange_state->s += 4;
|
||||
|
||||
if (session->server_hostkey)
|
||||
LIBSSH2_FREE(session, session->server_hostkey);
|
||||
|
||||
session->server_hostkey =
|
||||
LIBSSH2_ALLOC(session, session->server_hostkey_len);
|
||||
if (!session->server_hostkey) {
|
||||
@@ -314,54 +348,56 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 5);
|
||||
}
|
||||
|
||||
libssh2_sha1_init(&exchange_state->exchange_hash);
|
||||
exchange_state->exchange_hash = (void*)&exchange_hash_ctx;
|
||||
libssh2_sha1_init(&exchange_hash_ctx);
|
||||
|
||||
if (session->local.banner) {
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
strlen((char *) session->local.banner) - 2);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
(char *) session->local.banner,
|
||||
strlen((char *) session->local.banner) - 2);
|
||||
} else {
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
LIBSSH2_SSH_DEFAULT_BANNER,
|
||||
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
||||
}
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
strlen((char *) session->remote.banner));
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
session->remote.banner,
|
||||
strlen((char *) session->remote.banner));
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->local.kexinit_len);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
session->local.kexinit,
|
||||
session->local.kexinit_len);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->remote.kexinit_len);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
session->remote.kexinit,
|
||||
session->remote.kexinit_len);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->server_hostkey_len);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
|
||||
@@ -374,38 +410,38 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
LIBSSH2_DH_GEX_OPTGROUP);
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp + 8,
|
||||
LIBSSH2_DH_GEX_MAXGROUP);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 12);
|
||||
#else
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
LIBSSH2_DH_GEX_OPTGROUP);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (midhash) {
|
||||
libssh2_sha1_update(exchange_state->exchange_hash, midhash,
|
||||
libssh2_sha1_update(exchange_hash_ctx, midhash,
|
||||
midhash_len);
|
||||
}
|
||||
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->e_packet + 1,
|
||||
exchange_state->e_packet_len - 1);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
exchange_state->f_value_len);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->f_value,
|
||||
exchange_state->f_value_len);
|
||||
|
||||
libssh2_sha1_update(exchange_state->exchange_hash,
|
||||
libssh2_sha1_update(exchange_hash_ctx,
|
||||
exchange_state->k_value,
|
||||
exchange_state->k_value_len);
|
||||
|
||||
libssh2_sha1_final(exchange_state->exchange_hash,
|
||||
libssh2_sha1_final(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp);
|
||||
|
||||
if (session->hostkey->
|
||||
@@ -683,6 +719,628 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* diffie_hellman_sha256
|
||||
*
|
||||
* Diffie Hellman Key Exchange, Group Agnostic
|
||||
*/
|
||||
static int diffie_hellman_sha256(LIBSSH2_SESSION *session,
|
||||
_libssh2_bn *g,
|
||||
_libssh2_bn *p,
|
||||
int group_order,
|
||||
unsigned char packet_type_init,
|
||||
unsigned char packet_type_reply,
|
||||
unsigned char *midhash,
|
||||
unsigned long midhash_len,
|
||||
kmdhgGPshakex_state_t *exchange_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
libssh2_sha256_ctx exchange_hash_ctx;
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_idle) {
|
||||
/* Setup initial values */
|
||||
exchange_state->e_packet = NULL;
|
||||
exchange_state->s_packet = NULL;
|
||||
exchange_state->k_value = NULL;
|
||||
exchange_state->ctx = _libssh2_bn_ctx_new();
|
||||
exchange_state->x = _libssh2_bn_init(); /* Random from client */
|
||||
exchange_state->e = _libssh2_bn_init(); /* g^x mod p */
|
||||
exchange_state->f = _libssh2_bn_init_from_bin(); /* g^(Random from server) mod p */
|
||||
exchange_state->k = _libssh2_bn_init(); /* The shared secret: f^x mod p */
|
||||
|
||||
/* Zero the whole thing out */
|
||||
memset(&exchange_state->req_state, 0, sizeof(packet_require_state_t));
|
||||
|
||||
/* Generate x and e */
|
||||
_libssh2_bn_rand(exchange_state->x, group_order * 8 - 1, 0, -1);
|
||||
_libssh2_bn_mod_exp(exchange_state->e, g, exchange_state->x, p,
|
||||
exchange_state->ctx);
|
||||
|
||||
/* Send KEX init */
|
||||
/* packet_type(1) + String Length(4) + leading 0(1) */
|
||||
exchange_state->e_packet_len =
|
||||
_libssh2_bn_bytes(exchange_state->e) + 6;
|
||||
if (_libssh2_bn_bits(exchange_state->e) % 8) {
|
||||
/* Leading 00 not needed */
|
||||
exchange_state->e_packet_len--;
|
||||
}
|
||||
|
||||
exchange_state->e_packet =
|
||||
LIBSSH2_ALLOC(session, exchange_state->e_packet_len);
|
||||
if (!exchange_state->e_packet) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Out of memory error");
|
||||
goto clean_exit;
|
||||
}
|
||||
exchange_state->e_packet[0] = packet_type_init;
|
||||
_libssh2_htonu32(exchange_state->e_packet + 1,
|
||||
exchange_state->e_packet_len - 5);
|
||||
if (_libssh2_bn_bits(exchange_state->e) % 8) {
|
||||
_libssh2_bn_to_bin(exchange_state->e,
|
||||
exchange_state->e_packet + 5);
|
||||
} else {
|
||||
exchange_state->e_packet[5] = 0;
|
||||
_libssh2_bn_to_bin(exchange_state->e,
|
||||
exchange_state->e_packet + 6);
|
||||
}
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sending KEX packet %d",
|
||||
(int) packet_type_init);
|
||||
exchange_state->state = libssh2_NB_state_created;
|
||||
}
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_created) {
|
||||
rc = _libssh2_transport_send(session, exchange_state->e_packet,
|
||||
exchange_state->e_packet_len,
|
||||
NULL, 0);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
ret = _libssh2_error(session, rc,
|
||||
"Unable to send KEX init message");
|
||||
goto clean_exit;
|
||||
}
|
||||
exchange_state->state = libssh2_NB_state_sent;
|
||||
}
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_sent) {
|
||||
if (session->burn_optimistic_kexinit) {
|
||||
/* The first KEX packet to come along will be the guess initially
|
||||
* sent by the server. That guess turned out to be wrong so we
|
||||
* need to silently ignore it */
|
||||
int burn_type;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Waiting for badly guessed KEX packet (to be ignored)");
|
||||
burn_type =
|
||||
_libssh2_packet_burn(session, &exchange_state->burn_state);
|
||||
if (burn_type == LIBSSH2_ERROR_EAGAIN) {
|
||||
return burn_type;
|
||||
} else if (burn_type <= 0) {
|
||||
/* Failed to receive a packet */
|
||||
ret = burn_type;
|
||||
goto clean_exit;
|
||||
}
|
||||
session->burn_optimistic_kexinit = 0;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Burnt packet of type: %02x",
|
||||
(unsigned int) burn_type);
|
||||
}
|
||||
|
||||
exchange_state->state = libssh2_NB_state_sent1;
|
||||
}
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_sent1) {
|
||||
/* Wait for KEX reply */
|
||||
rc = _libssh2_packet_require(session, packet_type_reply,
|
||||
&exchange_state->s_packet,
|
||||
&exchange_state->s_packet_len, 0, NULL,
|
||||
0, &exchange_state->req_state);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
}
|
||||
if (rc) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT,
|
||||
"Timed out waiting for KEX reply");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
/* Parse KEXDH_REPLY */
|
||||
exchange_state->s = exchange_state->s_packet + 1;
|
||||
|
||||
session->server_hostkey_len = _libssh2_ntohu32(exchange_state->s);
|
||||
exchange_state->s += 4;
|
||||
|
||||
if (session->server_hostkey)
|
||||
LIBSSH2_FREE(session, session->server_hostkey);
|
||||
|
||||
session->server_hostkey =
|
||||
LIBSSH2_ALLOC(session, session->server_hostkey_len);
|
||||
if (!session->server_hostkey) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for a copy "
|
||||
"of the host key");
|
||||
goto clean_exit;
|
||||
}
|
||||
memcpy(session->server_hostkey, exchange_state->s,
|
||||
session->server_hostkey_len);
|
||||
exchange_state->s += session->server_hostkey_len;
|
||||
|
||||
#if LIBSSH2_MD5
|
||||
{
|
||||
libssh2_md5_ctx fingerprint_ctx;
|
||||
|
||||
if (libssh2_md5_init(&fingerprint_ctx)) {
|
||||
libssh2_md5_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_md5_final(fingerprint_ctx,
|
||||
session->server_hostkey_md5);
|
||||
session->server_hostkey_md5_valid = TRUE;
|
||||
}
|
||||
else {
|
||||
session->server_hostkey_md5_valid = FALSE;
|
||||
}
|
||||
}
|
||||
#ifdef LIBSSH2DEBUG
|
||||
{
|
||||
char fingerprint[50], *fprint = fingerprint;
|
||||
int i;
|
||||
for(i = 0; i < 16; i++, fprint += 3) {
|
||||
snprintf(fprint, 4, "%02x:", session->server_hostkey_md5[i]);
|
||||
}
|
||||
*(--fprint) = '\0';
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server's MD5 Fingerprint: %s", fingerprint);
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
|
||||
{
|
||||
libssh2_sha1_ctx fingerprint_ctx;
|
||||
|
||||
if (libssh2_sha1_init(&fingerprint_ctx)) {
|
||||
libssh2_sha1_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_sha1_final(fingerprint_ctx,
|
||||
session->server_hostkey_sha1);
|
||||
session->server_hostkey_sha1_valid = TRUE;
|
||||
}
|
||||
else {
|
||||
session->server_hostkey_sha1_valid = FALSE;
|
||||
}
|
||||
}
|
||||
#ifdef LIBSSH2DEBUG
|
||||
{
|
||||
char fingerprint[64], *fprint = fingerprint;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 20; i++, fprint += 3) {
|
||||
snprintf(fprint, 4, "%02x:", session->server_hostkey_sha1[i]);
|
||||
}
|
||||
*(--fprint) = '\0';
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server's SHA1 Fingerprint: %s", fingerprint);
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
|
||||
if (session->hostkey->init(session, session->server_hostkey,
|
||||
session->server_hostkey_len,
|
||||
&session->server_hostkey_abstract)) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
||||
"Unable to initialize hostkey importer");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
exchange_state->f_value_len = _libssh2_ntohu32(exchange_state->s);
|
||||
exchange_state->s += 4;
|
||||
exchange_state->f_value = exchange_state->s;
|
||||
exchange_state->s += exchange_state->f_value_len;
|
||||
_libssh2_bn_from_bin(exchange_state->f, exchange_state->f_value_len,
|
||||
exchange_state->f_value);
|
||||
|
||||
exchange_state->h_sig_len = _libssh2_ntohu32(exchange_state->s);
|
||||
exchange_state->s += 4;
|
||||
exchange_state->h_sig = exchange_state->s;
|
||||
|
||||
/* Compute the shared secret */
|
||||
_libssh2_bn_mod_exp(exchange_state->k, exchange_state->f,
|
||||
exchange_state->x, p, exchange_state->ctx);
|
||||
exchange_state->k_value_len = _libssh2_bn_bytes(exchange_state->k) + 5;
|
||||
if (_libssh2_bn_bits(exchange_state->k) % 8) {
|
||||
/* don't need leading 00 */
|
||||
exchange_state->k_value_len--;
|
||||
}
|
||||
exchange_state->k_value =
|
||||
LIBSSH2_ALLOC(session, exchange_state->k_value_len);
|
||||
if (!exchange_state->k_value) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate buffer for K");
|
||||
goto clean_exit;
|
||||
}
|
||||
_libssh2_htonu32(exchange_state->k_value,
|
||||
exchange_state->k_value_len - 4);
|
||||
if (_libssh2_bn_bits(exchange_state->k) % 8) {
|
||||
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 4);
|
||||
} else {
|
||||
exchange_state->k_value[4] = 0;
|
||||
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 5);
|
||||
}
|
||||
|
||||
exchange_state->exchange_hash = (void*)&exchange_hash_ctx;
|
||||
libssh2_sha256_init(&exchange_hash_ctx);
|
||||
|
||||
if (session->local.banner) {
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
strlen((char *) session->local.banner) - 2);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
(char *) session->local.banner,
|
||||
strlen((char *) session->local.banner) - 2);
|
||||
} else {
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
LIBSSH2_SSH_DEFAULT_BANNER,
|
||||
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
||||
}
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
strlen((char *) session->remote.banner));
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
session->remote.banner,
|
||||
strlen((char *) session->remote.banner));
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->local.kexinit_len);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
session->local.kexinit,
|
||||
session->local.kexinit_len);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->remote.kexinit_len);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
session->remote.kexinit,
|
||||
session->remote.kexinit_len);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
session->server_hostkey_len);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
|
||||
if (packet_type_init == SSH_MSG_KEX_DH_GEX_INIT) {
|
||||
/* diffie-hellman-group-exchange hashes additional fields */
|
||||
#ifdef LIBSSH2_DH_GEX_NEW
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
LIBSSH2_DH_GEX_MINGROUP);
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp + 4,
|
||||
LIBSSH2_DH_GEX_OPTGROUP);
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp + 8,
|
||||
LIBSSH2_DH_GEX_MAXGROUP);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 12);
|
||||
#else
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
LIBSSH2_DH_GEX_OPTGROUP);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (midhash) {
|
||||
libssh2_sha256_update(exchange_hash_ctx, midhash,
|
||||
midhash_len);
|
||||
}
|
||||
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->e_packet + 1,
|
||||
exchange_state->e_packet_len - 1);
|
||||
|
||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||
exchange_state->f_value_len);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp, 4);
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->f_value,
|
||||
exchange_state->f_value_len);
|
||||
|
||||
libssh2_sha256_update(exchange_hash_ctx,
|
||||
exchange_state->k_value,
|
||||
exchange_state->k_value_len);
|
||||
|
||||
libssh2_sha256_final(exchange_hash_ctx,
|
||||
exchange_state->h_sig_comp);
|
||||
|
||||
if (session->hostkey->
|
||||
sig_verify(session, exchange_state->h_sig,
|
||||
exchange_state->h_sig_len, exchange_state->h_sig_comp,
|
||||
SHA256_DIGEST_LENGTH, &session->server_hostkey_abstract)) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_SIGN,
|
||||
"Unable to verify hostkey signature");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sending NEWKEYS message");
|
||||
exchange_state->c = SSH_MSG_NEWKEYS;
|
||||
|
||||
exchange_state->state = libssh2_NB_state_sent2;
|
||||
}
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_sent2) {
|
||||
rc = _libssh2_transport_send(session, &exchange_state->c, 1, NULL, 0);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
ret = _libssh2_error(session, rc, "Unable to send NEWKEYS message");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
exchange_state->state = libssh2_NB_state_sent3;
|
||||
}
|
||||
|
||||
if (exchange_state->state == libssh2_NB_state_sent3) {
|
||||
rc = _libssh2_packet_require(session, SSH_MSG_NEWKEYS,
|
||||
&exchange_state->tmp,
|
||||
&exchange_state->tmp_len, 0, NULL, 0,
|
||||
&exchange_state->req_state);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
ret = _libssh2_error(session, rc, "Timed out waiting for NEWKEYS");
|
||||
goto clean_exit;
|
||||
}
|
||||
/* The first key exchange has been performed,
|
||||
switch to active crypt/comp/mac mode */
|
||||
session->state |= LIBSSH2_STATE_NEWKEYS;
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Received NEWKEYS message");
|
||||
|
||||
/* This will actually end up being just packet_type(1)
|
||||
for this packet type anyway */
|
||||
LIBSSH2_FREE(session, exchange_state->tmp);
|
||||
|
||||
if (!session->session_id) {
|
||||
session->session_id = LIBSSH2_ALLOC(session, SHA256_DIGEST_LENGTH);
|
||||
if (!session->session_id) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate buffer for SHA digest");
|
||||
goto clean_exit;
|
||||
}
|
||||
memcpy(session->session_id, exchange_state->h_sig_comp,
|
||||
SHA256_DIGEST_LENGTH);
|
||||
session->session_id_len = SHA256_DIGEST_LENGTH;
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "session_id calculated");
|
||||
}
|
||||
|
||||
/* Cleanup any existing cipher */
|
||||
if (session->local.crypt->dtor) {
|
||||
session->local.crypt->dtor(session,
|
||||
&session->local.crypt_abstract);
|
||||
}
|
||||
|
||||
/* Calculate IV/Secret/Key for each direction */
|
||||
if (session->local.crypt->init) {
|
||||
unsigned char *iv = NULL, *secret = NULL;
|
||||
int free_iv = 0, free_secret = 0;
|
||||
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(iv,
|
||||
session->local.crypt->
|
||||
iv_len, "A");
|
||||
if (!iv) {
|
||||
ret = -1;
|
||||
goto clean_exit;
|
||||
}
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(secret,
|
||||
session->local.crypt->
|
||||
secret_len, "C");
|
||||
if (!secret) {
|
||||
LIBSSH2_FREE(session, iv);
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
if (session->local.crypt->
|
||||
init(session, session->local.crypt, iv, &free_iv, secret,
|
||||
&free_secret, 1, &session->local.crypt_abstract)) {
|
||||
LIBSSH2_FREE(session, iv);
|
||||
LIBSSH2_FREE(session, secret);
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (free_iv) {
|
||||
memset(iv, 0, session->local.crypt->iv_len);
|
||||
LIBSSH2_FREE(session, iv);
|
||||
}
|
||||
|
||||
if (free_secret) {
|
||||
memset(secret, 0, session->local.crypt->secret_len);
|
||||
LIBSSH2_FREE(session, secret);
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Client to Server IV and Key calculated");
|
||||
|
||||
if (session->remote.crypt->dtor) {
|
||||
/* Cleanup any existing cipher */
|
||||
session->remote.crypt->dtor(session,
|
||||
&session->remote.crypt_abstract);
|
||||
}
|
||||
|
||||
if (session->remote.crypt->init) {
|
||||
unsigned char *iv = NULL, *secret = NULL;
|
||||
int free_iv = 0, free_secret = 0;
|
||||
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(iv,
|
||||
session->remote.crypt->
|
||||
iv_len, "B");
|
||||
if (!iv) {
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(secret,
|
||||
session->remote.crypt->
|
||||
secret_len, "D");
|
||||
if (!secret) {
|
||||
LIBSSH2_FREE(session, iv);
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
if (session->remote.crypt->
|
||||
init(session, session->remote.crypt, iv, &free_iv, secret,
|
||||
&free_secret, 0, &session->remote.crypt_abstract)) {
|
||||
LIBSSH2_FREE(session, iv);
|
||||
LIBSSH2_FREE(session, secret);
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (free_iv) {
|
||||
memset(iv, 0, session->remote.crypt->iv_len);
|
||||
LIBSSH2_FREE(session, iv);
|
||||
}
|
||||
|
||||
if (free_secret) {
|
||||
memset(secret, 0, session->remote.crypt->secret_len);
|
||||
LIBSSH2_FREE(session, secret);
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client IV and Key calculated");
|
||||
|
||||
if (session->local.mac->dtor) {
|
||||
session->local.mac->dtor(session, &session->local.mac_abstract);
|
||||
}
|
||||
|
||||
if (session->local.mac->init) {
|
||||
unsigned char *key = NULL;
|
||||
int free_key = 0;
|
||||
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(key,
|
||||
session->local.mac->
|
||||
key_len, "E");
|
||||
if (!key) {
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
session->local.mac->init(session, key, &free_key,
|
||||
&session->local.mac_abstract);
|
||||
|
||||
if (free_key) {
|
||||
memset(key, 0, session->local.mac->key_len);
|
||||
LIBSSH2_FREE(session, key);
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Client to Server HMAC Key calculated");
|
||||
|
||||
if (session->remote.mac->dtor) {
|
||||
session->remote.mac->dtor(session, &session->remote.mac_abstract);
|
||||
}
|
||||
|
||||
if (session->remote.mac->init) {
|
||||
unsigned char *key = NULL;
|
||||
int free_key = 0;
|
||||
|
||||
LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA256_HASH(key,
|
||||
session->remote.mac->
|
||||
key_len, "F");
|
||||
if (!key) {
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
session->remote.mac->init(session, key, &free_key,
|
||||
&session->remote.mac_abstract);
|
||||
|
||||
if (free_key) {
|
||||
memset(key, 0, session->remote.mac->key_len);
|
||||
LIBSSH2_FREE(session, key);
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client HMAC Key calculated");
|
||||
|
||||
/* Initialize compression for each direction */
|
||||
|
||||
/* Cleanup any existing compression */
|
||||
if (session->local.comp && session->local.comp->dtor) {
|
||||
session->local.comp->dtor(session, 1,
|
||||
&session->local.comp_abstract);
|
||||
}
|
||||
|
||||
if (session->local.comp && session->local.comp->init) {
|
||||
if (session->local.comp->init(session, 1,
|
||||
&session->local.comp_abstract)) {
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Client to Server compression initialized");
|
||||
|
||||
if (session->remote.comp && session->remote.comp->dtor) {
|
||||
session->remote.comp->dtor(session, 0,
|
||||
&session->remote.comp_abstract);
|
||||
}
|
||||
|
||||
if (session->remote.comp && session->remote.comp->init) {
|
||||
if (session->remote.comp->init(session, 0,
|
||||
&session->remote.comp_abstract)) {
|
||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||
goto clean_exit;
|
||||
}
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client compression initialized");
|
||||
|
||||
}
|
||||
|
||||
clean_exit:
|
||||
_libssh2_bn_free(exchange_state->x);
|
||||
exchange_state->x = NULL;
|
||||
_libssh2_bn_free(exchange_state->e);
|
||||
exchange_state->e = NULL;
|
||||
_libssh2_bn_free(exchange_state->f);
|
||||
exchange_state->f = NULL;
|
||||
_libssh2_bn_free(exchange_state->k);
|
||||
exchange_state->k = NULL;
|
||||
_libssh2_bn_ctx_free(exchange_state->ctx);
|
||||
exchange_state->ctx = NULL;
|
||||
|
||||
if (exchange_state->e_packet) {
|
||||
LIBSSH2_FREE(session, exchange_state->e_packet);
|
||||
exchange_state->e_packet = NULL;
|
||||
}
|
||||
|
||||
if (exchange_state->s_packet) {
|
||||
LIBSSH2_FREE(session, exchange_state->s_packet);
|
||||
exchange_state->s_packet = NULL;
|
||||
}
|
||||
|
||||
if (exchange_state->k_value) {
|
||||
LIBSSH2_FREE(session, exchange_state->k_value);
|
||||
exchange_state->k_value = NULL;
|
||||
}
|
||||
|
||||
exchange_state->state = libssh2_NB_state_idle;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group1_sha1_key_exchange
|
||||
* Diffie-Hellman Group1 (Actually Group2) Key Exchange using SHA1
|
||||
@@ -921,6 +1579,105 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
* Diffie-Hellman Group Exchange Key Exchange using SHA256
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
*/
|
||||
static int
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
{
|
||||
unsigned long p_len, g_len;
|
||||
int ret = 0;
|
||||
int rc;
|
||||
|
||||
if (key_state->state == libssh2_NB_state_idle) {
|
||||
key_state->p = _libssh2_bn_init();
|
||||
key_state->g = _libssh2_bn_init();
|
||||
/* Ask for a P and G pair */
|
||||
#ifdef LIBSSH2_DH_GEX_NEW
|
||||
key_state->request[0] = SSH_MSG_KEX_DH_GEX_REQUEST;
|
||||
_libssh2_htonu32(key_state->request + 1, LIBSSH2_DH_GEX_MINGROUP);
|
||||
_libssh2_htonu32(key_state->request + 5, LIBSSH2_DH_GEX_OPTGROUP);
|
||||
_libssh2_htonu32(key_state->request + 9, LIBSSH2_DH_GEX_MAXGROUP);
|
||||
key_state->request_len = 13;
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Initiating Diffie-Hellman Group-Exchange (New Method SHA256)");
|
||||
#else
|
||||
key_state->request[0] = SSH_MSG_KEX_DH_GEX_REQUEST_OLD;
|
||||
_libssh2_htonu32(key_state->request + 1, LIBSSH2_DH_GEX_OPTGROUP);
|
||||
key_state->request_len = 5;
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Initiating Diffie-Hellman Group-Exchange (Old Method SHA256)");
|
||||
#endif
|
||||
|
||||
key_state->state = libssh2_NB_state_created;
|
||||
}
|
||||
|
||||
if (key_state->state == libssh2_NB_state_created) {
|
||||
rc = _libssh2_transport_send(session, key_state->request,
|
||||
key_state->request_len, NULL, 0);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
ret = _libssh2_error(session, rc,
|
||||
"Unable to send Group Exchange Request SHA256");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
key_state->state = libssh2_NB_state_sent;
|
||||
}
|
||||
|
||||
if (key_state->state == libssh2_NB_state_sent) {
|
||||
rc = _libssh2_packet_require(session, SSH_MSG_KEX_DH_GEX_GROUP,
|
||||
&key_state->data, &key_state->data_len,
|
||||
0, NULL, 0, &key_state->req_state);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
} else if (rc) {
|
||||
ret = _libssh2_error(session, rc,
|
||||
"Timeout waiting for GEX_GROUP reply SHA256");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
key_state->state = libssh2_NB_state_sent1;
|
||||
}
|
||||
|
||||
if (key_state->state == libssh2_NB_state_sent1) {
|
||||
unsigned char *s = key_state->data + 1;
|
||||
p_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
_libssh2_bn_from_bin(key_state->p, p_len, s);
|
||||
s += p_len;
|
||||
|
||||
g_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
_libssh2_bn_from_bin(key_state->g, g_len, s);
|
||||
|
||||
ret = diffie_hellman_sha256(session, key_state->g, key_state->p, p_len,
|
||||
SSH_MSG_KEX_DH_GEX_INIT,
|
||||
SSH_MSG_KEX_DH_GEX_REPLY,
|
||||
key_state->data + 1,
|
||||
key_state->data_len - 1,
|
||||
&key_state->exchange_state);
|
||||
if (ret == LIBSSH2_ERROR_EAGAIN) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
LIBSSH2_FREE(session, key_state->data);
|
||||
}
|
||||
|
||||
dh_gex_clean_exit:
|
||||
key_state->state = libssh2_NB_state_idle;
|
||||
_libssh2_bn_free(key_state->g);
|
||||
key_state->g = NULL;
|
||||
_libssh2_bn_free(key_state->p);
|
||||
key_state->p = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#define LIBSSH2_KEX_METHOD_FLAG_REQ_ENC_HOSTKEY 0x0001
|
||||
#define LIBSSH2_KEX_METHOD_FLAG_REQ_SIGN_HOSTKEY 0x0002
|
||||
|
||||
@@ -943,9 +1700,17 @@ kex_method_diffie_helman_group_exchange_sha1 = {
|
||||
LIBSSH2_KEX_METHOD_FLAG_REQ_SIGN_HOSTKEY,
|
||||
};
|
||||
|
||||
static const LIBSSH2_KEX_METHOD
|
||||
kex_method_diffie_helman_group_exchange_sha256 = {
|
||||
"diffie-hellman-group-exchange-sha256",
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange,
|
||||
LIBSSH2_KEX_METHOD_FLAG_REQ_SIGN_HOSTKEY,
|
||||
};
|
||||
|
||||
static const LIBSSH2_KEX_METHOD *libssh2_kex_methods[] = {
|
||||
&kex_method_diffie_helman_group14_sha1,
|
||||
&kex_method_diffie_helman_group_exchange_sha256,
|
||||
&kex_method_diffie_helman_group_exchange_sha1,
|
||||
&kex_method_diffie_helman_group14_sha1,
|
||||
&kex_method_diffie_helman_group1_sha1,
|
||||
NULL
|
||||
};
|
||||
@@ -1600,21 +2365,21 @@ static int kex_agree_methods(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
|
||||
/* Locate each string */
|
||||
if(kex_string_pair(&s, data, data_len, &kex_len, &kex))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &hostkey_len, &hostkey))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &crypt_cs_len, &crypt_cs))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &crypt_sc_len, &crypt_sc))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &mac_cs_len, &mac_cs))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &mac_sc_len, &mac_sc))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &comp_cs_len, &comp_cs))
|
||||
return -1;
|
||||
return -1;
|
||||
if(kex_string_pair(&s, data, data_len, &comp_sc_len, &comp_sc))
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
/* If the server sent an optimistic packet, assume that it guessed wrong.
|
||||
* If the guess is determined to be right (by kex_agree_kex_hostkey)
|
||||
@@ -1682,7 +2447,7 @@ static int kex_agree_methods(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
*/
|
||||
int
|
||||
_libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
|
||||
key_exchange_state_t * key_state)
|
||||
key_exchange_state_t * key_state)
|
||||
{
|
||||
int rc = 0;
|
||||
int retcode;
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#define LIBSSH2_MD5 1
|
||||
|
||||
#define LIBSSH2_HMAC_RIPEMD 1
|
||||
#define LIBSSH2_HMAC_SHA256 1
|
||||
#define LIBSSH2_HMAC_SHA512 1
|
||||
|
||||
#define LIBSSH2_AES 1
|
||||
#define LIBSSH2_AES_CTR 1
|
||||
@@ -55,10 +57,13 @@
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define SHA_DIGEST_LENGTH 20
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
|
||||
#define _libssh2_random(buf, len) \
|
||||
(gcry_randomize ((buf), (len), GCRY_STRONG_RANDOM), 1)
|
||||
|
||||
#define libssh2_prepare_iovec(vec, len) /* Empty. */
|
||||
|
||||
#define libssh2_sha1_ctx gcry_md_hd_t
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
@@ -71,6 +76,17 @@
|
||||
#define libssh2_sha1(message, len, out) \
|
||||
gcry_md_hash_buffer (GCRY_MD_SHA1, out, message, len)
|
||||
|
||||
#define libssh2_sha256_ctx gcry_md_hd_t
|
||||
|
||||
#define libssh2_sha256_init(ctx) \
|
||||
(GPG_ERR_NO_ERROR == gcry_md_open (ctx, GCRY_MD_SHA256, 0))
|
||||
#define libssh2_sha256_update(ctx, data, len) \
|
||||
gcry_md_write (ctx, (unsigned char *) data, len)
|
||||
#define libssh2_sha256_final(ctx, out) \
|
||||
memcpy (out, gcry_md_read (ctx, 0), SHA256_DIGEST_LENGTH), gcry_md_close (ctx)
|
||||
#define libssh2_sha256(message, len, out) \
|
||||
gcry_md_hash_buffer (GCRY_MD_SHA256, out, message, len)
|
||||
|
||||
#define libssh2_md5_ctx gcry_md_hd_t
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
@@ -95,6 +111,12 @@
|
||||
#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \
|
||||
gcry_md_open (ctx, GCRY_MD_RMD160, GCRY_MD_FLAG_HMAC), \
|
||||
gcry_md_setkey (*ctx, key, keylen)
|
||||
#define libssh2_hmac_sha256_init(ctx, key, keylen) \
|
||||
gcry_md_open (ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC), \
|
||||
gcry_md_setkey (*ctx, key, keylen)
|
||||
#define libssh2_hmac_sha512_init(ctx, key, keylen) \
|
||||
gcry_md_open (ctx, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC), \
|
||||
gcry_md_setkey (*ctx, key, keylen)
|
||||
#define libssh2_hmac_update(ctx, data, datalen) \
|
||||
gcry_md_write (ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_hmac_final(ctx, data) \
|
||||
|
||||
17
src/libssh2.pc.in
Normal file
17
src/libssh2.pc.in
Normal file
@@ -0,0 +1,17 @@
|
||||
###########################################################################
|
||||
# libssh2 installation details
|
||||
###########################################################################
|
||||
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
URL: @PROJECT_URL@
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
Version: @LIBSSH2_VERSION@
|
||||
Requires.private: @PC_REQUIRES_PRIVATE@
|
||||
Libs: -L${libdir} -lssh2 @PC_LIBS@
|
||||
Libs.private: @PC_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
105
src/libssh2_config_cmake.h.in
Normal file
105
src/libssh2_config_cmake.h.in
Normal file
@@ -0,0 +1,105 @@
|
||||
/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
* Copyright (c) 1999-2011 Douglas Gilbert. 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.
|
||||
*/
|
||||
|
||||
/* Headers */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
#cmakedefine HAVE_STDLIB_H
|
||||
#cmakedefine HAVE_SYS_SELECT_H
|
||||
#cmakedefine HAVE_SYS_UIO_H
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
#cmakedefine HAVE_SYS_IOCTL_H
|
||||
#cmakedefine HAVE_SYS_TIME_H
|
||||
#cmakedefine HAVE_SYS_UN_H
|
||||
#cmakedefine HAVE_WINDOWS_H
|
||||
#cmakedefine HAVE_WS2TCPIP_H
|
||||
#cmakedefine HAVE_WINSOCK2_H
|
||||
#cmakedefine HAVE_NTDEF_H
|
||||
#cmakedefine HAVE_NTSTATUS_H
|
||||
|
||||
/* Libraries */
|
||||
#cmakedefine HAVE_LIBCRYPT32
|
||||
|
||||
/* Types */
|
||||
#cmakedefine HAVE_LONGLONG
|
||||
|
||||
/* Functions */
|
||||
#cmakedefine HAVE_GETTIMEOFDAY
|
||||
#cmakedefine HAVE_INET_ADDR
|
||||
#cmakedefine HAVE_POLL
|
||||
#cmakedefine HAVE_SELECT
|
||||
#cmakedefine HAVE_SOCKET
|
||||
#cmakedefine HAVE_STRTOLL
|
||||
#cmakedefine HAVE_STRTOI64
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
|
||||
/* OpenSSL functions */
|
||||
#cmakedefine HAVE_EVP_AES_128_CTR
|
||||
|
||||
/* Socket non-blocking support */
|
||||
#cmakedefine HAVE_O_NONBLOCK
|
||||
#cmakedefine HAVE_FIONBIO
|
||||
#cmakedefine HAVE_IOCTLSOCKET
|
||||
#cmakedefine HAVE_IOCTLSOCKET_CASE
|
||||
#cmakedefine HAVE_SO_NONBLOCK
|
||||
#cmakedefine HAVE_DISABLED_NONBLOCKING
|
||||
|
||||
/* snprintf not in Visual Studio CRT and _snprintf dangerously incompatible.
|
||||
We provide a safe wrapper if snprintf not found */
|
||||
#ifndef HAVE_SNPRINTF
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
/* Want safe, 'n += snprintf(b + n ...)' like function. If cp_max_len is 1
|
||||
* then assume cp is pointing to a null char and do nothing. Returns number
|
||||
* number of chars placed in cp excluding the trailing null char. So for
|
||||
* cp_max_len > 0 the return value is always < cp_max_len; for cp_max_len
|
||||
* <= 0 the return value is 0 (and no chars are written to cp). */
|
||||
static int snprintf(char * cp, int cp_max_len, const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int n;
|
||||
|
||||
if (cp_max_len < 2)
|
||||
return 0;
|
||||
va_start(args, fmt);
|
||||
n = vsnprintf(cp, cp_max_len, fmt, args);
|
||||
va_end(args);
|
||||
return (n < cp_max_len) ? n : (cp_max_len - 1);
|
||||
}
|
||||
|
||||
#define HAVE_SNPRINTF
|
||||
#endif
|
||||
@@ -132,6 +132,11 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __OS400__
|
||||
/* Force parameter type. */
|
||||
#define send(s, b, l, f) send((s), (unsigned char *) (b), (l), (f))
|
||||
#endif
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
@@ -149,6 +154,7 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
|
||||
* padding length, payload, padding, and MAC.)."
|
||||
*/
|
||||
#define MAX_SSH_PACKET_LEN 35000
|
||||
#define MAX_SHA_DIGEST_LEN SHA256_DIGEST_LENGTH
|
||||
|
||||
#define LIBSSH2_ALLOC(session, count) \
|
||||
session->alloc((count), &(session)->abstract)
|
||||
@@ -182,9 +188,9 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
|
||||
(channel), &(channel)->abstract)
|
||||
|
||||
#define LIBSSH2_SEND_FD(session, fd, buffer, length, flags) \
|
||||
session->send(fd, buffer, length, flags, &session->abstract)
|
||||
(session->send)(fd, buffer, length, flags, &session->abstract)
|
||||
#define LIBSSH2_RECV_FD(session, fd, buffer, length, flags) \
|
||||
session->recv(fd, buffer, length, flags, &session->abstract)
|
||||
(session->recv)(fd, buffer, length, flags, &session->abstract)
|
||||
|
||||
#define LIBSSH2_SEND(session, buffer, length, flags) \
|
||||
LIBSSH2_SEND_FD(session, session->socket_fd, buffer, length, flags)
|
||||
@@ -215,7 +221,8 @@ typedef enum
|
||||
libssh2_NB_state_jump2,
|
||||
libssh2_NB_state_jump3,
|
||||
libssh2_NB_state_jump4,
|
||||
libssh2_NB_state_jump5
|
||||
libssh2_NB_state_jump5,
|
||||
libssh2_NB_state_end
|
||||
} libssh2_nonblocking_states;
|
||||
|
||||
typedef struct packet_require_state_t
|
||||
@@ -229,13 +236,13 @@ typedef struct packet_requirev_state_t
|
||||
time_t start;
|
||||
} packet_requirev_state_t;
|
||||
|
||||
typedef struct kmdhgGPsha1kex_state_t
|
||||
typedef struct kmdhgGPshakex_state_t
|
||||
{
|
||||
libssh2_nonblocking_states state;
|
||||
unsigned char *e_packet;
|
||||
unsigned char *s_packet;
|
||||
unsigned char *tmp;
|
||||
unsigned char h_sig_comp[SHA_DIGEST_LENGTH];
|
||||
unsigned char h_sig_comp[MAX_SHA_DIGEST_LEN];
|
||||
unsigned char c;
|
||||
size_t e_packet_len;
|
||||
size_t s_packet_len;
|
||||
@@ -252,16 +259,16 @@ typedef struct kmdhgGPsha1kex_state_t
|
||||
size_t f_value_len;
|
||||
size_t k_value_len;
|
||||
size_t h_sig_len;
|
||||
libssh2_sha1_ctx exchange_hash;
|
||||
void *exchange_hash;
|
||||
packet_require_state_t req_state;
|
||||
libssh2_nonblocking_states burn_state;
|
||||
} kmdhgGPsha1kex_state_t;
|
||||
} kmdhgGPshakex_state_t;
|
||||
|
||||
typedef struct key_exchange_state_low_t
|
||||
{
|
||||
libssh2_nonblocking_states state;
|
||||
packet_require_state_t req_state;
|
||||
kmdhgGPsha1kex_state_t exchange_state;
|
||||
kmdhgGPshakex_state_t exchange_state;
|
||||
_libssh2_bn *p; /* SSH2 defined value (p_value) */
|
||||
_libssh2_bn *g; /* SSH2 defined value (2) */
|
||||
unsigned char request[13];
|
||||
@@ -629,6 +636,7 @@ struct _LIBSSH2_SESSION
|
||||
/* Error tracking */
|
||||
const char *err_msg;
|
||||
int err_code;
|
||||
int err_flags;
|
||||
|
||||
/* struct members for packet-level reading */
|
||||
struct transportpacket packet;
|
||||
@@ -779,7 +787,7 @@ struct _LIBSSH2_SESSION
|
||||
int sftpInit_sent; /* number of bytes from the buffer that have been
|
||||
sent */
|
||||
|
||||
/* State variables used in libssh2_scp_recv() */
|
||||
/* State variables used in libssh2_scp_recv() / libssh_scp_recv2() */
|
||||
libssh2_nonblocking_states scpRecv_state;
|
||||
unsigned char *scpRecv_command;
|
||||
size_t scpRecv_command_len;
|
||||
@@ -790,6 +798,9 @@ struct _LIBSSH2_SESSION
|
||||
/* we have the type and we can parse such numbers */
|
||||
long long scpRecv_size;
|
||||
#define scpsize_strtol strtoll
|
||||
#elif defined(HAVE_STRTOI64)
|
||||
__int64 scpRecv_size;
|
||||
#define scpsize_strtol _strtoi64
|
||||
#else
|
||||
long scpRecv_size;
|
||||
#define scpsize_strtol strtol
|
||||
@@ -945,6 +956,10 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
||||
/* Something very bad is going on */
|
||||
#define LIBSSH2_MAC_INVALID -1
|
||||
|
||||
/* Flags for _libssh2_error_flags */
|
||||
/* Error message is allocated on the heap */
|
||||
#define LIBSSH2_ERR_FLAG_DUP 1
|
||||
|
||||
/* SSH Packet Types -- Defined by internet draft */
|
||||
/* Transport Layer */
|
||||
#define SSH_MSG_DISCONNECT 1
|
||||
@@ -961,7 +976,7 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
||||
#define SSH_MSG_KEXDH_INIT 30
|
||||
#define SSH_MSG_KEXDH_REPLY 31
|
||||
|
||||
/* diffie-hellman-group-exchange-sha1 */
|
||||
/* diffie-hellman-group-exchange-sha1 and diffie-hellman-group-exchange-sha256 */
|
||||
#define SSH_MSG_KEX_DH_GEX_REQUEST_OLD 30
|
||||
#define SSH_MSG_KEX_DH_GEX_REQUEST 34
|
||||
#define SSH_MSG_KEX_DH_GEX_GROUP 31
|
||||
|
||||
97
src/mac.c
97
src/mac.c
@@ -96,6 +96,97 @@ mac_method_common_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
|
||||
|
||||
|
||||
#if LIBSSH2_HMAC_SHA512
|
||||
/* mac_method_hmac_sha512_hash
|
||||
* Calculate hash using full sha512 value
|
||||
*/
|
||||
static int
|
||||
mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session,
|
||||
unsigned char *buf, uint32_t seqno,
|
||||
const unsigned char *packet,
|
||||
uint32_t packet_len,
|
||||
const unsigned char *addtl,
|
||||
uint32_t addtl_len, void **abstract)
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
libssh2_hmac_sha512_init(&ctx, *abstract, 64);
|
||||
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 mac_method_hmac_sha2_512 = {
|
||||
"hmac-sha2-512",
|
||||
64,
|
||||
64,
|
||||
mac_method_common_init,
|
||||
mac_method_hmac_sha2_512_hash,
|
||||
mac_method_common_dtor,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if LIBSSH2_HMAC_SHA256
|
||||
/* mac_method_hmac_sha256_hash
|
||||
* Calculate hash using full sha256 value
|
||||
*/
|
||||
static int
|
||||
mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session,
|
||||
unsigned char *buf, uint32_t seqno,
|
||||
const unsigned char *packet,
|
||||
uint32_t packet_len,
|
||||
const unsigned char *addtl,
|
||||
uint32_t addtl_len, void **abstract)
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
libssh2_hmac_sha256_init(&ctx, *abstract, 32);
|
||||
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 mac_method_hmac_sha2_256 = {
|
||||
"hmac-sha2-256",
|
||||
32,
|
||||
32,
|
||||
mac_method_common_init,
|
||||
mac_method_hmac_sha2_256_hash,
|
||||
mac_method_common_dtor,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* mac_method_hmac_sha1_hash
|
||||
* Calculate hash using full sha1 value
|
||||
*/
|
||||
@@ -294,6 +385,12 @@ static const LIBSSH2_MAC_METHOD mac_method_hmac_ripemd160_openssh_com = {
|
||||
#endif /* LIBSSH2_HMAC_RIPEMD */
|
||||
|
||||
static const LIBSSH2_MAC_METHOD *mac_methods[] = {
|
||||
#if LIBSSH2_HMAC_SHA256
|
||||
&mac_method_hmac_sha2_256,
|
||||
#endif
|
||||
#if LIBSSH2_HMAC_SHA512
|
||||
&mac_method_hmac_sha2_512,
|
||||
#endif
|
||||
&mac_method_hmac_sha1,
|
||||
&mac_method_hmac_sha1_96,
|
||||
#if LIBSSH2_MD5
|
||||
|
||||
30
src/misc.c
30
src/misc.c
@@ -51,10 +51,29 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg)
|
||||
int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode, const char* errmsg, int errflags)
|
||||
{
|
||||
session->err_msg = errmsg;
|
||||
if (session->err_flags & LIBSSH2_ERR_FLAG_DUP)
|
||||
LIBSSH2_FREE(session, (char *)session->err_msg);
|
||||
|
||||
session->err_code = errcode;
|
||||
session->err_flags = 0;
|
||||
|
||||
if ((errmsg != NULL) && ((errflags & LIBSSH2_ERR_FLAG_DUP) != 0)) {
|
||||
size_t len = strlen(errmsg);
|
||||
char *copy = LIBSSH2_ALLOC(session, len + 1);
|
||||
if (copy) {
|
||||
memcpy(copy, errmsg, len + 1);
|
||||
session->err_flags = LIBSSH2_ERR_FLAG_DUP;
|
||||
session->err_msg = copy;
|
||||
}
|
||||
else
|
||||
/* Out of memory: this code path is very unlikely */
|
||||
session->err_msg = "former error forgotten (OOM)";
|
||||
}
|
||||
else
|
||||
session->err_msg = errmsg;
|
||||
|
||||
#ifdef LIBSSH2DEBUG
|
||||
if((errcode == LIBSSH2_ERROR_EAGAIN) && !session->api_block_mode)
|
||||
/* if this is EAGAIN and we're in non-blocking mode, don't generate
|
||||
@@ -67,6 +86,11 @@ int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg)
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg)
|
||||
{
|
||||
return _libssh2_error_flags(session, errcode, errmsg, 0);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
static int wsa2errno(void)
|
||||
{
|
||||
@@ -380,6 +404,8 @@ libssh2_free(LIBSSH2_SESSION *session, void *ptr)
|
||||
}
|
||||
|
||||
#ifdef LIBSSH2DEBUG
|
||||
#include <stdarg.h>
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ struct list_node {
|
||||
struct list_head *head;
|
||||
};
|
||||
|
||||
int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode, const char* errmsg, int errflags);
|
||||
int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg);
|
||||
|
||||
void _libssh2_list_init(struct list_head *head);
|
||||
|
||||
197
src/openssl.c
197
src/openssl.c
@@ -105,7 +105,8 @@ _libssh2_rsa_sha1_verify(libssh2_rsa_ctx * rsactx,
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
int ret;
|
||||
|
||||
libssh2_sha1(m, m_len, hash);
|
||||
if (_libssh2_sha1(m, m_len, hash))
|
||||
return -1; /* failure */
|
||||
ret = RSA_verify(NID_sha1, hash, SHA_DIGEST_LENGTH,
|
||||
(unsigned char *) sig, sig_len, rsactx);
|
||||
return (ret == 1) ? 0 : -1;
|
||||
@@ -153,15 +154,17 @@ _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
|
||||
{
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
DSA_SIG dsasig;
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
dsasig.r = BN_new();
|
||||
BN_bin2bn(sig, 20, dsasig.r);
|
||||
dsasig.s = BN_new();
|
||||
BN_bin2bn(sig + 20, 20, dsasig.s);
|
||||
|
||||
libssh2_sha1(m, m_len, hash);
|
||||
ret = DSA_do_verify(hash, SHA_DIGEST_LENGTH, &dsasig, dsactx);
|
||||
if (!_libssh2_sha1(m, m_len, hash))
|
||||
/* _libssh2_sha1() succeeded */
|
||||
ret = DSA_do_verify(hash, SHA_DIGEST_LENGTH, &dsasig, dsactx);
|
||||
|
||||
BN_clear_free(dsasig.s);
|
||||
BN_clear_free(dsasig.r);
|
||||
|
||||
@@ -174,8 +177,13 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
_libssh2_cipher_type(algo),
|
||||
unsigned char *iv, unsigned char *secret, int encrypt)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
*h = EVP_CIPHER_CTX_new();
|
||||
return !EVP_CipherInit(*h, algo(), secret, iv, encrypt);
|
||||
#else
|
||||
EVP_CIPHER_CTX_init(h);
|
||||
return !EVP_CipherInit(h, algo(), secret, iv, encrypt);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
@@ -188,7 +196,11 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
(void) algo;
|
||||
(void) encrypt;
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
ret = EVP_Cipher(*ctx, buf, block, blocksize);
|
||||
#else
|
||||
ret = EVP_Cipher(ctx, buf, block, blocksize);
|
||||
#endif
|
||||
if (ret == 1) {
|
||||
memcpy(block, buf, blocksize);
|
||||
}
|
||||
@@ -219,7 +231,7 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const EVP_CIPHER *aes_cipher;
|
||||
(void) enc;
|
||||
|
||||
switch (ctx->key_len) {
|
||||
switch (EVP_CIPHER_CTX_key_length(ctx)) {
|
||||
case 16:
|
||||
aes_cipher = EVP_aes_128_ecb();
|
||||
break;
|
||||
@@ -237,14 +249,22 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
if (c == NULL)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
c->aes_ctx = EVP_CIPHER_CTX_new();
|
||||
#else
|
||||
c->aes_ctx = malloc(sizeof(EVP_CIPHER_CTX));
|
||||
#endif
|
||||
if (c->aes_ctx == NULL) {
|
||||
free(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (EVP_EncryptInit(c->aes_ctx, aes_cipher, key, NULL) != 1) {
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
EVP_CIPHER_CTX_free(c->aes_ctx);
|
||||
#else
|
||||
free(c->aes_ctx);
|
||||
#endif
|
||||
free(c);
|
||||
return 0;
|
||||
}
|
||||
@@ -309,8 +329,12 @@ aes_ctr_cleanup(EVP_CIPHER_CTX *ctx) /* cleanup ctx */
|
||||
}
|
||||
|
||||
if (c->aes_ctx != NULL) {
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
EVP_CIPHER_CTX_free(c->aes_ctx);
|
||||
#else
|
||||
_libssh2_cipher_dtor(c->aes_ctx);
|
||||
free(c->aes_ctx);
|
||||
#endif
|
||||
}
|
||||
|
||||
free(c);
|
||||
@@ -319,14 +343,25 @@ aes_ctr_cleanup(EVP_CIPHER_CTX *ctx) /* cleanup ctx */
|
||||
}
|
||||
|
||||
static const EVP_CIPHER *
|
||||
make_ctr_evp (size_t keylen, EVP_CIPHER *aes_ctr_cipher)
|
||||
make_ctr_evp (size_t keylen, EVP_CIPHER *aes_ctr_cipher, int type)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
aes_ctr_cipher = EVP_CIPHER_meth_new(type, 16, keylen);
|
||||
if (aes_ctr_cipher) {
|
||||
EVP_CIPHER_meth_set_iv_length(aes_ctr_cipher, 16);
|
||||
EVP_CIPHER_meth_set_init(aes_ctr_cipher, aes_ctr_init);
|
||||
EVP_CIPHER_meth_set_do_cipher(aes_ctr_cipher, aes_ctr_do_cipher);
|
||||
EVP_CIPHER_meth_set_cleanup(aes_ctr_cipher, aes_ctr_cleanup);
|
||||
}
|
||||
#else
|
||||
aes_ctr_cipher->nid = type;
|
||||
aes_ctr_cipher->block_size = 16;
|
||||
aes_ctr_cipher->key_len = keylen;
|
||||
aes_ctr_cipher->iv_len = 16;
|
||||
aes_ctr_cipher->init = aes_ctr_init;
|
||||
aes_ctr_cipher->do_cipher = aes_ctr_do_cipher;
|
||||
aes_ctr_cipher->cleanup = aes_ctr_cleanup;
|
||||
#endif
|
||||
|
||||
return aes_ctr_cipher;
|
||||
}
|
||||
@@ -334,25 +369,43 @@ make_ctr_evp (size_t keylen, EVP_CIPHER *aes_ctr_cipher)
|
||||
const EVP_CIPHER *
|
||||
_libssh2_EVP_aes_128_ctr(void)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
static EVP_CIPHER * aes_ctr_cipher;
|
||||
return !aes_ctr_cipher?
|
||||
make_ctr_evp (16, aes_ctr_cipher, NID_aes_128_ctr) : aes_ctr_cipher;
|
||||
#else
|
||||
static EVP_CIPHER aes_ctr_cipher;
|
||||
return !aes_ctr_cipher.key_len?
|
||||
make_ctr_evp (16, &aes_ctr_cipher) : &aes_ctr_cipher;
|
||||
make_ctr_evp (16, &aes_ctr_cipher, 0) : &aes_ctr_cipher;
|
||||
#endif
|
||||
}
|
||||
|
||||
const EVP_CIPHER *
|
||||
_libssh2_EVP_aes_192_ctr(void)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
static EVP_CIPHER * aes_ctr_cipher;
|
||||
return !aes_ctr_cipher?
|
||||
make_ctr_evp (24, aes_ctr_cipher, NID_aes_192_ctr) : aes_ctr_cipher;
|
||||
#else
|
||||
static EVP_CIPHER aes_ctr_cipher;
|
||||
return !aes_ctr_cipher.key_len?
|
||||
make_ctr_evp (24, &aes_ctr_cipher) : &aes_ctr_cipher;
|
||||
make_ctr_evp (24, &aes_ctr_cipher, 0) : &aes_ctr_cipher;
|
||||
#endif
|
||||
}
|
||||
|
||||
const EVP_CIPHER *
|
||||
_libssh2_EVP_aes_256_ctr(void)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
static EVP_CIPHER * aes_ctr_cipher;
|
||||
return !aes_ctr_cipher?
|
||||
make_ctr_evp (32, aes_ctr_cipher, NID_aes_256_ctr) : aes_ctr_cipher;
|
||||
#else
|
||||
static EVP_CIPHER aes_ctr_cipher;
|
||||
return !aes_ctr_cipher.key_len?
|
||||
make_ctr_evp (32, &aes_ctr_cipher) : &aes_ctr_cipher;
|
||||
make_ctr_evp (32, &aes_ctr_cipher, 0) : &aes_ctr_cipher;
|
||||
#endif
|
||||
}
|
||||
|
||||
void _libssh2_init_aes_ctr(void)
|
||||
@@ -431,7 +484,7 @@ read_private_key_from_file(void ** key_ctx,
|
||||
return (*key_ctx) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
_libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
@@ -564,43 +617,129 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
#endif /* LIBSSH_DSA */
|
||||
|
||||
int
|
||||
libssh2_sha1_init(libssh2_sha1_ctx *ctx)
|
||||
_libssh2_sha1_init(libssh2_sha1_ctx *ctx)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
*ctx = EVP_MD_CTX_new();
|
||||
|
||||
if (*ctx == NULL)
|
||||
return 0;
|
||||
|
||||
if (EVP_DigestInit(*ctx, EVP_get_digestbyname("sha1")))
|
||||
return 1;
|
||||
|
||||
EVP_MD_CTX_free(*ctx);
|
||||
*ctx = NULL;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
EVP_MD_CTX_init(ctx);
|
||||
return EVP_DigestInit(ctx, EVP_get_digestbyname("sha1"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
libssh2_sha1(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out)
|
||||
int
|
||||
_libssh2_sha1(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
EVP_MD_CTX * ctx = EVP_MD_CTX_new();
|
||||
|
||||
if (ctx == NULL)
|
||||
return 1; /* error */
|
||||
|
||||
if (EVP_DigestInit(ctx, EVP_get_digestbyname("sha1"))) {
|
||||
EVP_DigestUpdate(ctx, message, len);
|
||||
EVP_DigestFinal(ctx, out, NULL);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return 0; /* success */
|
||||
}
|
||||
EVP_MD_CTX_free(ctx);
|
||||
#else
|
||||
EVP_MD_CTX ctx;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
if (EVP_DigestInit(&ctx, EVP_get_digestbyname("sha1"))) {
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
return 0; /* success */
|
||||
}
|
||||
#endif
|
||||
return 1; /* error */
|
||||
}
|
||||
|
||||
int
|
||||
libssh2_md5_init(libssh2_md5_ctx *ctx)
|
||||
_libssh2_sha256_init(libssh2_sha256_ctx *ctx)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
*ctx = EVP_MD_CTX_new();
|
||||
|
||||
if (*ctx == NULL)
|
||||
return 0;
|
||||
|
||||
if (EVP_DigestInit(*ctx, EVP_get_digestbyname("sha256")))
|
||||
return 1;
|
||||
|
||||
EVP_MD_CTX_free(*ctx);
|
||||
*ctx = NULL;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
EVP_MD_CTX_init(ctx);
|
||||
return EVP_DigestInit(ctx, EVP_get_digestbyname("md5"));
|
||||
return EVP_DigestInit(ctx, EVP_get_digestbyname("sha256"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
libssh2_md5(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out)
|
||||
int
|
||||
_libssh2_sha256(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
EVP_MD_CTX * ctx = EVP_MD_CTX_new();
|
||||
|
||||
if (ctx == NULL)
|
||||
return 1; /* error */
|
||||
|
||||
if(EVP_DigestInit(ctx, EVP_get_digestbyname("sha256"))) {
|
||||
EVP_DigestUpdate(ctx, message, len);
|
||||
EVP_DigestFinal(ctx, out, NULL);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return 0; /* success */
|
||||
}
|
||||
EVP_MD_CTX_free(ctx);
|
||||
#else
|
||||
EVP_MD_CTX ctx;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
if (EVP_DigestInit(&ctx, EVP_get_digestbyname("md5"))) {
|
||||
if(EVP_DigestInit(&ctx, EVP_get_digestbyname("sha256"))) {
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
return 0; /* success */
|
||||
}
|
||||
#endif
|
||||
return 1; /* error */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_md5_init(libssh2_md5_ctx *ctx)
|
||||
{
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
*ctx = EVP_MD_CTX_new();
|
||||
|
||||
if (*ctx == NULL)
|
||||
return 0;
|
||||
|
||||
if (EVP_DigestInit(*ctx, EVP_get_digestbyname("md5")))
|
||||
return 1;
|
||||
|
||||
EVP_MD_CTX_free(*ctx);
|
||||
*ctx = NULL;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
EVP_MD_CTX_init(ctx);
|
||||
return EVP_DigestInit(ctx, EVP_get_digestbyname("md5"));
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
@@ -819,6 +958,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
int st;
|
||||
BIO* bp;
|
||||
EVP_PKEY* pk;
|
||||
int pktype;
|
||||
|
||||
_libssh2_debug(session,
|
||||
LIBSSH2_TRACE_AUTH,
|
||||
@@ -853,7 +993,13 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
"private key file format");
|
||||
}
|
||||
|
||||
switch (pk->type) {
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
pktype = EVP_PKEY_id(pk);
|
||||
#else
|
||||
pktype = pk->type;
|
||||
#endif
|
||||
|
||||
switch (pktype) {
|
||||
case EVP_PKEY_RSA :
|
||||
st = gen_publickey_from_rsa_evp(
|
||||
session, method, method_len, pubkeydata, pubkeydata_len, pk);
|
||||
@@ -892,6 +1038,7 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
int st;
|
||||
BIO* bp;
|
||||
EVP_PKEY* pk;
|
||||
int pktype;
|
||||
|
||||
_libssh2_debug(session,
|
||||
LIBSSH2_TRACE_AUTH,
|
||||
@@ -922,7 +1069,13 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
"private key file format");
|
||||
}
|
||||
|
||||
switch (pk->type) {
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
pktype = EVP_PKEY_id(pk);
|
||||
#else
|
||||
pktype = pk->type;
|
||||
#endif
|
||||
|
||||
switch (pktype) {
|
||||
case EVP_PKEY_RSA :
|
||||
st = gen_publickey_from_rsa_evp(session, method, method_len,
|
||||
pubkeydata, pubkeydata_len, pk);
|
||||
|
||||
120
src/openssl.h
120
src/openssl.h
@@ -39,6 +39,11 @@
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/engine.h>
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
#include <openssl/dsa.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
#include <openssl/md5.h>
|
||||
#endif
|
||||
@@ -48,6 +53,11 @@
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
|
||||
!defined(LIBRESSL_VERSION_NUMBER)
|
||||
# define HAVE_OPAQUE_STRUCTS 1
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_NO_RSA
|
||||
# define LIBSSH2_RSA 0
|
||||
#else
|
||||
@@ -72,6 +82,9 @@
|
||||
# define LIBSSH2_HMAC_RIPEMD 1
|
||||
#endif
|
||||
|
||||
#define LIBSSH2_HMAC_SHA256 1
|
||||
#define LIBSSH2_HMAC_SHA512 1
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00907000L && !defined(OPENSSL_NO_AES)
|
||||
# define LIBSSH2_AES_CTR 1
|
||||
# define LIBSSH2_AES 1
|
||||
@@ -106,37 +119,118 @@
|
||||
|
||||
#define _libssh2_random(buf, len) RAND_bytes ((buf), (len))
|
||||
|
||||
#define libssh2_prepare_iovec(vec, len) /* Empty. */
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_sha1_ctx EVP_MD_CTX *
|
||||
#else
|
||||
#define libssh2_sha1_ctx EVP_MD_CTX
|
||||
#endif
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
int libssh2_sha1_init(libssh2_sha1_ctx *ctx);
|
||||
int _libssh2_sha1_init(libssh2_sha1_ctx *ctx);
|
||||
#define libssh2_sha1_init(x) _libssh2_sha1_init(x)
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_sha1_update(ctx, data, len) EVP_DigestUpdate(ctx, data, len)
|
||||
#define libssh2_sha1_final(ctx, out) do { \
|
||||
EVP_DigestFinal(ctx, out, NULL); \
|
||||
EVP_MD_CTX_free(ctx); \
|
||||
} while(0)
|
||||
#else
|
||||
#define libssh2_sha1_update(ctx, data, len) EVP_DigestUpdate(&(ctx), data, len)
|
||||
#define libssh2_sha1_final(ctx, out) EVP_DigestFinal(&(ctx), out, NULL)
|
||||
void libssh2_sha1(const unsigned char *message, unsigned long len, unsigned char *out);
|
||||
#endif
|
||||
int _libssh2_sha1(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out);
|
||||
#define libssh2_sha1(x,y,z) _libssh2_sha1(x,y,z)
|
||||
|
||||
#define libssh2_md5_ctx EVP_MD_CTX
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_sha256_ctx EVP_MD_CTX *
|
||||
#else
|
||||
#define libssh2_sha256_ctx EVP_MD_CTX
|
||||
#endif
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
int libssh2_md5_init(libssh2_md5_ctx *);
|
||||
int _libssh2_sha256_init(libssh2_sha256_ctx *ctx);
|
||||
#define libssh2_sha256_init(x) _libssh2_sha256_init(x)
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_sha256_update(ctx, data, len) EVP_DigestUpdate(ctx, data, len)
|
||||
#define libssh2_sha256_final(ctx, out) do { \
|
||||
EVP_DigestFinal(ctx, out, NULL); \
|
||||
EVP_MD_CTX_free(ctx); \
|
||||
} while(0)
|
||||
#else
|
||||
#define libssh2_sha256_update(ctx, data, len) EVP_DigestUpdate(&(ctx), data, len)
|
||||
#define libssh2_sha256_final(ctx, out) EVP_DigestFinal(&(ctx), out, NULL)
|
||||
#endif
|
||||
int _libssh2_sha256(const unsigned char *message, unsigned long len,
|
||||
unsigned char *out);
|
||||
#define libssh2_sha256(x,y,z) _libssh2_sha256(x,y,z)
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_md5_ctx EVP_MD_CTX *
|
||||
#else
|
||||
#define libssh2_md5_ctx EVP_MD_CTX
|
||||
#endif
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
int _libssh2_md5_init(libssh2_md5_ctx *ctx);
|
||||
#define libssh2_md5_init(x) _libssh2_md5_init(x)
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_md5_update(ctx, data, len) EVP_DigestUpdate(ctx, data, len)
|
||||
#define libssh2_md5_final(ctx, out) do { \
|
||||
EVP_DigestFinal(ctx, out, NULL); \
|
||||
EVP_MD_CTX_free(ctx); \
|
||||
} while(0)
|
||||
#else
|
||||
#define libssh2_md5_update(ctx, data, len) EVP_DigestUpdate(&(ctx), data, len)
|
||||
#define libssh2_md5_final(ctx, out) EVP_DigestFinal(&(ctx), out, NULL)
|
||||
void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char *out);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define libssh2_hmac_ctx HMAC_CTX *
|
||||
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(*(ctx), key, keylen, EVP_sha1(), NULL)
|
||||
#define libssh2_hmac_md5_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(*(ctx), key, keylen, EVP_md5(), NULL)
|
||||
#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(*(ctx), key, keylen, EVP_ripemd160(), NULL)
|
||||
#define libssh2_hmac_sha256_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(*(ctx), key, keylen, EVP_sha256(), NULL)
|
||||
#define libssh2_hmac_sha512_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(*(ctx), key, keylen, EVP_sha512(), NULL)
|
||||
|
||||
#define libssh2_hmac_update(ctx, data, datalen) \
|
||||
HMAC_Update(ctx, data, datalen)
|
||||
#define libssh2_hmac_final(ctx, data) HMAC_Final(ctx, data, NULL)
|
||||
#define libssh2_hmac_cleanup(ctx) HMAC_CTX_free(*(ctx))
|
||||
#else
|
||||
#define libssh2_hmac_ctx HMAC_CTX
|
||||
#define libssh2_hmac_ctx_init(ctx) \
|
||||
HMAC_CTX_init(&ctx)
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
HMAC_Init(ctx, key, keylen, EVP_sha1())
|
||||
HMAC_Init_ex(ctx, key, keylen, EVP_sha1(), NULL)
|
||||
#define libssh2_hmac_md5_init(ctx, key, keylen) \
|
||||
HMAC_Init(ctx, key, keylen, EVP_md5())
|
||||
HMAC_Init_ex(ctx, key, keylen, EVP_md5(), NULL)
|
||||
#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \
|
||||
HMAC_Init(ctx, key, keylen, EVP_ripemd160())
|
||||
HMAC_Init_ex(ctx, key, keylen, EVP_ripemd160(), NULL)
|
||||
#define libssh2_hmac_sha256_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(ctx, key, keylen, EVP_sha256(), NULL)
|
||||
#define libssh2_hmac_sha512_init(ctx, key, keylen) \
|
||||
HMAC_Init_ex(ctx, key, keylen, EVP_sha512(), NULL)
|
||||
|
||||
#define libssh2_hmac_update(ctx, data, datalen) \
|
||||
HMAC_Update(&(ctx), data, datalen)
|
||||
#define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
|
||||
#define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx)
|
||||
#endif
|
||||
|
||||
#define libssh2_crypto_init() \
|
||||
OpenSSL_add_all_algorithms(); \
|
||||
ENGINE_load_builtin_engines(); \
|
||||
ENGINE_register_all_complete()
|
||||
|
||||
#define libssh2_crypto_init() OpenSSL_add_all_algorithms()
|
||||
#define libssh2_crypto_exit()
|
||||
|
||||
#define libssh2_rsa_ctx RSA
|
||||
@@ -149,7 +243,11 @@ void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char
|
||||
#define _libssh2_dsa_free(dsactx) DSA_free(dsactx)
|
||||
|
||||
#define _libssh2_cipher_type(name) const EVP_CIPHER *(*name)(void)
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define _libssh2_cipher_ctx EVP_CIPHER_CTX *
|
||||
#else
|
||||
#define _libssh2_cipher_ctx EVP_CIPHER_CTX
|
||||
#endif
|
||||
|
||||
#define _libssh2_cipher_aes256 EVP_aes_256_cbc
|
||||
#define _libssh2_cipher_aes192 EVP_aes_192_cbc
|
||||
@@ -168,7 +266,11 @@ void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char
|
||||
#define _libssh2_cipher_cast5 EVP_cast5_cbc
|
||||
#define _libssh2_cipher_3des EVP_des_ede3_cbc
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
#define _libssh2_cipher_dtor(ctx) EVP_CIPHER_CTX_reset(*(ctx))
|
||||
#else
|
||||
#define _libssh2_cipher_dtor(ctx) EVP_CIPHER_CTX_cleanup(ctx)
|
||||
#endif
|
||||
|
||||
#define _libssh2_bn BIGNUM
|
||||
#define _libssh2_bn_ctx BN_CTX
|
||||
|
||||
2513
src/os400qc3.c
Normal file
2513
src/os400qc3.c
Normal file
File diff suppressed because it is too large
Load Diff
358
src/os400qc3.h
Normal file
358
src/os400qc3.h
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* 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_OS400QC3_H
|
||||
#define LIBSSH2_OS400QC3_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <qc3cci.h>
|
||||
|
||||
|
||||
/* Redefine character/string literals as always EBCDIC. */
|
||||
#undef Qc3_Alg_Token
|
||||
#define Qc3_Alg_Token "\xC1\xD3\xC7\xC4\xF0\xF1\xF0\xF0" /* ALGD0100 */
|
||||
#undef Qc3_Alg_Block_Cipher
|
||||
#define Qc3_Alg_Block_Cipher "\xC1\xD3\xC7\xC4\xF0\xF2\xF0\xF0" /* ALGD0200 */
|
||||
#undef Qc3_Alg_Block_CipherAuth
|
||||
#define Qc3_Alg_Block_CipherAuth \
|
||||
"\xC1\xD3\xC7\xC4\xF0\xF2\xF1\xF0" /* ALGD0210 */
|
||||
#undef Qc3_Alg_Stream_Cipher
|
||||
#define Qc3_Alg_Stream_Cipher \
|
||||
"\xC1\xD3\xC7\xC4\xF0\xF3\xF0\xF0" /* ALGD0300 */
|
||||
#undef Qc3_Alg_Public_Key
|
||||
#define Qc3_Alg_Public_Key "\xC1\xD3\xC7\xC4\xF0\xF4\xF0\xF0" /* ALGD0400 */
|
||||
#undef Qc3_Alg_Hash
|
||||
#define Qc3_Alg_Hash "\xC1\xD3\xC7\xC4\xF0\xF5\xF0\xF0" /* ALGD0500 */
|
||||
#undef Qc3_Data
|
||||
#define Qc3_Data "\xC4\xC1\xE3\xC1\xF0\xF1\xF0\xF0" /* DATA0100 */
|
||||
#undef Qc3_Array
|
||||
#define Qc3_Array "\xC4\xC1\xE3\xC1\xF0\xF2\xF0\xF0" /* DATA0200 */
|
||||
#undef Qc3_Key_Token
|
||||
#define Qc3_Key_Token "\xD2\xC5\xE8\xC4\xF0\xF1\xF0\xF0" /* KEYD0100 */
|
||||
#undef Qc3_Key_Parms
|
||||
#define Qc3_Key_Parms "\xD2\xC5\xE8\xC4\xF0\xF2\xF0\xF0" /* KEYD0200 */
|
||||
#undef Qc3_Key_KSLabel
|
||||
#define Qc3_Key_KSLabel "\xD2\xC5\xE8\xC4\xF0\xF4\xF0\xF0" /* KEYD0400 */
|
||||
#undef Qc3_Key_PKCS5
|
||||
#define Qc3_Key_PKCS5 "\xD2\xC5\xE8\xC4\xF0\xF5\xF0\xF0" /* KEYD0500 */
|
||||
#undef Qc3_Key_PEMCert
|
||||
#define Qc3_Key_PEMCert "\xD2\xC5\xE8\xC4\xF0\xF6\xF0\xF0" /* KEYD0600 */
|
||||
#undef Qc3_Key_CSLabel
|
||||
#define Qc3_Key_CSLabel "\xD2\xC5\xE8\xC4\xF0\xF7\xF0\xF0" /* KEYD0700 */
|
||||
#undef Qc3_Key_CSDN
|
||||
#define Qc3_Key_CSDN "\xD2\xC5\xE8\xC4\xF0\xF8\xF0\xF0" /* KEYD0800 */
|
||||
#undef Qc3_Key_AppID
|
||||
#define Qc3_Key_AppID "\xD2\xC5\xE8\xC4\xF0\xF9\xF0\xF0" /* KEYD0900 */
|
||||
|
||||
#undef Qc3_ECB
|
||||
#define Qc3_ECB '\xF0' /* '0' */
|
||||
#undef Qc3_CBC
|
||||
#define Qc3_CBC '\xF1' /* '1' */
|
||||
#undef Qc3_OFB
|
||||
#define Qc3_OFB '\xF2' /* '2' */
|
||||
#undef Qc3_CFB1Bit
|
||||
#define Qc3_CFB1Bit '\xF3' /* '3' */
|
||||
#undef Qc3_CFB8Bit
|
||||
#define Qc3_CFB8Bit '\xF4' /* '4' */
|
||||
#undef Qc3_CFB64Bit
|
||||
#define Qc3_CFB64Bit '\xF5' /* '5' */
|
||||
#undef Qc3_CUSP
|
||||
#define Qc3_CUSP '\xF6' /* '6' */
|
||||
#undef Qc3_CTR
|
||||
#define Qc3_CTR '\xF7' /* '7' */
|
||||
#undef Qc3_CCM
|
||||
#define Qc3_CCM '\xF8' /* '8' */
|
||||
#undef Qc3_No_Pad
|
||||
#define Qc3_No_Pad '\xF0' /* '0' */
|
||||
#undef Qc3_Pad_Char
|
||||
#define Qc3_Pad_Char '\xF1' /* '1' */
|
||||
#undef Qc3_Pad_Counter
|
||||
#define Qc3_Pad_Counter '\xF2' /* '2' */
|
||||
#undef Qc3_PKCS1_00
|
||||
#define Qc3_PKCS1_00 '\xF0' /* '0' */
|
||||
#undef Qc3_PKCS1_01
|
||||
#define Qc3_PKCS1_01 '\xF1' /* '1' */
|
||||
#undef Qc3_PKCS1_02
|
||||
#define Qc3_PKCS1_02 '\xF2' /* '2' */
|
||||
#undef Qc3_ISO9796
|
||||
#define Qc3_ISO9796 '\xF3' /* '3' */
|
||||
#undef Qc3_Zero_Pad
|
||||
#define Qc3_Zero_Pad '\xF4' /* '4' */
|
||||
#undef Qc3_ANSI_X931
|
||||
#define Qc3_ANSI_X931 '\xF5' /* '5' */
|
||||
#undef Qc3_OAEP
|
||||
#define Qc3_OAEP '\xF6' /* '6' */
|
||||
#undef Qc3_Bin_String
|
||||
#define Qc3_Bin_String '\xF0' /* '0' */
|
||||
#undef Qc3_BER_String
|
||||
#define Qc3_BER_String '\xF1' /* '1' */
|
||||
#undef Qc3_MK_Struct
|
||||
#define Qc3_MK_Struct '\xF3' /* '3' */
|
||||
#undef Qc3_KSLabel_Struct
|
||||
#define Qc3_KSLabel_Struct '\xF4' /* '4' */
|
||||
#undef Qc3_PKCS5_Struct
|
||||
#define Qc3_PKCS5_Struct '\xF5' /* '5' */
|
||||
#undef Qc3_PEMCert_String
|
||||
#define Qc3_PEMCert_String '\xF6' /* '6' */
|
||||
#undef Qc3_CSLabel_String
|
||||
#define Qc3_CSLabel_String '\xF7' /* '7' */
|
||||
#undef Qc3_CSDN_String
|
||||
#define Qc3_CSDN_String '\xF8' /* '8' */
|
||||
#undef Qc3_Clear
|
||||
#define Qc3_Clear '\xF0' /* '0' */
|
||||
#undef Qc3_Encrypted
|
||||
#define Qc3_Encrypted '\xF1' /* '1' */
|
||||
#undef Qc3_MK_Encrypted
|
||||
#define Qc3_MK_Encrypted '\xF2' /* '2' */
|
||||
#undef Qc3_Any_CSP
|
||||
#define Qc3_Any_CSP '\xF0' /* '0' */
|
||||
#undef Qc3_Sfw_CSP
|
||||
#define Qc3_Sfw_CSP '\xF1' /* '1' */
|
||||
#undef Qc3_Hdw_CSP
|
||||
#define Qc3_Hdw_CSP '\xF2' /* '2' */
|
||||
#undef Qc3_Continue
|
||||
#define Qc3_Continue '\xF0' /* '0' */
|
||||
#undef Qc3_Final
|
||||
#define Qc3_Final '\xF1' /* '1' */
|
||||
#undef Qc3_MK_New
|
||||
#define Qc3_MK_New '\xF0' /* '0' */
|
||||
#undef Qc3_MK_Current
|
||||
#define Qc3_MK_Current '\xF1' /* '1' */
|
||||
#undef Qc3_MK_Old
|
||||
#define Qc3_MK_Old '\xF2' /* '2' */
|
||||
#undef Qc3_MK_Pending
|
||||
#define Qc3_MK_Pending '\xF3' /* '3' */
|
||||
|
||||
|
||||
/* Define which features are supported. */
|
||||
#define LIBSSH2_MD5 1
|
||||
#define LIBSSH2_HMAC_RIPEMD 0
|
||||
#define LIBSSH2_HMAC_SHA256 1
|
||||
#define LIBSSH2_HMAC_SHA512 1
|
||||
|
||||
#define LIBSSH2_AES 1
|
||||
#define LIBSSH2_AES_CTR 1
|
||||
#define LIBSSH2_BLOWFISH 0
|
||||
#define LIBSSH2_RC4 1
|
||||
#define LIBSSH2_CAST 0
|
||||
#define LIBSSH2_3DES 1
|
||||
|
||||
#define LIBSSH2_RSA 1
|
||||
#define LIBSSH2_DSA 0
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define SHA_DIGEST_LENGTH 20
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: global handles structures.
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
/* HMAC & private key algorithms support structure. */
|
||||
typedef struct _libssh2_os400qc3_crypto_ctx _libssh2_os400qc3_crypto_ctx;
|
||||
struct _libssh2_os400qc3_crypto_ctx {
|
||||
Qc3_Format_ALGD0100_T hash; /* Hash algorithm. */
|
||||
Qc3_Format_KEYD0100_T key; /* Key. */
|
||||
_libssh2_os400qc3_crypto_ctx * kek; /* Key encryption. */
|
||||
};
|
||||
|
||||
typedef struct { /* Big number. */
|
||||
unsigned char * bignum; /* Number bits, little-endian. */
|
||||
unsigned int length; /* Length of bignum (# bytes). */
|
||||
} _libssh2_bn;
|
||||
|
||||
typedef struct { /* Algorithm description. */
|
||||
char * fmt; /* Format of Qc3 structure. */
|
||||
int algo; /* Algorithm identifier. */
|
||||
unsigned char size; /* Block length. */
|
||||
unsigned char mode; /* Block mode. */
|
||||
int keylen; /* Key length. */
|
||||
} _libssh2_os400qc3_cipher_t;
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: Define global types/codes.
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
#define libssh2_crypto_init()
|
||||
#define libssh2_crypto_exit()
|
||||
|
||||
#define libssh2_sha1_ctx Qc3_Format_ALGD0100_T
|
||||
#define libssh2_sha256_ctx Qc3_Format_ALGD0100_T
|
||||
#define libssh2_md5_ctx Qc3_Format_ALGD0100_T
|
||||
#define libssh2_hmac_ctx _libssh2_os400qc3_crypto_ctx
|
||||
#define _libssh2_cipher_ctx _libssh2_os400qc3_crypto_ctx
|
||||
|
||||
#define libssh2_sha1_init(x) libssh2_os400qc3_hash_init(x, Qc3_SHA1)
|
||||
#define libssh2_sha1_update(ctx, data, len) \
|
||||
libssh2_os400qc3_hash_update(&(ctx), data, len)
|
||||
#define libssh2_sha1_final(ctx, out) \
|
||||
libssh2_os400qc3_hash_final(&(ctx), out)
|
||||
#define libssh2_sha256_init(x) libssh2_os400qc3_hash_init(x, Qc3_SHA256)
|
||||
#define libssh2_sha256_update(ctx, data, len) \
|
||||
libssh2_os400qc3_hash_update(&(ctx), data, len)
|
||||
#define libssh2_sha256_final(ctx, out) \
|
||||
libssh2_os400qc3_hash_final(&(ctx), out)
|
||||
#define libssh2_sha256(message, len, out) \
|
||||
libssh2_os400qc3_hash(message, len, out, \
|
||||
Qc3_SHA256)
|
||||
#define libssh2_md5_init(x) libssh2_os400qc3_hash_init(x, Qc3_MD5)
|
||||
#define libssh2_md5_update(ctx, data, len) \
|
||||
libssh2_os400qc3_hash_update(&(ctx), data, len)
|
||||
#define libssh2_md5_final(ctx, out) \
|
||||
libssh2_os400qc3_hash_final(&(ctx), out)
|
||||
#define libssh2_hmac_ctx_init(ctx) \
|
||||
memset((char *) &(ctx), 0, \
|
||||
sizeof(libssh2_hmac_ctx))
|
||||
#define libssh2_hmac_md5_init(ctx, key, keylen) \
|
||||
libssh2_os400qc3_hmac_init(ctx, Qc3_MD5, \
|
||||
MD5_DIGEST_LENGTH, \
|
||||
key, keylen)
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
libssh2_os400qc3_hmac_init(ctx, Qc3_SHA1, \
|
||||
SHA_DIGEST_LENGTH, \
|
||||
key, keylen)
|
||||
#define libssh2_hmac_sha256_init(ctx, key, keylen) \
|
||||
libssh2_os400qc3_hmac_init(ctx, Qc3_SHA256, \
|
||||
SHA256_DIGEST_LENGTH, \
|
||||
key, keylen)
|
||||
#define libssh2_hmac_sha512_init(ctx, key, keylen) \
|
||||
libssh2_os400qc3_hmac_init(ctx, Qc3_SHA512, \
|
||||
SHA512_DIGEST_LENGTH, \
|
||||
key, keylen)
|
||||
#define libssh2_hmac_update(ctx, data, datalen) \
|
||||
libssh2_os400qc3_hmac_update(&(ctx), \
|
||||
data, datalen)
|
||||
#define libssh2_hmac_final(ctx, data) \
|
||||
libssh2_os400qc3_hmac_final(&(ctx), data)
|
||||
#define libssh2_hmac_cleanup(ctx) \
|
||||
_libssh2_os400qc3_crypto_dtor(ctx)
|
||||
|
||||
|
||||
#define _libssh2_bn_ctx int /* Not used. */
|
||||
|
||||
#define _libssh2_bn_ctx_new() 0
|
||||
#define _libssh2_bn_ctx_free(bnctx) ((void) 0)
|
||||
|
||||
#define _libssh2_bn_init_from_bin() _libssh2_bn_init()
|
||||
#define _libssh2_bn_mod_exp(r, a, p, m, ctx) \
|
||||
_libssh2_os400qc3_bn_mod_exp(r, a, p, m)
|
||||
#define _libssh2_bn_bytes(bn) ((bn)->length)
|
||||
|
||||
#define _libssh2_cipher_type(name) _libssh2_os400qc3_cipher_t name
|
||||
#define _libssh2_cipher_aes128 {Qc3_Alg_Block_Cipher, Qc3_AES, 16, \
|
||||
Qc3_CBC, 16}
|
||||
#define _libssh2_cipher_aes192 {Qc3_Alg_Block_Cipher, Qc3_AES, 24, \
|
||||
Qc3_CBC, 24}
|
||||
#define _libssh2_cipher_aes256 {Qc3_Alg_Block_Cipher, Qc3_AES, 32, \
|
||||
Qc3_CBC, 32}
|
||||
#define _libssh2_cipher_aes128ctr {Qc3_Alg_Block_Cipher, Qc3_AES, 16, \
|
||||
Qc3_CTR, 16}
|
||||
#define _libssh2_cipher_aes192ctr {Qc3_Alg_Block_Cipher, Qc3_AES, 24, \
|
||||
Qc3_CTR, 24}
|
||||
#define _libssh2_cipher_aes256ctr {Qc3_Alg_Block_Cipher, Qc3_AES, 32, \
|
||||
Qc3_CTR, 32}
|
||||
#define _libssh2_cipher_3des {Qc3_Alg_Block_Cipher, Qc3_TDES, 0, \
|
||||
Qc3_CBC, 24}
|
||||
#define _libssh2_cipher_arcfour {Qc3_Alg_Stream_Cipher, Qc3_RC4, 0, 0, 16}
|
||||
|
||||
#define _libssh2_cipher_dtor(ctx) _libssh2_os400qc3_crypto_dtor(ctx)
|
||||
|
||||
#define libssh2_rsa_ctx _libssh2_os400qc3_crypto_ctx
|
||||
#define _libssh2_rsa_free(ctx) (_libssh2_os400qc3_crypto_dtor(ctx), \
|
||||
free((char *) ctx))
|
||||
#define libssh2_prepare_iovec(vec, len) memset((char *) (vec), 0, \
|
||||
(len) * sizeof(struct iovec))
|
||||
#define _libssh2_rsa_sha1_signv(session, sig, siglen, count, vector, ctx) \
|
||||
_libssh2_os400qc3_rsa_sha1_signv(session, sig, siglen, \
|
||||
count, vector, ctx)
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: Support procedure prototypes.
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
extern _libssh2_bn * _libssh2_bn_init(void);
|
||||
extern void _libssh2_bn_free(_libssh2_bn *bn);
|
||||
extern unsigned long _libssh2_bn_bits(_libssh2_bn *bn);
|
||||
extern int _libssh2_bn_from_bin(_libssh2_bn *bn, int len,
|
||||
const unsigned char *v);
|
||||
extern int _libssh2_bn_set_word(_libssh2_bn *bn, unsigned long val);
|
||||
extern int _libssh2_bn_to_bin(_libssh2_bn *bn, unsigned char *val);
|
||||
extern void _libssh2_random(unsigned char *buf, int len);
|
||||
extern int _libssh2_bn_rand(_libssh2_bn *bn, int bits,
|
||||
int top, int bottom);
|
||||
extern int _libssh2_os400qc3_bn_mod_exp(_libssh2_bn *r, _libssh2_bn *a,
|
||||
_libssh2_bn *p, _libssh2_bn *m);
|
||||
extern void _libssh2_os400qc3_crypto_dtor(_libssh2_os400qc3_crypto_ctx *x);
|
||||
extern int libssh2_os400qc3_hash_init(Qc3_Format_ALGD0100_T *x,
|
||||
unsigned int algo);
|
||||
extern void libssh2_os400qc3_hash_update(Qc3_Format_ALGD0100_T *ctx,
|
||||
unsigned char *data, int len);
|
||||
extern void libssh2_os400qc3_hash_final(Qc3_Format_ALGD0100_T *ctx,
|
||||
unsigned char *out);
|
||||
extern int libssh2_os400qc3_hash(const unsigned char *message,
|
||||
unsigned long len, unsigned char *out,
|
||||
unsigned int algo);
|
||||
extern void libssh2_os400qc3_hmac_init(_libssh2_os400qc3_crypto_ctx *x,
|
||||
int algo, size_t minkeylen,
|
||||
void *key, int keylen);
|
||||
extern void libssh2_os400qc3_hmac_update(_libssh2_os400qc3_crypto_ctx *ctx,
|
||||
const unsigned char *data,
|
||||
int len);
|
||||
extern void libssh2_os400qc3_hmac_final(_libssh2_os400qc3_crypto_ctx *ctx,
|
||||
unsigned char *out);
|
||||
extern int _libssh2_os400qc3_rsa_sha1_signv(LIBSSH2_SESSION *session,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len,
|
||||
int veccount,
|
||||
const struct iovec vector[],
|
||||
libssh2_rsa_ctx *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
42
src/scp.c
42
src/scp.c
@@ -268,7 +268,7 @@ shell_quotearg(const char *path, unsigned char *buf,
|
||||
*
|
||||
*/
|
||||
static LIBSSH2_CHANNEL *
|
||||
scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
||||
{
|
||||
int cmd_len;
|
||||
int rc;
|
||||
@@ -724,7 +724,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
}
|
||||
|
||||
if (sb) {
|
||||
memset(sb, 0, sizeof(struct stat));
|
||||
memset(sb, 0, sizeof(libssh2_struct_stat));
|
||||
|
||||
sb->st_mtime = session->scpRecv_mtime;
|
||||
sb->st_atime = session->scpRecv_atime;
|
||||
@@ -759,11 +759,47 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
/*
|
||||
* libssh2_scp_recv
|
||||
*
|
||||
* Open a channel and request a remote file via SCP
|
||||
* DEPRECATED
|
||||
*
|
||||
* Open a channel and request a remote file via SCP. This receives files larger
|
||||
* than 2 GB, but is unable to report the proper size on platforms where the
|
||||
* st_size member of struct stat is limited to 2 GB (e.g. windows).
|
||||
*
|
||||
*/
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat * sb)
|
||||
{
|
||||
LIBSSH2_CHANNEL *ptr;
|
||||
|
||||
/* scp_recv uses libssh2_struct_stat, so pass one if the caller gave us a struct to populate... */
|
||||
libssh2_struct_stat sb_intl;
|
||||
libssh2_struct_stat *sb_ptr;
|
||||
sb_ptr = sb ? &sb_intl : NULL;
|
||||
|
||||
BLOCK_ADJUST_ERRNO(ptr, session, scp_recv(session, path, sb_ptr));
|
||||
|
||||
/* ...and populate the caller's with as much info as fits. */
|
||||
if (sb) {
|
||||
memset(sb, 0, sizeof(struct stat));
|
||||
|
||||
sb->st_mtime = sb_intl.st_mtime;
|
||||
sb->st_atime = sb_intl.st_atime;
|
||||
sb->st_size = (off_t)sb_intl.st_size;
|
||||
sb->st_mode = sb_intl.st_mode;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* libssh2_scp_recv2
|
||||
*
|
||||
* Open a channel and request a remote file via SCP. This supports files > 2GB
|
||||
* on platforms that support it.
|
||||
*
|
||||
*/
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv2(LIBSSH2_SESSION *session, const char *path, libssh2_struct_stat * sb)
|
||||
{
|
||||
LIBSSH2_CHANNEL *ptr;
|
||||
BLOCK_ADJUST_ERRNO(ptr, session, scp_recv(session, path, sb));
|
||||
|
||||
@@ -1058,6 +1058,11 @@ session_free(LIBSSH2_SESSION *session)
|
||||
LIBSSH2_FREE(session, session->server_hostkey);
|
||||
}
|
||||
|
||||
/* error string */
|
||||
if (session->err_msg && ((session->err_flags & LIBSSH2_ERR_FLAG_DUP) != 0)) {
|
||||
LIBSSH2_FREE(session, (char *)session->err_msg);
|
||||
}
|
||||
|
||||
LIBSSH2_FREE(session, session);
|
||||
|
||||
return 0;
|
||||
@@ -1285,7 +1290,24 @@ libssh2_session_last_errno(LIBSSH2_SESSION * session)
|
||||
return session->err_code;
|
||||
}
|
||||
|
||||
/* libssh2_session_flag
|
||||
/* libssh2_session_set_last_error
|
||||
*
|
||||
* Sets the internal error code for the session.
|
||||
*
|
||||
* This function is available specifically to be used by high level
|
||||
* language wrappers (i.e. Python or Perl) that may extend the library
|
||||
* features while still relying on its error reporting mechanism.
|
||||
*/
|
||||
LIBSSH2_API int
|
||||
libssh2_session_set_last_error(LIBSSH2_SESSION* session,
|
||||
int errcode,
|
||||
const char* errmsg)
|
||||
{
|
||||
return _libssh2_error_flags(session, errcode, errmsg,
|
||||
LIBSSH2_ERR_FLAG_DUP);
|
||||
}
|
||||
|
||||
/* Libssh2_session_flag
|
||||
*
|
||||
* Set/Get session flags
|
||||
*
|
||||
|
||||
173
src/sftp.c
173
src/sftp.c
@@ -108,7 +108,7 @@ static int sftp_attrsize(unsigned long flags)
|
||||
((flags & LIBSSH2_SFTP_ATTR_UIDGID) ? 8 : 0) +
|
||||
((flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) ? 4 : 0) +
|
||||
((flags & LIBSSH2_SFTP_ATTR_ACMODTIME) ? 8 : 0));
|
||||
/* atime + mtime as u32 */
|
||||
/* atime + mtime as u32 */
|
||||
}
|
||||
|
||||
/* _libssh2_store_u64
|
||||
@@ -161,8 +161,8 @@ remove_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
|
||||
request_id);
|
||||
if(zombie) {
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
|
||||
"Removing request ID %ld from the list of zombie requests",
|
||||
request_id);
|
||||
"Removing request ID %ld from the list of zombie requests",
|
||||
request_id);
|
||||
|
||||
_libssh2_list_remove(&zombie->node);
|
||||
LIBSSH2_FREE(session, zombie);
|
||||
@@ -204,7 +204,8 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
|
||||
LIBSSH2_SFTP_PACKET *packet;
|
||||
uint32_t request_id;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Received packet %d (len %d)",
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
|
||||
"Received packet type %d (len %d)",
|
||||
(int) data[0], data_len);
|
||||
|
||||
/*
|
||||
@@ -250,12 +251,15 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
|
||||
|
||||
request_id = _libssh2_ntohu32(&data[1]);
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Received packet id %d",
|
||||
request_id);
|
||||
|
||||
/* Don't add the packet if it answers a request we've given up on. */
|
||||
if((data[0] == SSH_FXP_STATUS || data[0] == SSH_FXP_DATA)
|
||||
&& find_zombie_request(sftp, request_id)) {
|
||||
&& find_zombie_request(sftp, request_id)) {
|
||||
|
||||
/* If we get here, the file ended before the response arrived. We
|
||||
are no longer interested in the request so we discard it */
|
||||
are no longer interested in the request so we discard it */
|
||||
|
||||
LIBSSH2_FREE(session, data);
|
||||
|
||||
@@ -348,13 +352,13 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
|
||||
packet = LIBSSH2_ALLOC(session, sftp->partial_len);
|
||||
if (!packet)
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate SFTP packet");
|
||||
"Unable to allocate SFTP packet");
|
||||
sftp->partial_size_len = 0;
|
||||
sftp->partial_received = 0; /* how much of the packet already
|
||||
received */
|
||||
sftp->partial_packet = packet;
|
||||
|
||||
window_adjust:
|
||||
window_adjust:
|
||||
recv_window = libssh2_channel_window_read_ex(channel, NULL, NULL);
|
||||
|
||||
if(sftp->partial_len > recv_window) {
|
||||
@@ -1245,6 +1249,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
ssize_t rc;
|
||||
struct _libssh2_sftp_handle_file_data *filep =
|
||||
&handle->u.file;
|
||||
size_t bytes_in_buffer = 0;
|
||||
char *sliding_bufferp = buffer;
|
||||
|
||||
/* This function can be interrupted in three different places where it
|
||||
might need to wait for data from the network. It returns EAGAIN to
|
||||
@@ -1301,11 +1307,14 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* We allow a number of bytes being requested at any given time
|
||||
without having been acked - until we reach EOF. */
|
||||
if(!filep->eof) {
|
||||
if (filep->eof) {
|
||||
return 0;
|
||||
} else {
|
||||
/* We allow a number of bytes being requested at any given time
|
||||
without having been acked - until we reach EOF. */
|
||||
|
||||
/* Number of bytes asked for that haven't been acked yet */
|
||||
size_t already = (filep->offset_sent - filep->offset);
|
||||
size_t already = (size_t)(filep->offset_sent - filep->offset);
|
||||
|
||||
size_t max_read_ahead = buffer_size*4;
|
||||
unsigned long recv_window;
|
||||
@@ -1358,19 +1367,25 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
while(count > 0) {
|
||||
unsigned char *s;
|
||||
uint32_t size = MIN(MAX_SFTP_READ_SIZE, count);
|
||||
|
||||
/* 25 = packet_len(4) + packet_type(1) + request_id(4) +
|
||||
handle_len(4) + offset(8) + count(4) */
|
||||
uint32_t packet_len = (uint32_t)handle->handle_len + 25;
|
||||
uint32_t request_id;
|
||||
|
||||
uint32_t size = count;
|
||||
if (size < buffer_size)
|
||||
size = buffer_size;
|
||||
if (size > MAX_SFTP_READ_SIZE)
|
||||
size = MAX_SFTP_READ_SIZE;
|
||||
|
||||
chunk = LIBSSH2_ALLOC(session, packet_len +
|
||||
sizeof(struct sftp_pipeline_chunk));
|
||||
if (!chunk)
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"malloc fail for FXP_WRITE");
|
||||
|
||||
chunk->offset = filep->offset_sent;
|
||||
chunk->len = size;
|
||||
chunk->lefttosend = packet_len;
|
||||
chunk->sent = 0;
|
||||
@@ -1389,8 +1404,11 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
/* add this new entry LAST in the list */
|
||||
_libssh2_list_add(&handle->packet_list, &chunk->node);
|
||||
count -= size; /* deduct the size we used, as we might have
|
||||
to create more packets */
|
||||
count -= MIN(size,count); /* deduct the size we used, as we might
|
||||
* have to create more packets */
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
|
||||
"read request id %d sent (offset: %d, size: %d)",
|
||||
request_id, (int)chunk->offset, (int)chunk->len);
|
||||
}
|
||||
|
||||
case libssh2_NB_state_sent:
|
||||
@@ -1416,9 +1434,16 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
chunk->lefttosend -= rc;
|
||||
chunk->sent += rc;
|
||||
|
||||
if(chunk->lefttosend)
|
||||
/* data left to send, get out of loop */
|
||||
break;
|
||||
if(chunk->lefttosend) {
|
||||
/* We still have data left to send for this chunk.
|
||||
* If there is at least one completely sent chunk,
|
||||
* we can get out of this loop and start reading. */
|
||||
if (chunk != _libssh2_list_first(&handle->packet_list)) {
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* move on to the next chunk with data to send */
|
||||
@@ -1442,13 +1467,27 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
SSH_FXP_DATA, SSH_FXP_STATUS
|
||||
};
|
||||
|
||||
if(chunk->lefttosend)
|
||||
if(chunk->lefttosend) {
|
||||
/* if the chunk still has data left to send, we shouldn't wait
|
||||
for an ACK for it just yet */
|
||||
break;
|
||||
if (bytes_in_buffer > 0) {
|
||||
return bytes_in_buffer;
|
||||
} else {
|
||||
/* we should never reach this point */
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"sftp_read() internal error");
|
||||
}
|
||||
}
|
||||
|
||||
rc = sftp_packet_requirev(sftp, 2, read_responses,
|
||||
chunk->request_id, &data, &data_len);
|
||||
|
||||
if (rc==LIBSSH2_ERROR_EAGAIN && bytes_in_buffer != 0) {
|
||||
/* do not return EAGAIN if we have already
|
||||
* written data into the buffer */
|
||||
return bytes_in_buffer;
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
sftp->read_state = libssh2_NB_state_sent2;
|
||||
return rc;
|
||||
@@ -1475,7 +1514,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
if (rc32 == LIBSSH2_FX_EOF) {
|
||||
filep->eof = TRUE;
|
||||
return 0;
|
||||
return bytes_in_buffer;
|
||||
}
|
||||
else {
|
||||
sftp->last_errno = rc32;
|
||||
@@ -1485,6 +1524,16 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
break;
|
||||
|
||||
case SSH_FXP_DATA:
|
||||
if (chunk->offset != filep->offset) {
|
||||
/* This could happen if the server returns less bytes than
|
||||
requested, which shouldn't happen for normal files. See:
|
||||
http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
|
||||
#section-6.4
|
||||
*/
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"Read Packet At Unexpected Offset");
|
||||
}
|
||||
|
||||
rc32 = _libssh2_ntohu32(data + 5);
|
||||
if (rc32 > (data_len - 9))
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
@@ -1505,13 +1554,13 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
filep->offset_sent -= (chunk->len - rc32);
|
||||
}
|
||||
|
||||
if(rc32 > buffer_size) {
|
||||
if((bytes_in_buffer + rc32) > buffer_size) {
|
||||
/* figure out the overlap amount */
|
||||
filep->data_left = rc32 - buffer_size;
|
||||
filep->data_left = (bytes_in_buffer + rc32) - buffer_size;
|
||||
|
||||
/* getting the full packet would overflow the buffer, so
|
||||
only get the correct amount and keep the remainder */
|
||||
rc32 = (uint32_t)buffer_size;
|
||||
rc32 = (uint32_t)buffer_size - bytes_in_buffer;
|
||||
|
||||
/* store data to keep for next call */
|
||||
filep->data = data;
|
||||
@@ -1522,29 +1571,28 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
/* copy the received data from the received FXP_DATA packet to
|
||||
the buffer at the correct index */
|
||||
memcpy(buffer, data + 9, rc32);
|
||||
memcpy(sliding_bufferp, data + 9, rc32);
|
||||
filep->offset += rc32;
|
||||
bytes_in_buffer += rc32;
|
||||
sliding_bufferp += rc32;
|
||||
|
||||
if(filep->data_len == 0)
|
||||
/* free the allocated data if not stored to keep */
|
||||
LIBSSH2_FREE(session, data);
|
||||
|
||||
|
||||
/* remove the chunk we just processed keeping track of the
|
||||
* next one in case we need it */
|
||||
next = _libssh2_list_next(&chunk->node);
|
||||
_libssh2_list_remove(&chunk->node);
|
||||
LIBSSH2_FREE(session, chunk);
|
||||
chunk = NULL;
|
||||
|
||||
if(rc32 > 0) {
|
||||
/* we must return as we wrote some data to the buffer */
|
||||
return rc32;
|
||||
} else {
|
||||
/* A zero-byte read is not necessarily EOF so we must not
|
||||
* return 0 (that would signal EOF to the caller) so
|
||||
* instead we carry on to the next chunk */
|
||||
/* check if we have space left in the buffer
|
||||
* and either continue to the next chunk or stop
|
||||
*/
|
||||
if (bytes_in_buffer < buffer_size) {
|
||||
chunk = next;
|
||||
} else {
|
||||
chunk = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1555,13 +1603,18 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
if (bytes_in_buffer > 0)
|
||||
return bytes_in_buffer;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"State machine error; unrecognised read state");
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* we should never reach this point */
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"sftp_read() internal error");
|
||||
}
|
||||
|
||||
/* libssh2_sftp_read
|
||||
@@ -1827,7 +1880,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
||||
acked but we haven't been able to return as such yet, so we will
|
||||
get that data as well passed in here again.
|
||||
*/
|
||||
already = (handle->u.file.offset_sent - handle->u.file.offset)+
|
||||
already = (size_t) (handle->u.file.offset_sent - handle->u.file.offset)+
|
||||
handle->u.file.acked;
|
||||
|
||||
if(count >= already) {
|
||||
@@ -2346,15 +2399,15 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
||||
rc = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for FXP_CLOSE "
|
||||
"packet");
|
||||
} else {
|
||||
} else {
|
||||
|
||||
_libssh2_store_u32(&s, packet_len - 4);
|
||||
*(s++) = SSH_FXP_CLOSE;
|
||||
handle->close_request_id = sftp->request_id++;
|
||||
_libssh2_store_u32(&s, handle->close_request_id);
|
||||
_libssh2_store_str(&s, handle->handle, handle->handle_len);
|
||||
handle->close_state = libssh2_NB_state_created;
|
||||
}
|
||||
_libssh2_store_u32(&s, packet_len - 4);
|
||||
*(s++) = SSH_FXP_CLOSE;
|
||||
handle->close_request_id = sftp->request_id++;
|
||||
_libssh2_store_u32(&s, handle->close_request_id);
|
||||
_libssh2_store_str(&s, handle->handle, handle->handle_len);
|
||||
handle->close_state = libssh2_NB_state_created;
|
||||
}
|
||||
}
|
||||
|
||||
if (handle->close_state == libssh2_NB_state_created) {
|
||||
@@ -2367,7 +2420,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
||||
rc = _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send FXP_CLOSE command");
|
||||
} else
|
||||
handle->close_state = libssh2_NB_state_sent;
|
||||
handle->close_state = libssh2_NB_state_sent;
|
||||
|
||||
LIBSSH2_FREE(session, handle->close_packet);
|
||||
handle->close_packet = NULL;
|
||||
@@ -2394,15 +2447,15 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
||||
assert(rc);
|
||||
|
||||
} else {
|
||||
int retcode = _libssh2_ntohu32(data + 5);
|
||||
LIBSSH2_FREE(session, data);
|
||||
int retcode = _libssh2_ntohu32(data + 5);
|
||||
LIBSSH2_FREE(session, data);
|
||||
|
||||
if (retcode != LIBSSH2_FX_OK) {
|
||||
sftp->last_errno = retcode;
|
||||
handle->close_state = libssh2_NB_state_idle;
|
||||
rc = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"SFTP Protocol Error");
|
||||
}
|
||||
if (retcode != LIBSSH2_FX_OK) {
|
||||
sftp->last_errno = retcode;
|
||||
handle->close_state = libssh2_NB_state_idle;
|
||||
rc = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"SFTP Protocol Error");
|
||||
}
|
||||
}
|
||||
|
||||
/* remove this handle from the parent's list */
|
||||
@@ -2678,7 +2731,7 @@ static int sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_STATVFS *st)
|
||||
LIBSSH2_SESSION *session = channel->session;
|
||||
size_t data_len;
|
||||
/* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4)
|
||||
+ handle_len (4) */
|
||||
+ handle_len (4) */
|
||||
/* 20 = strlen ("fstatvfs@openssh.com") */
|
||||
uint32_t packet_len = handle->handle_len + 20 + 17;
|
||||
unsigned char *packet, *s, *data;
|
||||
@@ -2767,7 +2820,7 @@ static int sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_STATVFS *st)
|
||||
st->f_ffree = _libssh2_ntohu64(data + 53);
|
||||
st->f_favail = _libssh2_ntohu64(data + 61);
|
||||
st->f_fsid = _libssh2_ntohu64(data + 69);
|
||||
flag = _libssh2_ntohu64(data + 77);
|
||||
flag = (unsigned int)_libssh2_ntohu64(data + 77);
|
||||
st->f_namemax = _libssh2_ntohu64(data + 85);
|
||||
|
||||
st->f_flag = (flag & SSH_FXE_STATVFS_ST_RDONLY)
|
||||
@@ -2805,7 +2858,7 @@ static int sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
|
||||
LIBSSH2_SESSION *session = channel->session;
|
||||
size_t data_len;
|
||||
/* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4)
|
||||
+ path_len (4) */
|
||||
+ path_len (4) */
|
||||
/* 19 = strlen ("statvfs@openssh.com") */
|
||||
uint32_t packet_len = path_len + 19 + 17;
|
||||
unsigned char *packet, *s, *data;
|
||||
@@ -2893,13 +2946,13 @@ static int sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
|
||||
st->f_ffree = _libssh2_ntohu64(data + 53);
|
||||
st->f_favail = _libssh2_ntohu64(data + 61);
|
||||
st->f_fsid = _libssh2_ntohu64(data + 69);
|
||||
flag = _libssh2_ntohu64(data + 77);
|
||||
flag = (unsigned int)_libssh2_ntohu64(data + 77);
|
||||
st->f_namemax = _libssh2_ntohu64(data + 85);
|
||||
|
||||
st->f_flag = (flag & SSH_FXE_STATVFS_ST_RDONLY)
|
||||
? LIBSSH2_SFTP_ST_RDONLY : 0;
|
||||
? LIBSSH2_SFTP_ST_RDONLY : 0;
|
||||
st->f_flag |= (flag & SSH_FXE_STATVFS_ST_NOSUID)
|
||||
? LIBSSH2_SFTP_ST_NOSUID : 0;
|
||||
? LIBSSH2_SFTP_ST_NOSUID : 0;
|
||||
|
||||
LIBSSH2_FREE(session, data);
|
||||
return 0;
|
||||
@@ -3395,7 +3448,7 @@ LIBSSH2_API unsigned long
|
||||
libssh2_sftp_last_error(LIBSSH2_SFTP *sftp)
|
||||
{
|
||||
if(!sftp)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return sftp->last_errno;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@
|
||||
/* MAX_SFTP_READ_SIZE is how much data is asked for at max in each FXP_READ
|
||||
* packets.
|
||||
*/
|
||||
#define MAX_SFTP_READ_SIZE 2000
|
||||
#define MAX_SFTP_READ_SIZE 30000
|
||||
|
||||
struct sftp_pipeline_chunk {
|
||||
struct list_node node;
|
||||
libssh2_uint64_t offset; /* READ: offset at which to start reading
|
||||
WRITE: not used */
|
||||
size_t len; /* WRITE: size of the data to write
|
||||
READ: how many bytes that was asked for */
|
||||
size_t sent;
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "mac.h"
|
||||
|
||||
#define MAX_BLOCKSIZE 32 /* MUST fit biggest crypto block size we use/get */
|
||||
#define MAX_MACSIZE 20 /* MUST fit biggest MAC length we support */
|
||||
#define MAX_MACSIZE 64 /* MUST fit biggest MAC length we support */
|
||||
|
||||
#ifdef LIBSSH2DEBUG
|
||||
#define UNPRINTABLE_CHAR '.'
|
||||
|
||||
@@ -546,10 +546,6 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
while (!feof(fd) && 1 == fread(&c, 1, 1, fd) && c != '\r' && c != '\n') {
|
||||
pubkey_len++;
|
||||
}
|
||||
if (feof(fd)) {
|
||||
/* the last character was EOF */
|
||||
pubkey_len--;
|
||||
}
|
||||
rewind(fd);
|
||||
|
||||
if (pubkey_len <= 1) {
|
||||
@@ -720,6 +716,7 @@ sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
if(rc)
|
||||
return rc;
|
||||
|
||||
libssh2_prepare_iovec(&datavec, 1);
|
||||
datavec.iov_base = (void *)data;
|
||||
datavec.iov_len = data_len;
|
||||
|
||||
@@ -755,6 +752,7 @@ sign_fromfile(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
if(rc)
|
||||
return rc;
|
||||
|
||||
libssh2_prepare_iovec(&datavec, 1);
|
||||
datavec.iov_base = (void *)data;
|
||||
datavec.iov_len = data_len;
|
||||
|
||||
@@ -877,6 +875,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
||||
}
|
||||
|
||||
_libssh2_htonu32(buf, session->session_id_len);
|
||||
libssh2_prepare_iovec(datavec, 4);
|
||||
datavec[0].iov_base = (void *)buf;
|
||||
datavec[0].iov_len = 4;
|
||||
datavec[1].iov_base = (void *)session->session_id;
|
||||
|
||||
37
src/wincng.c
37
src/wincng.c
@@ -93,6 +93,14 @@
|
||||
#define BCRYPT_SHA1_ALGORITHM L"SHA1"
|
||||
#endif
|
||||
|
||||
#ifndef BCRYPT_SHA256_ALGORITHM
|
||||
#define BCRYPT_SHA256_ALGORITHM L"SHA256"
|
||||
#endif
|
||||
|
||||
#ifndef BCRYPT_SHA512_ALGORITHM
|
||||
#define BCRYPT_SHA512_ALGORITHM L"SHA512"
|
||||
#endif
|
||||
|
||||
#ifndef BCRYPT_RSA_ALGORITHM
|
||||
#define BCRYPT_RSA_ALGORITHM L"RSA"
|
||||
#endif
|
||||
@@ -211,6 +219,10 @@ _libssh2_wincng_init(void)
|
||||
BCRYPT_MD5_ALGORITHM, NULL, 0);
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHashSHA1,
|
||||
BCRYPT_SHA1_ALGORITHM, NULL, 0);
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHashSHA256,
|
||||
BCRYPT_SHA256_ALGORITHM, NULL, 0);
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHashSHA512,
|
||||
BCRYPT_SHA512_ALGORITHM, NULL, 0);
|
||||
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHmacMD5,
|
||||
BCRYPT_MD5_ALGORITHM, NULL,
|
||||
@@ -218,6 +230,12 @@ _libssh2_wincng_init(void)
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHmacSHA1,
|
||||
BCRYPT_SHA1_ALGORITHM, NULL,
|
||||
BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHmacSHA256,
|
||||
BCRYPT_SHA256_ALGORITHM, NULL,
|
||||
BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgHmacSHA512,
|
||||
BCRYPT_SHA512_ALGORITHM, NULL,
|
||||
BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
||||
|
||||
(void)BCryptOpenAlgorithmProvider(&_libssh2_wincng.hAlgRSA,
|
||||
BCRYPT_RSA_ALGORITHM, NULL, 0);
|
||||
@@ -264,8 +282,12 @@ _libssh2_wincng_free(void)
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgRNG, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHashMD5, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHashSHA1, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHashSHA256, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHashSHA512, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHmacMD5, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHmacSHA1, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHmacSHA256, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgHmacSHA512, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgRSA, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgDSA, 0);
|
||||
(void)BCryptCloseAlgorithmProvider(_libssh2_wincng.hAlgAES_CBC, 0);
|
||||
@@ -384,7 +406,7 @@ _libssh2_wincng_hash_final(_libssh2_wincng_hash_ctx *ctx,
|
||||
ctx->pbHashObject = NULL;
|
||||
ctx->dwHashObject = 0;
|
||||
|
||||
return ret;
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -393,16 +415,15 @@ _libssh2_wincng_hash(unsigned char *data, unsigned long datalen,
|
||||
unsigned char *hash, unsigned long hashlen)
|
||||
{
|
||||
_libssh2_wincng_hash_ctx ctx;
|
||||
int ret;
|
||||
|
||||
if (!_libssh2_wincng_hash_init(&ctx, hAlg, hashlen, NULL, 0)) {
|
||||
if (!_libssh2_wincng_hash_update(&ctx, data, datalen)) {
|
||||
if (!_libssh2_wincng_hash_final(&ctx, hash)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = _libssh2_wincng_hash_init(&ctx, hAlg, hashlen, NULL, 0);
|
||||
if (!ret) {
|
||||
ret = _libssh2_wincng_hash_update(&ctx, data, datalen);
|
||||
ret |= _libssh2_wincng_hash_final(&ctx, hash);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
40
src/wincng.h
40
src/wincng.h
@@ -51,6 +51,8 @@
|
||||
#define LIBSSH2_MD5 1
|
||||
|
||||
#define LIBSSH2_HMAC_RIPEMD 0
|
||||
#define LIBSSH2_HMAC_SHA256 1
|
||||
#define LIBSSH2_HMAC_SHA512 1
|
||||
|
||||
#define LIBSSH2_AES 1
|
||||
#define LIBSSH2_AES_CTR 0
|
||||
@@ -64,6 +66,8 @@
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define SHA_DIGEST_LENGTH 20
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
@@ -75,8 +79,12 @@ struct _libssh2_wincng_ctx {
|
||||
BCRYPT_ALG_HANDLE hAlgRNG;
|
||||
BCRYPT_ALG_HANDLE hAlgHashMD5;
|
||||
BCRYPT_ALG_HANDLE hAlgHashSHA1;
|
||||
BCRYPT_ALG_HANDLE hAlgHashSHA256;
|
||||
BCRYPT_ALG_HANDLE hAlgHashSHA512;
|
||||
BCRYPT_ALG_HANDLE hAlgHmacMD5;
|
||||
BCRYPT_ALG_HANDLE hAlgHmacSHA1;
|
||||
BCRYPT_ALG_HANDLE hAlgHmacSHA256;
|
||||
BCRYPT_ALG_HANDLE hAlgHmacSHA512;
|
||||
BCRYPT_ALG_HANDLE hAlgRSA;
|
||||
BCRYPT_ALG_HANDLE hAlgDSA;
|
||||
BCRYPT_ALG_HANDLE hAlgAES_CBC;
|
||||
@@ -103,6 +111,8 @@ void _libssh2_wincng_free(void);
|
||||
#define _libssh2_random(buf, len) \
|
||||
_libssh2_wincng_random(buf, len)
|
||||
|
||||
#define libssh2_prepare_iovec(vec, len) /* Empty. */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -132,6 +142,30 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
_libssh2_wincng_hash(data, datalen, _libssh2_wincng.hAlgHashSHA1, \
|
||||
hash, SHA_DIGEST_LENGTH)
|
||||
|
||||
#define libssh2_sha256_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_sha256_init(ctx) \
|
||||
(_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashSHA256, \
|
||||
SHA256_DIGEST_LENGTH, NULL, 0) == 0)
|
||||
#define libssh2_sha256_update(ctx, data, datalen) \
|
||||
_libssh2_wincng_hash_update(&ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_sha256_final(ctx, hash) \
|
||||
_libssh2_wincng_hash_final(&ctx, hash)
|
||||
#define libssh2_sha256(data, datalen, hash) \
|
||||
_libssh2_wincng_hash(data, datalen, _libssh2_wincng.hAlgHashSHA256, \
|
||||
hash, SHA256_DIGEST_LENGTH)
|
||||
|
||||
#define libssh2_sha512_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_sha512_init(ctx) \
|
||||
(_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashSHA512, \
|
||||
SHA512_DIGEST_LENGTH, NULL, 0) == 0)
|
||||
#define libssh2_sha512_update(ctx, data, datalen) \
|
||||
_libssh2_wincng_hash_update(&ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_sha512_final(ctx, hash) \
|
||||
_libssh2_wincng_hash_final(&ctx, hash)
|
||||
#define libssh2_sha512(data, datalen, hash) \
|
||||
_libssh2_wincng_hash(data, datalen, _libssh2_wincng.hAlgHashSHA512, \
|
||||
hash, SHA512_DIGEST_LENGTH)
|
||||
|
||||
#define libssh2_md5_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_md5_init(ctx) \
|
||||
(_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashMD5, \
|
||||
@@ -158,6 +192,12 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
MD5_DIGEST_LENGTH, key, keylen)
|
||||
#define libssh2_hmac_ripemd160_init(ctx, key, keylen)
|
||||
/* not implemented */
|
||||
#define libssh2_hmac_sha256_init(ctx, key, keylen) \
|
||||
_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHmacSHA256, \
|
||||
SHA256_DIGEST_LENGTH, key, keylen)
|
||||
#define libssh2_hmac_sha512_init(ctx, key, keylen) \
|
||||
_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHmacSHA512, \
|
||||
SHA512_DIGEST_LENGTH, key, keylen)
|
||||
#define libssh2_hmac_update(ctx, data, datalen) \
|
||||
_libssh2_wincng_hash_update(&ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_hmac_final(ctx, hash) \
|
||||
|
||||
111
tests/CMakeLists.txt
Normal file
111
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,111 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# 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(CheckIncludeFiles)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(BundleUtilities)
|
||||
include(CopyRuntimeDependencies)
|
||||
include(SocketLibraries)
|
||||
|
||||
## Platform checks
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
|
||||
check_include_files(windows.h HAVE_WINDOWS_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
||||
|
||||
set(TESTS
|
||||
simple
|
||||
ssh2)
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
foreach(test ${TESTS})
|
||||
add_executable(test-${test} ${test}.c)
|
||||
target_link_libraries(test-${test} libssh2 ${LIBRARIES})
|
||||
target_include_directories(test-${test} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
list(APPEND TEST_TARGETS test-${test})
|
||||
endforeach()
|
||||
|
||||
add_target_to_copy_dependencies(
|
||||
TARGET copy_test_dependencies
|
||||
DEPENDENCIES ${RUNTIME_DEPENDENCIES}
|
||||
BEFORE_TARGETS ${TEST_TARGETS})
|
||||
|
||||
# TODO convert mansyntax.sh into CMake script.
|
||||
# XXX Just because we can find all three programs, doesn't mean sh can
|
||||
# find man and grep
|
||||
find_program(SH_EXECUTABLE sh)
|
||||
find_program(MAN_EXECUTABLE man)
|
||||
find_program(GREP_EXECUTABLE grep)
|
||||
mark_as_advanced(SH_EXECUTABLE MAN_EXECUTABLE GREP_EXECUTABLE)
|
||||
if(SH_EXECUTABLE AND MAN_EXECUTABLE AND GREP_EXECUTABLE)
|
||||
set(cmd "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(cmd "${cmd} ${CMAKE_CURRENT_SOURCE_DIR}/mansyntax.sh")
|
||||
add_test(mansyntax ${SH_EXECUTABLE} -c "${cmd}")
|
||||
endif()
|
||||
|
||||
add_test(simple test-simple)
|
||||
|
||||
find_program(SSHD_EXECUTABLE sshd)
|
||||
find_program(CHMOD_EXECUTABLE chmod)
|
||||
find_program(KILL_EXECUTABLE kill)
|
||||
mark_as_advanced(SSHD_EXECUTABLE CHMOD_EXECUTABLE KILL_EXECUTABLE)
|
||||
if(SSHD_EXECUTABLE AND CHMOD_EXECUTABLE AND KILL_EXECUTABLE)
|
||||
set(SSHD_TEST_CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(TEST_NAME ssh2)
|
||||
|
||||
add_custom_command(
|
||||
TARGET test-${TEST_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/etc
|
||||
${SSHD_TEST_CONFIG_DIR}/etc)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sshd_fixture.sh.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test-${TEST_NAME}_fixture.sh
|
||||
@ONLY)
|
||||
|
||||
add_test(NAME ssh2 COMMAND ${SH_EXECUTABLE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test-${TEST_NAME}_fixture.sh
|
||||
$<TARGET_FILE:test-${TEST_NAME}>)
|
||||
|
||||
endif()
|
||||
@@ -14,6 +14,8 @@ endif
|
||||
check_PROGRAMS = $(ctests)
|
||||
|
||||
TESTS_ENVIRONMENT = SSHD=$(SSHD) EXEEXT=$(EXEEXT)
|
||||
TESTS_ENVIRONMENT += srcdir=$(top_srcdir)/tests builddir=$(top_builddir)/tests
|
||||
|
||||
EXTRA_DIST = ssh2.sh mansyntax.sh
|
||||
EXTRA_DIST += etc/host etc/host.pub etc/user etc/user.pub
|
||||
EXTRA_DIST += CMakeLists.txt libssh2_config_cmake.h.in sshd_fixture.sh.in
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -15,7 +15,17 @@
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -81,8 +91,6 @@ host_triplet = @host@
|
||||
@SSHD_TRUE@noinst_PROGRAMS = ssh2$(EXEEXT)
|
||||
@SSHD_TRUE@am__append_1 = ssh2.sh
|
||||
subdir = tests
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/depcomp $(top_srcdir)/test-driver
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -92,6 +100,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h \
|
||||
$(top_builddir)/example/libssh2_config.h
|
||||
@@ -375,6 +384,8 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log)
|
||||
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
|
||||
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
|
||||
$(TEST_LOG_FLAGS)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
|
||||
$(top_srcdir)/test-driver
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -508,6 +519,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -522,9 +534,11 @@ LDADD = ../src/libssh2.la
|
||||
ctests = simple$(EXEEXT)
|
||||
TESTS = $(ctests) mansyntax.sh $(am__append_1)
|
||||
check_PROGRAMS = $(ctests)
|
||||
TESTS_ENVIRONMENT = SSHD=$(SSHD) EXEEXT=$(EXEEXT)
|
||||
TESTS_ENVIRONMENT = SSHD=$(SSHD) EXEEXT=$(EXEEXT) \
|
||||
srcdir=$(top_srcdir)/tests builddir=$(top_builddir)/tests
|
||||
EXTRA_DIST = ssh2.sh mansyntax.sh etc/host etc/host.pub etc/user \
|
||||
etc/user.pub
|
||||
etc/user.pub CMakeLists.txt libssh2_config_cmake.h.in \
|
||||
sshd_fixture.sh.in
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
@@ -541,7 +555,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign tests/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -704,7 +717,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
|
||||
if test -n "$$am__remaking_logs"; then \
|
||||
echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
|
||||
"recursion detected" >&2; \
|
||||
else \
|
||||
elif test -n "$$redo_logs"; then \
|
||||
am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
|
||||
fi; \
|
||||
if $(am__make_dryrun); then :; else \
|
||||
@@ -1008,6 +1021,8 @@ uninstall-am:
|
||||
pdf pdf-am ps ps-am recheck tags tags-am uninstall \
|
||||
uninstall-am
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
43
tests/libssh2_config_cmake.h.in
Normal file
43
tests/libssh2_config_cmake.h.in
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Headers */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
#cmakedefine HAVE_ARPA_INET_H
|
||||
#cmakedefine HAVE_WINDOWS_H
|
||||
#cmakedefine HAVE_WINSOCK2_H
|
||||
@@ -6,7 +6,8 @@ set -e
|
||||
# Run syntax checks for all manpages in the documentation tree.
|
||||
#
|
||||
|
||||
srcdir="`cd $(dirname $0);pwd`"
|
||||
srcdir=${srcdir:-$PWD}
|
||||
dstdir=${builddir:-$PWD}
|
||||
mandir=${srcdir}/../docs
|
||||
|
||||
#
|
||||
@@ -19,13 +20,13 @@ fi
|
||||
|
||||
ec=0
|
||||
|
||||
trap "rm -f $srcdir/man3" EXIT
|
||||
trap "rm -f $dstdir/man3" EXIT
|
||||
|
||||
ln -sf "$mandir" "$srcdir/man3"
|
||||
ln -sf "$mandir" "$dstdir/man3"
|
||||
|
||||
for manpage in $mandir/libssh2_*.*; do
|
||||
echo "$manpage"
|
||||
warnings=$(LANG=en_US.UTF-8 MANWIDTH=80 man -M "$srcdir" --warnings \
|
||||
warnings=$(LANG=en_US.UTF-8 MANWIDTH=80 man -M "$dstdir" --warnings \
|
||||
-E UTF-8 -l "$manpage" 2>&1 >/dev/null)
|
||||
if [ -n "$warnings" ]; then
|
||||
echo "$warnings"
|
||||
|
||||
53
tests/sshd_fixture.sh.in
Normal file
53
tests/sshd_fixture.sh.in
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Written by Simon Josefsson.
|
||||
|
||||
# Start sshd, invoke parameters, saving exit code, kill sshd, and
|
||||
# return exit code.
|
||||
|
||||
srcdir="@SSHD_TEST_CONFIG_DIR@"
|
||||
SSHD="@SSHD_EXECUTABLE@"
|
||||
|
||||
cmd="\"$1\""
|
||||
|
||||
PRIVKEY=$srcdir/etc/user
|
||||
export PRIVKEY
|
||||
PUBKEY=$srcdir/etc/user.pub
|
||||
export PUBKEY
|
||||
|
||||
if test -n "$DEBUG"; then
|
||||
libssh2_sshd_params="-d -d"
|
||||
fi
|
||||
|
||||
chmod go-rwx "$srcdir"/etc/host*
|
||||
"$SSHD" -f /dev/null -h "$srcdir/etc/host" \
|
||||
-o 'Port 4711' \
|
||||
-o 'Protocol 2' \
|
||||
-o "AuthorizedKeysFile \"$srcdir/etc/user.pub\"" \
|
||||
-o 'UsePrivilegeSeparation no' \
|
||||
-o 'StrictModes no' \
|
||||
-D \
|
||||
$libssh2_sshd_params &
|
||||
sshdpid=$!
|
||||
|
||||
trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT
|
||||
|
||||
: "started sshd (${sshdpid})"
|
||||
|
||||
sleep 3
|
||||
|
||||
if ! kill -0 ${sshdpid}
|
||||
then
|
||||
echo "SSHD exited before test started"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: Invoking $cmd...
|
||||
eval "$cmd"
|
||||
ec=$?
|
||||
: Self-test exit code $ec
|
||||
|
||||
: "killing sshd (${sshdpid})"
|
||||
kill "${sshdpid}" > /dev/null 2>&1
|
||||
trap "" EXIT
|
||||
exit $ec
|
||||
@@ -8,7 +8,7 @@ LIBSSH2
|
||||
|
||||
LIBSSH2 is a client-side library written in C that aims to
|
||||
implement the SSH2 protocol. It is an open source project,
|
||||
to be found at http://libssh2.org.
|
||||
to be found at https://libssh2.org.
|
||||
|
||||
GNV
|
||||
---
|
||||
@@ -190,7 +190,7 @@ You will need to have the following available:
|
||||
|
||||
Optional:
|
||||
|
||||
- curl, to be found at http://curl.haxx.se
|
||||
- curl, to be found at https://curl.haxx.se
|
||||
You might want to use curl to download the libssh2 kit directly
|
||||
to you VMS machine. Interestingly, sftp in curl is implemented using
|
||||
libssh2, soon to be expected on VMS as well, hopefully.
|
||||
@@ -217,7 +217,7 @@ $ then
|
||||
$ delete libssh2-'libssh2_version'-'currentday'.tar.gz;*
|
||||
$ endif
|
||||
$!
|
||||
$ curl 'proxy_line' "http://libssh2.org/snapshots/libssh2-''libssh2_version'-''currentday'.tar.gz" -
|
||||
$ curl 'proxy_line' "https://libssh2.org/snapshots/libssh2-''libssh2_version'-''currentday'.tar.gz" -
|
||||
-o libssh2-'libssh2_version'-'currentday'.tar.gz
|
||||
$!
|
||||
$!
|
||||
|
||||
Reference in New Issue
Block a user