Compare commits

...

34 Commits

Author SHA1 Message Date
Andreas Schneider
254a166c02 Don't add the tests directory to the build. 2010-02-13 13:13:20 +01:00
Andreas Schneider
3e938cb901 Added ChangeLog entries for 0.4.1. 2010-02-13 13:00:10 +01:00
Andreas Schneider
452b16ede2 Set CFLAGS correctly. 2010-02-13 13:00:10 +01:00
Aris Adamantiadis
bd47ff75ba Fix compilation of opensolaris 2010-02-12 10:08:22 +01:00
Andreas Schneider
0016ded7f9 Try zlib compression and fallback to none if not available. 2010-02-11 23:28:37 +01:00
Aris Adamantiadis
d725b31752 Use closesocket in server.c for win32
Resolves #56
2010-02-11 19:54:57 +01:00
Aris Adamantiadis
c2e86c876c aes128-ctr aes192-ctr aes256-ctr for libgcrypt 2010-02-09 22:43:37 +01:00
Aris Adamantiadis
028516ba6a aes192-ctr and aes256-ctr working on libcrypto 2010-02-09 22:43:27 +01:00
Aris Adamantiadis
344b27ac6c Added aes128-ctr support for libcrypto (openssl) 2010-02-09 22:43:13 +01:00
Aris Adamantiadis
a700259b01 KEX bug: client preference should be prioritary 2010-02-09 22:42:53 +01:00
Andreas Schneider
14da14db05 Respect known_hosts file set by the user.
Thanks to contact@leblanc-simon.eu for the patch.
2010-02-07 22:39:35 +01:00
Vic Lee
474d63f24e The ssh_message object needs to be freed after processing in channel_accept().
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-02-01 17:24:50 +01:00
Andreas Schneider
b3589fbf6c Increased version number. 2010-01-29 18:59:55 +01:00
Aris Adamantiadis
dd68bae776 Fix underflow when leave_function() are unbalanced 2010-01-29 18:54:48 +01:00
Vic Lee
4768cf3e85 In handle_channel_request_open(), variable type is freed too early and cause memory corruptions.
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-01-29 18:51:50 +01:00
Vic Lee
5a95681f01 File handle need to be closed in case of errors in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-12-23 09:37:59 +01:00
Andreas Schneider
13a3619102 Added an example for exec. 2009-12-22 18:33:16 +01:00
Vic Lee
c7636edf84 Added private key type detection feature in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-12-22 08:58:05 +01:00
Andreas Schneider
27e332b623 Fixed ssh_get_user_home_dir() to be thread safe. 2009-12-21 12:33:44 +01:00
Andreas Schneider
ebc8544c56 Improved doxygen output of ssh_options_set(). 2009-12-19 00:11:37 +01:00
Andreas Schneider
0f8e9b839c Disabled caller graphs as they are only of internal interest. 2009-12-18 23:55:17 +01:00
Andreas Schneider
0c02d6effe Updated the doxygen file. 2009-12-18 23:49:56 +01:00
Andreas Schneider
7199b196b0 Fixed documentation of buffer struct. 2009-12-18 23:45:34 +01:00
Andreas Schneider
ca83b66066 Fixed documentation of ssh_options_copy(). 2009-12-18 23:45:24 +01:00
Andreas Schneider
d978f9b58a Moved the doxygen mainpage to doc/mainpage.dox 2009-12-18 23:45:09 +01:00
Andreas Schneider
e539eaf9e0 Added a mainpage to doxygen. 2009-12-18 23:11:25 +01:00
Andreas Schneider
b728f44ce9 Fixed the doxygen documentation. 2009-12-18 23:05:03 +01:00
Andreas Schneider
2f0b671a61 Update version to 0.4.0. 2009-12-10 14:15:04 +01:00
Andreas Schneider
1fadec37d6 Don't install crypto.h which is an internal header file. 2009-12-10 13:55:07 +01:00
Andreas Schneider
2aabbd6245 Remove socklen_t definition.
Tthe problem is that winsock2.h defines socklen_t as a typedef, not as a
define, so depending on the order of includes you can get errors in
ws2tcpip.h with msvc.
2009-12-09 13:04:26 +01:00
Aris Adamantiadis
fd6823691b Fix stupid bug which stops log_verbosity working 2009-12-02 14:19:42 +01:00
Andreas Schneider
b174ad8ae4 Fixed indent. 2009-12-02 00:23:27 +01:00
Andreas Schneider
176778bb1c Added gettimeofday for Windows.
Thanks to Patrick Spendrin.
2009-12-02 00:23:20 +01:00
Andreas Schneider
e5bf645010 Fixed uint* to work on Windows.
Thanks to Patrick Spendrin.
2009-12-02 00:23:00 +01:00
24 changed files with 483 additions and 303 deletions

View File

@@ -10,9 +10,11 @@ set(APPLICATION_VERSION "0.4.0")
set(APPLICATION_VERSION_MAJOR "0") set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "4") set(APPLICATION_VERSION_MINOR "4")
set(APPLICATION_VERSION_PATCH "0") set(APPLICATION_VERSION_PATCH "1")
set(LIBRARY_VERSION "4.0.0") set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}${APPLICATION_VERSION_MINOR}${APPLICATION_VERSION_PATCH}")
set(LIBRARY_VERSION "4.0.1")
set(LIBRARY_SOVERSION "4") set(LIBRARY_SOVERSION "4")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
@@ -61,7 +63,6 @@ configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(include) add_subdirectory(include)
add_subdirectory(libssh) add_subdirectory(libssh)
add_subdirectory(tests)
# build samples # build samples
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include)

View File

@@ -12,8 +12,8 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
### versions ### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "3") set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "91") set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

View File

@@ -1,7 +1,21 @@
ChangeLog ChangeLog
========== ==========
version 0.4 (released xxxx-xx-xx) version 0.4.1 (released 2010-02-13)
* Added support for aes128-ctr, aes192-ctr and aes256-ctr encryption.
* Added an example for exec.
* Added private key type detection feature in privatekey_from_file().
* Fixed zlib compression fallback.
* Fixed kex bug that client preference should be prioritary
* Fixed known_hosts file set by the user.
* Fixed a memleak in channel_accept().
* Fixed underflow when leave_function() are unbalanced
* Fixed memory corruption in handle_channel_request_open().
* Fixed closing of a file handle case of errors in privatekey_from_file().
* Fixed ssh_get_user_home_dir() to be thread safe.
* Fixed the doxygen documentation.
version 0.4.0 (released 2009-12-10)
* Added scp support. * Added scp support.
* Added support for sending signals (RFC 4254, section 6.9). * Added support for sending signals (RFC 4254, section 6.9).
* Added MSVC support. * Added MSVC support.

View File

@@ -3,27 +3,27 @@
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
if (UNIX AND NOT WIN32) if (UNIX AND NOT WIN32)
if (CMAKE_COMPILER_IS_GNUCC) if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
# add -Wconversion ? # add -Wconversion ?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute")
# with -fPIC # with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC) check_c_compiler_flag("-fPIC" WITH_FPIC)
if (WITH_FPIC) if (WITH_FPIC)
add_definitions(-fPIC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif (WITH_FPIC) endif (WITH_FPIC)
check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR) check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR) if (WITH_STACK_PROTECTOR)
add_definitions(-fstack-protector) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif (WITH_STACK_PROTECTOR) endif (WITH_STACK_PROTECTOR)
check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE) check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
if (WITH_FORTIFY_SOURCE) if (WITH_FORTIFY_SOURCE)
add_definitions(-D_FORTIFY_SOURCE=2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
endif (WITH_FORTIFY_SOURCE) endif (WITH_FORTIFY_SOURCE)
endif (CMAKE_COMPILER_IS_GNUCC) endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
if (CMAKE_SIZEOF_VOID_P MATCHES "8") if (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support # with large file support
@@ -48,12 +48,12 @@ if (UNIX AND NOT WIN32)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8") endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
if (_lfs_CFLAGS) if (_lfs_CFLAGS)
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}") string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
add_definitions(${_lfs_CFLAGS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
endif (_lfs_CFLAGS) endif (_lfs_CFLAGS)
endif (UNIX AND NOT WIN32) endif (UNIX AND NOT WIN32)
# suppress warning about "deprecated" functions # suppress warning about "deprecated" functions
if (MSVC) if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
endif (MSVC) endif (MSVC)

View File

@@ -1,4 +1,4 @@
# Doxyfile 1.5.8 # Doxyfile 1.5.6
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project # doxygen (www.doxygen.org) for a project
@@ -57,8 +57,8 @@ CREATE_SUBDIRS = NO
# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, # Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), # Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, # Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish,
# Spanish, Swedish, and Ukrainian. # and Ukrainian.
OUTPUT_LANGUAGE = English OUTPUT_LANGUAGE = English
@@ -165,6 +165,13 @@ QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO MULTILINE_CPP_IS_BRIEF = NO
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
# will output the detailed description near the top, like JavaDoc.
# If set to NO, the detailed description appears after the member
# documentation.
DETAILS_AT_TOP = YES
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it # member inherits the documentation from any documented member that it
# re-implements. # re-implements.
@@ -217,17 +224,6 @@ OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO OPTIMIZE_OUTPUT_VHDL = NO
# Doxygen selects the parser to use depending on the extension of the files it parses.
# With this tag you can assign which parser to use for a given extension.
# Doxygen has a built-in mapping, but you can override or extend it using this tag.
# The format is ext=language, where ext is a file extension, and language is one of
# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
# use: inc=Fortran f=C
EXTENSION_MAPPING =
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should # to include (a tag file for) the STL sources as input, then you should
# set this tag to YES in order to let doxygen match functions declarations and # set this tag to YES in order to let doxygen match functions declarations and
@@ -237,7 +233,7 @@ EXTENSION_MAPPING =
BUILTIN_STL_SUPPORT = NO BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to # If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support. # enable parsing support.
CPP_CLI_SUPPORT = NO CPP_CLI_SUPPORT = NO
@@ -280,23 +276,7 @@ SUBGROUPING = YES
# be useful for C code in case the coding convention dictates that all compound # be useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name. # types are typedef'ed and only the typedef is referenced, never the tag name.
TYPEDEF_HIDES_STRUCT = NO TYPEDEF_HIDES_STRUCT = YES
# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
# determine which symbols to keep in memory and which to flush to disk.
# When the cache is full, less often used symbols will be written to disk.
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
# causing a significant performance penality.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will rougly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols
SYMBOL_CACHE_SIZE = 0
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Build related configuration options # Build related configuration options
@@ -425,7 +405,7 @@ SORT_GROUP_NAMES = NO
# sorted by fully-qualified names, including namespaces. If set to # sorted by fully-qualified names, including namespaces. If set to
# NO (the default), the class list will be sorted only by class name, # NO (the default), the class list will be sorted only by class name,
# not including the namespace part. # not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the # Note: This option applies only to the class list, not to the
# alphabetical list. # alphabetical list.
@@ -482,15 +462,14 @@ SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO SHOW_DIRECTORIES = NO
# Set the SHOW_FILES tag to NO to disable the generation of the Files page. # Set the SHOW_FILES tag to NO to disable the generation of the Files page.
# This will remove the Files entry from the Quick Index and from the # This will remove the Files entry from the Quick Index and from the
# Folder Tree View (if specified). The default is YES. # Folder Tree View (if specified). The default is YES.
SHOW_FILES = YES SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Set the SHOW_NAMESPACES tag to NO to disable the generation of the
# Namespaces page. # Namespaces page. This will remove the Namespaces entry from the Quick Index
# This will remove the Namespaces entry from the Quick Index
# and from the Folder Tree View (if specified). The default is YES. # and from the Folder Tree View (if specified). The default is YES.
SHOW_NAMESPACES = YES SHOW_NAMESPACES = YES
@@ -505,15 +484,6 @@ SHOW_NAMESPACES = YES
FILE_VERSION_FILTER = FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
# doxygen. The layout file controls the global structure of the generated output files
# in an output format independent way. The create the layout file that represents
# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
LAYOUT_FILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to warning and progress messages # configuration options related to warning and progress messages
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -575,7 +545,8 @@ WARN_LOGFILE = @CMAKE_CURRENT_BINARY_DIR@/doxy.log
# with spaces. # with spaces.
INPUT = @CMAKE_SOURCE_DIR@/include \ INPUT = @CMAKE_SOURCE_DIR@/include \
@CMAKE_SOURCE_DIR@/libssh @CMAKE_SOURCE_DIR@/libssh \
@CMAKE_SOURCE_DIR@/doc
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -642,18 +613,15 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see # directories that contain example code fragments that are included (see
# the \include command). # the \include command).
EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/tests \ EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/examples
@CMAKE_SOURCE_DIR@
# If the value of the EXAMPLE_PATH tag contains directories, you can use the # If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left # and *.h) to filter out the source-files in the directories. If left
# blank all files are included. # blank all files are included.
EXAMPLE_PATTERNS = *.cpp \ EXAMPLE_PATTERNS = *.c \
*.cc \
*.h \ *.h \
*.hh \
INSTALL \ INSTALL \
DEPENDENCIES \ DEPENDENCIES \
CHANGELOG \ CHANGELOG \
@@ -678,17 +646,14 @@ IMAGE_PATH =
# by executing (via popen()) the command <filter> <input-file>, where <filter> # by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an # is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes # input file. Doxygen will then use the output that the filter program writes
# to standard output. # to standard output. If FILTER_PATTERNS is specified, this tag will be
# If FILTER_PATTERNS is specified, this tag will be
# ignored. # ignored.
INPUT_FILTER = INPUT_FILTER =
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis. # basis. Doxygen will compare the file name with each pattern and apply the
# Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form:
# filter if there is a match.
# The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
# is applied to all files. # is applied to all files.
@@ -735,11 +700,10 @@ REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES REFERENCES_RELATION = YES
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
# link to the source code. # link to the source code. Otherwise they will link to the documentstion.
# Otherwise they will link to the documentation.
REFERENCES_LINK_SOURCE = YES REFERENCES_LINK_SOURCE = YES
@@ -828,13 +792,12 @@ HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES HTML_ALIGN_MEMBERS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # If the GENERATE_HTMLHELP tag is set to YES, additional index files
# documentation will contain sections that can be hidden and shown after the # will be generated that can be used as input for tools like the
# page has loaded. For this to work a browser that supports # Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # of the generated HTML documentation.
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
HTML_DYNAMIC_SECTIONS = NO GENERATE_HTMLHELP = NO
# If the GENERATE_DOCSET tag is set to YES, additional index files # If the GENERATE_DOCSET tag is set to YES, additional index files
# will be generated that can be used as input for Apple's Xcode 3 # will be generated that can be used as input for Apple's Xcode 3
@@ -843,8 +806,7 @@ HTML_DYNAMIC_SECTIONS = NO
# HTML output directory. Running make will produce the docset in that # HTML output directory. Running make will produce the docset in that
# directory and running "make install" will install the docset in # directory and running "make install" will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
# it at startup. # it at startup.
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
GENERATE_DOCSET = NO GENERATE_DOCSET = NO
@@ -862,12 +824,13 @@ DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_BUNDLE_ID = org.doxygen.Project
# If the GENERATE_HTMLHELP tag is set to YES, additional index files # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# will be generated that can be used as input for tools like the # documentation will contain sections that can be hidden and shown after the
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # page has loaded. For this to work a browser that supports
# of the generated HTML documentation. # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
GENERATE_HTMLHELP = NO HTML_DYNAMIC_SECTIONS = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You # be used to specify the file name of the resulting .chm file. You
@@ -889,8 +852,8 @@ HHC_LOCATION =
GENERATE_CHI = NO GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file # is used to encode HtmlHelp index (hhk), content (hhc) and project file
# content. # content.
CHM_INDEX_ENCODING = CHM_INDEX_ENCODING =
@@ -906,55 +869,6 @@ BINARY_TOC = NO
TOC_EXPAND = NO TOC_EXPAND = NO
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
# are set, an additional index file will be generated that can be used as input for
# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
# HTML documentation.
GENERATE_QHP = NO
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
QHP_NAMESPACE =
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = doc
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
# For more information please see
# http://doc.trolltech.com/qthelpproject.html#custom-filters
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
# filter section matches.
# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
QHP_SECT_FILTER_ATTRS =
# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
# be used to specify the location of Qt's qhelpgenerator.
# If non-empty doxygen will try to run qhelpgenerator on the generated
# .qhp file.
QHG_LOCATION =
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at # The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and # top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it. # the value YES disables it.
@@ -966,19 +880,19 @@ DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4 ENUM_VALUES_PER_LINE = 4
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. # structure should be generated to display hierarchical information.
# If the tag value is set to FRAME, a side panel will be generated # If the tag value is set to FRAME, a side panel will be generated
# containing a tree-like index structure (just like the one that # containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports # is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature. Other possible values # probably better off using the HTML help feature. Other possible values
# for this tag are: HIERARCHIES, which will generate the Groups, Directories, # for this tag are: HIERARCHIES, which will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list; # and Class Hiererachy pages using a tree view instead of an ordered list;
# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
# disables this behavior completely. For backwards compatibility with previous # disables this behavior completely. For backwards compatibility with previous
# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
# respectively. # respectively.
GENERATE_TREEVIEW = NO GENERATE_TREEVIEW = NO
@@ -1209,10 +1123,8 @@ GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader. # nicely formatted so it can be parsed by a human reader. This is useful
# This is useful # if you want to understand what is going on. On the other hand, if this
# if you want to understand what is going on.
# On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller # tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same. # and Perl will parse it just the same.
@@ -1299,16 +1211,14 @@ SKIP_FUNCTION_MACROS = YES
# Optionally an initial location of the external documentation # Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without # can be added for each tagfile. The format of a tag file without
# this location is as follows: # this location is as follows:
# # TAGFILES = file1 file2 ...
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows: # Adding location for the tag files is done as follows:
# # TAGFILES = file1=loc1 "file2 = loc2" ...
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or # where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool # URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links. # does not have to be run to correct the links.
# Note that each tag file must have a unique name # Note that each tag file must have a unique name
# (where the name does NOT include the path) # (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen # If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here. # is run, you must also specify the path to the tagfile here.
@@ -1382,11 +1292,6 @@ HAVE_DOT = @DOXYGEN_DOT_FOUND@
DOT_FONTNAME = FreeSans DOT_FONTNAME = FreeSans
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
DOT_FONTSIZE = 10
# By default doxygen will tell dot to use the output directory to look for the # By default doxygen will tell dot to use the output directory to look for the
# FreeSans.ttf font (which doxygen will put there itself). If you specify a # FreeSans.ttf font (which doxygen will put there itself). If you specify a
# different font using DOT_FONTNAME you can set the path where dot # different font using DOT_FONTNAME you can set the path where dot
@@ -1429,7 +1334,7 @@ TEMPLATE_RELATIONS = YES
# file showing the direct and indirect include dependencies of the file with # file showing the direct and indirect include dependencies of the file with
# other documented files. # other documented files.
INCLUDE_GRAPH = YES INCLUDE_GRAPH = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
@@ -1444,7 +1349,7 @@ INCLUDED_BY_GRAPH = YES
# the time of a run. So in most cases it will be better to enable call graphs # the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command. # for selected functions only using the \callgraph command.
CALL_GRAPH = YES CALL_GRAPH = NO
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function # doxygen will generate a caller dependency graph for every global function
@@ -1452,7 +1357,7 @@ CALL_GRAPH = YES
# the time of a run. So in most cases it will be better to enable caller # the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command. # graphs for selected functions only using the \callergraph command.
CALLER_GRAPH = YES CALLER_GRAPH = NO
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one. # will graphical hierarchy of all classes instead of a textual one.
@@ -1461,13 +1366,13 @@ GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
# then doxygen will show the dependencies a directory has on other directories # then doxygen will show the dependencies a directory has on other directories
# in a graphical way. The dependency relations are determined by the #include # in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories. # relations between the files in the directories.
DIRECTORY_GRAPH = YES DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif # generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used. # If left blank png will be used.
DOT_IMAGE_FORMAT = png DOT_IMAGE_FORMAT = png
@@ -1504,10 +1409,10 @@ DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 0 MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not # background. This is enabled by default, which results in a transparent
# seem to support this out of the box. Warning: Depending on the platform used, # background. Warning: Depending on the platform used, enabling this option
# enabling this option may lead to badly anti-aliased labels on the edges of # may lead to badly anti-aliased labels on the edges of a graph (i.e. they
# a graph (i.e. they become hard to read). # become hard to read).
DOT_TRANSPARENT = NO DOT_TRANSPARENT = NO
@@ -1531,7 +1436,7 @@ GENERATE_LEGEND = YES
DOT_CLEANUP = YES DOT_CLEANUP = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Options related to the search engine # Configuration::additions related to the search engine
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be # The SEARCHENGINE tag specifies whether or not a search engine should be

12
doc/mainpage.dox Normal file
View File

@@ -0,0 +1,12 @@
/**
* @mainpage
* This manual documents the libssh C API.
*
* There are several other places to look for libssh information, such as the
* <a href="http://dev.libssh.org/wiki/Tutorial" target="_blank">tutorial</a>
* and the specification; those can be found at the <a
* href="http://www.libssh.org/" target="_blank">libssh website</a>.
*
* To be continued...
*/

View File

@@ -14,10 +14,12 @@ include_directories(
add_executable(libssh_scp libssh_scp.c ${examples_SRCS}) add_executable(libssh_scp libssh_scp.c ${examples_SRCS})
add_executable(scp_download scp_download.c ${examples_SRCS}) add_executable(scp_download scp_download.c ${examples_SRCS})
add_executable(samplessh sample.c ${examples_SRCS}) add_executable(samplessh sample.c ${examples_SRCS})
add_executable(exec exec.c ${examples_SRCS})
target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY}) target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY}) target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY}) target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(exec ${LIBSSH_SHARED_LIBRARY})
include_directories( include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS} ${LIBSSH_PUBLIC_INCLUDE_DIRS}

67
examples/exec.c Normal file
View File

@@ -0,0 +1,67 @@
/* simple exec example */
#include <stdio.h>
#include <libssh/libssh.h>
#include "examples_common.h"
int main(void) {
ssh_session session;
ssh_channel channel;
ssh_buffer buf;
int rc;
session = connect_ssh("localhost", NULL, 0);
if (session == NULL) {
return 1;
}
channel = channel_new(session);;
if (channel == NULL) {
ssh_disconnect(session);
ssh_finalize();
return 1;
}
rc = channel_open_session(channel);
if (rc < 0) {
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 1;
}
rc = channel_request_exec(channel, "ps aux");
if (rc < 0) {
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 1;
}
if (channel_is_open(channel)) {
while (channel_poll(channel, 0) >= 0) {
buf = buffer_new();
rc = channel_read_buffer(channel, buf, 0, 0);
if (rc < 0) {
buffer_free(buf);
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 1;
}
printf("%s\n", (char *) buffer_get(buf));
buffer_free(buf);
}
}
channel_send_eof(channel);
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 0;
}

View File

@@ -3,7 +3,6 @@ project(libssh-headers C)
set(libssh_HDRS set(libssh_HDRS
callbacks.h callbacks.h
libssh.h libssh.h
crypto.h
ssh2.h ssh2.h
) )

View File

@@ -22,8 +22,7 @@
#ifndef BUFFER_H_ #ifndef BUFFER_H_
#define BUFFER_H_ #define BUFFER_H_
/** Describes a buffer state at a moment /* Describes a buffer state */
*/
struct ssh_buffer_struct { struct ssh_buffer_struct {
char *data; char *data;
uint32_t used; uint32_t used;

View File

@@ -50,6 +50,7 @@
#ifdef _MSC_VER #ifdef _MSC_VER
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */ /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
@@ -78,7 +79,7 @@
/* libssh version */ /* libssh version */
#define LIBSSH_VERSION_MAJOR 0 #define LIBSSH_VERSION_MAJOR 0
#define LIBSSH_VERSION_MINOR 4 #define LIBSSH_VERSION_MINOR 4
#define LIBSSH_VERSION_MICRO 0 #define LIBSSH_VERSION_MICRO 1
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \ LIBSSH_VERSION_MINOR, \

View File

@@ -7,7 +7,7 @@
#ifdef WITH_PCAP #ifdef WITH_PCAP
typedef struct ssh_pcap_context_struct* ssh_pcap_context; typedef struct ssh_pcap_context_struct* ssh_pcap_context;
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, u_int32_t original_len); int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
ssh_pcap_context ssh_pcap_context_new(ssh_session session); ssh_pcap_context ssh_pcap_context_new(ssh_session session);
void ssh_pcap_context_free(ssh_pcap_context ctx); void ssh_pcap_context_free(ssh_pcap_context ctx);
@@ -18,7 +18,7 @@ enum ssh_pcap_direction{
}; };
void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file); void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file);
int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data, int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data,
u_int32_t len, u_int32_t origlen); uint32_t len, uint32_t origlen);
#endif /* WITH_PCAP */ #endif /* WITH_PCAP */

View File

@@ -77,7 +77,7 @@ typedef struct kex_struct {
struct error_struct { struct error_struct {
/* error handling */ /* error handling */
int error_code; unsigned int error_code;
char error_buffer[ERROR_BUFFERLEN]; char error_buffer[ERROR_BUFFERLEN];
}; };
@@ -185,6 +185,11 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
/* log.c */ /* log.c */
/* misc.c */
#ifdef _WIN32
int gettimeofday(struct timeval *__p, void *__t);
#endif /* _WIN32 */
#ifndef __FUNCTION__ #ifndef __FUNCTION__
#if defined(__SUNPRO_C) #if defined(__SUNPRO_C)
#define __FUNCTION__ __func__ #define __FUNCTION__ __func__

View File

@@ -1359,6 +1359,7 @@ static ssh_channel channel_accept(ssh_session session, int channeltype,
}; };
#endif #endif
ssh_message msg = NULL; ssh_message msg = NULL;
ssh_channel channel = NULL;
struct ssh_iterator *iterator; struct ssh_iterator *iterator;
int t; int t;
@@ -1373,7 +1374,9 @@ static ssh_channel channel_accept(ssh_session session, int channeltype,
if (ssh_message_type(msg) == SSH_REQUEST_CHANNEL_OPEN && if (ssh_message_type(msg) == SSH_REQUEST_CHANNEL_OPEN &&
ssh_message_subtype(msg) == channeltype) { ssh_message_subtype(msg) == channeltype) {
ssh_list_remove(session->ssh_message_list, iterator); ssh_list_remove(session->ssh_message_list, iterator);
return ssh_message_channel_request_open_reply_accept(msg); channel = ssh_message_channel_request_open_reply_accept(msg);
ssh_message_free(msg);
return channel;
} }
iterator = iterator->next; iterator = iterator->next;
} }

View File

@@ -227,8 +227,8 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
i = ssh_config_get_yesno(&s, -1); i = ssh_config_get_yesno(&s, -1);
if (i >= 0 && *parsing) { if (i >= 0 && *parsing) {
if (i) { if (i) {
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib,none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib,none");
} else { } else {
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none");

View File

@@ -341,7 +341,6 @@ socket_t ssh_connect_host(ssh_session session, const char *host,
ssh_set_error(session, SSH_FATAL, "Connect failed: %s", strerror(errno)); ssh_set_error(session, SSH_FATAL, "Connect failed: %s", strerror(errno));
ssh_connect_socket_close(s); ssh_connect_socket_close(s);
s = -1; s = -1;
leave_function();
continue; continue;
} else { } else {
/* We are connected */ /* We are connected */

View File

@@ -43,7 +43,7 @@
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
#define BLOWFISH "blowfish-cbc," #define BLOWFISH "blowfish-cbc,"
#define AES "aes256-cbc,aes192-cbc,aes128-cbc," #define AES "aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,"
#define DES "3des-cbc" #define DES "3des-cbc"
#elif defined HAVE_LIBCRYPTO #elif defined HAVE_LIBCRYPTO
#ifdef HAVE_OPENSSL_BLOWFISH_H #ifdef HAVE_OPENSSL_BLOWFISH_H
@@ -52,7 +52,7 @@
#define BLOWFISH "" #define BLOWFISH ""
#endif #endif
#ifdef HAVE_OPENSSL_AES_H #ifdef HAVE_OPENSSL_AES_H
#define AES "aes256-cbc,aes192-cbc,aes128-cbc," #define AES "aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,"
#else #else
#define AES "" #define AES ""
#endif #endif
@@ -67,7 +67,7 @@
const char *default_methods[] = { const char *default_methods[] = {
"diffie-hellman-group1-sha1", "diffie-hellman-group1-sha1",
"ssh-dss,ssh-rsa", "ssh-rsa,ssh-dss",
AES BLOWFISH DES, AES BLOWFISH DES,
AES BLOWFISH DES, AES BLOWFISH DES,
"hmac-sha1", "hmac-sha1",
@@ -81,7 +81,7 @@ const char *default_methods[] = {
const char *supported_methods[] = { const char *supported_methods[] = {
"diffie-hellman-group1-sha1", "diffie-hellman-group1-sha1",
"ssh-dss,ssh-rsa", "ssh-rsa,ssh-dss",
AES BLOWFISH DES, AES BLOWFISH DES,
AES BLOWFISH DES, AES BLOWFISH DES,
"hmac-sha1", "hmac-sha1",
@@ -218,19 +218,19 @@ char *ssh_find_matching(const char *in_d, const char *what_d){
SAFE_FREE(tok_in); SAFE_FREE(tok_in);
} }
for(i_in=0; tok_in[i_in]; ++i_in){ for(i_what=0; tok_what[i_what] ; ++i_what){
for(i_what=0; tok_what[i_what] ; ++i_what){ for(i_in=0; tok_in[i_in]; ++i_in){
if(!strcmp(tok_in[i_in],tok_what[i_what])){ if(!strcmp(tok_in[i_in],tok_what[i_what])){
/* match */ /* match */
ret=strdup(tok_in[i_in]); ret=strdup(tok_in[i_in]);
/* free the tokens */ /* free the tokens */
free(tok_in[0]); free(tok_in[0]);
free(tok_what[0]); free(tok_what[0]);
free(tok_in); free(tok_in);
free(tok_what); free(tok_what);
return ret; return ret;
}
} }
}
} }
free(tok_in[0]); free(tok_in[0]);
free(tok_what[0]); free(tok_what[0]);

View File

@@ -59,15 +59,15 @@
#endif /* HAVE_LIBCRYPTO */ #endif /* HAVE_LIBCRYPTO */
#define MAXLINESIZE 80 #define MAXLINESIZE 80
#define RSA_HEADER_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
#define RSA_HEADER_END "-----END RSA PRIVATE KEY-----"
#define DSA_HEADER_BEGIN "-----BEGIN DSA PRIVATE KEY-----"
#define DSA_HEADER_END "-----END DSA PRIVATE KEY-----"
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
#define MAX_KEY_SIZE 32 #define MAX_KEY_SIZE 32
#define MAX_PASSPHRASE_SIZE 1024 #define MAX_PASSPHRASE_SIZE 1024
#define RSA_HEADER_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
#define RSA_HEADER_END "-----END RSA PRIVATE KEY-----"
#define DSA_HEADER_BEGIN "-----BEGIN DSA PRIVATE KEY-----"
#define DSA_HEADER_END "-----END DSA PRIVATE KEY-----"
#define ASN1_INTEGER 2 #define ASN1_INTEGER 2
#define ASN1_SEQUENCE 48 #define ASN1_SEQUENCE 48
#define PKCS5_SALT_LEN 8 #define PKCS5_SALT_LEN 8
@@ -611,6 +611,22 @@ static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
} }
#endif /* HAVE_LIBCRYPTO */ #endif /* HAVE_LIBCRYPTO */
static int privatekey_type_from_file(FILE *fp) {
char buffer[MAXLINESIZE] = {0};
if (!fgets(buffer, MAXLINESIZE, fp)) {
return 0;
}
fseek(fp, 0, SEEK_SET);
if (strncmp(buffer, DSA_HEADER_BEGIN, strlen(DSA_HEADER_BEGIN)) == 0) {
return TYPE_DSS;
}
if (strncmp(buffer, RSA_HEADER_BEGIN, strlen(RSA_HEADER_BEGIN)) == 0) {
return TYPE_RSA;
}
return 0;
}
/** \addtogroup ssh_auth /** \addtogroup ssh_auth
* @{ * @{
*/ */
@@ -618,7 +634,7 @@ static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
/** \brief Reads a SSH private key from a file /** \brief Reads a SSH private key from a file
* \param session SSH Session * \param session SSH Session
* \param filename Filename containing the private key * \param filename Filename containing the private key
* \param type Type of the private key. One of TYPE_DSS or TYPE_RSA. * \param type Type of the private key. One of TYPE_DSS or TYPE_RSA. Pass 0 to automatically detect the type.
* \param passphrase Passphrase to decrypt the private key. Set to null if none is needed or it is unknown. * \param passphrase Passphrase to decrypt the private key. Set to null if none is needed or it is unknown.
* \returns a PRIVATE_KEY object containing the private key, or NULL if it failed. * \returns a PRIVATE_KEY object containing the private key, or NULL if it failed.
* \see privatekey_free() * \see privatekey_free()
@@ -649,6 +665,15 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
ssh_log(session, SSH_LOG_RARE, "Trying to read %s, passphase=%s, authcb=%s", ssh_log(session, SSH_LOG_RARE, "Trying to read %s, passphase=%s, authcb=%s",
filename, passphrase ? "true" : "false", filename, passphrase ? "true" : "false",
session->callbacks && session->callbacks->auth_function ? "true" : "false"); session->callbacks && session->callbacks->auth_function ? "true" : "false");
if (type == 0) {
type = privatekey_type_from_file(file);
if (type == 0) {
fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key file.");
return NULL;
}
}
switch (type) { switch (type) {
case TYPE_DSS: case TYPE_DSS:
if (passphrase == NULL) { if (passphrase == NULL) {
@@ -731,6 +756,7 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
} }
break; break;
default: default:
fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type); ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type);
return NULL; return NULL;
} /* switch */ } /* switch */
@@ -1474,9 +1500,11 @@ int ssh_write_knownhost(ssh_session session) {
char *dir; char *dir;
size_t len = 0; size_t len = 0;
if (ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, NULL) < 0) { if (session->knownhosts == NULL) {
ssh_set_error(session, SSH_FATAL, "Cannot find known_hosts file."); if (ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, NULL) < 0) {
return -1; ssh_set_error(session, SSH_FATAL, "Can't find a known_hosts file");
return -1;
}
} }
if (session->host == NULL) { if (session->host == NULL) {

View File

@@ -319,7 +319,6 @@ static ssh_message handle_channel_request_open(ssh_session session) {
ssh_log(session, SSH_LOG_PACKET, ssh_log(session, SSH_LOG_PACKET,
"Clients wants to open a %s channel", type_c); "Clients wants to open a %s channel", type_c);
string_free(type);
buffer_get_u32(session->in_buffer, &sender); buffer_get_u32(session->in_buffer, &sender);
buffer_get_u32(session->in_buffer, &window); buffer_get_u32(session->in_buffer, &window);
@@ -331,6 +330,7 @@ static ssh_message handle_channel_request_open(ssh_session session) {
if (strcmp(type_c,"session") == 0) { if (strcmp(type_c,"session") == 0) {
msg->channel_request_open.type = SSH_CHANNEL_SESSION; msg->channel_request_open.type = SSH_CHANNEL_SESSION;
string_free(type);
SAFE_FREE(type_c); SAFE_FREE(type_c);
leave_function(); leave_function();
return msg; return msg;
@@ -370,6 +370,7 @@ static ssh_message handle_channel_request_open(ssh_session session) {
msg->channel_request_open.originator_port = ntohl(originator_port); msg->channel_request_open.originator_port = ntohl(originator_port);
msg->channel_request_open.type = SSH_CHANNEL_DIRECT_TCPIP; msg->channel_request_open.type = SSH_CHANNEL_DIRECT_TCPIP;
string_free(type);
SAFE_FREE(type_c); SAFE_FREE(type_c);
leave_function(); leave_function();
return msg; return msg;
@@ -409,6 +410,7 @@ static ssh_message handle_channel_request_open(ssh_session session) {
msg->channel_request_open.originator_port = ntohl(originator_port); msg->channel_request_open.originator_port = ntohl(originator_port);
msg->channel_request_open.type = SSH_CHANNEL_FORWARDED_TCPIP; msg->channel_request_open.type = SSH_CHANNEL_FORWARDED_TCPIP;
string_free(type);
SAFE_FREE(type_c); SAFE_FREE(type_c);
leave_function(); leave_function();
return msg; return msg;
@@ -432,12 +434,14 @@ static ssh_message handle_channel_request_open(ssh_session session) {
msg->channel_request_open.originator_port = ntohl(originator_port); msg->channel_request_open.originator_port = ntohl(originator_port);
msg->channel_request_open.type = SSH_CHANNEL_X11; msg->channel_request_open.type = SSH_CHANNEL_X11;
string_free(type);
SAFE_FREE(type_c); SAFE_FREE(type_c);
leave_function(); leave_function();
return msg; return msg;
} }
msg->channel_request_open.type = SSH_CHANNEL_UNKNOWN; msg->channel_request_open.type = SSH_CHANNEL_UNKNOWN;
string_free(type);
SAFE_FREE(type_c); SAFE_FREE(type_c);
leave_function(); leave_function();

View File

@@ -38,6 +38,8 @@
#include <shlobj.h> #include <shlobj.h>
#include <direct.h> #include <direct.h>
#else #else
/* This is needed for a standard getpwuid_r on opensolaris */
#define _POSIX_PTHREAD_SEMANTICS
#include <pwd.h> #include <pwd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
@@ -87,25 +89,48 @@ char *ssh_get_user_home_dir(void) {
return NULL; return NULL;
} }
/* we have read access on file */ /* we have read access on file */
int ssh_file_readaccess_ok(const char *file) { int ssh_file_readaccess_ok(const char *file) {
if (_access(file, 4) < 0) { if (_access(file, 4) < 0) {
return 0; return 0;
} }
return 1; return 1;
} }
#define SSH_USEC_IN_SEC 1000000LL
#define SSH_SECONDS_SINCE_1601 11644473600LL
int gettimeofday(struct timeval *__p, void *__t) {
union {
unsigned long long ns100; /* time since 1 Jan 1601 in 100ns units */
FILETIME ft;
} now;
GetSystemTimeAsFileTime (&now.ft);
__p->tv_usec = (long) ((now.ns100 / 10LL) % SSH_USEC_IN_SEC);
__p->tv_sec = (long)(((now.ns100 / 10LL ) / SSH_USEC_IN_SEC) - SSH_SECONDS_SINCE_1601);
return (0);
}
#else /* _WIN32 */ #else /* _WIN32 */
#ifndef NSS_BUFLEN_PASSWD
#define NSS_BUFLEN_PASSWD 4096
#endif
char *ssh_get_user_home_dir(void) { char *ssh_get_user_home_dir(void) {
char *szPath = NULL; char *szPath = NULL;
struct passwd *pwd = NULL; struct passwd pwd;
struct passwd *pwdbuf;
char buf[NSS_BUFLEN_PASSWD];
int rc;
pwd = getpwuid(getuid()); rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
if (pwd == NULL) { if (rc != 0) {
return NULL; return NULL;
} }
szPath = strdup(pwd->pw_dir); szPath = strdup(pwd.pw_dir);
return szPath; return szPath;
} }

View File

@@ -39,15 +39,22 @@
#include "libssh/server.h" #include "libssh/server.h"
#endif #endif
/**
* @addtogroup ssh_session
* @{
*/
/** /**
* @brief Duplicate the options of a session structure. * @brief Duplicate the options of a session structure.
* *
* If you make several sessions with the same options this is useful. You * If you make several sessions with the same options this is useful. You
* cannot use twice the same option structure in ssh_session_connect. * cannot use twice the same option structure in ssh_session_connect.
* *
* @param opt Option structure to copy. * @param src The session to use to copy the options.
* *
* @returns New copied option structure, NULL on error. * @param dest The session to copy the options to.
*
* @returns 0 on sucess, -1 on error with errno set.
* *
* @see ssh_session_connect() * @see ssh_session_connect()
*/ */
@@ -219,140 +226,143 @@ char *dir_expand_dup(ssh_session session, const char *value, int allowsshdir) {
* @param type The option type to set. This could be one of the * @param type The option type to set. This could be one of the
* following: * following:
* *
* SSH_OPTIONS_HOST: * - SSH_OPTIONS_HOST:
* The hostname or ip address to connect to (string). * The hostname or ip address to connect to (string).
* *
* SSH_OPTIONS_PORT: * - SSH_OPTIONS_PORT:
* The port to connect to (integer). * The port to connect to (integer).
* *
* SSH_OPTIONS_PORT_STR: * - SSH_OPTIONS_PORT_STR:
* The port to connect to (string). * The port to connect to (string).
* *
* SSH_OPTIONS_FD: * - SSH_OPTIONS_FD:
* The file descriptor to use (socket_t). * The file descriptor to use (socket_t).\n
* * \n
* If you wish to open the socket yourself for a reason * If you wish to open the socket yourself for a reason
* or another, set the file descriptor. Don't forget to * or another, set the file descriptor. Don't forget to
* set the hostname as the hostname is used as a key in * set the hostname as the hostname is used as a key in
* the known_host mechanism. * the known_host mechanism.
* *
* SSH_OPTIONS_USER: * - SSH_OPTIONS_USER:
* The username for authentication (string). * The username for authentication (string).\n
* * \n
* If the value is NULL, the username is set to the * If the value is NULL, the username is set to the
* default username. * default username.
* *
* SSH_OPTIONS_SSH_DIR: * - SSH_OPTIONS_SSH_DIR:
* Set the ssh directory (format string). * Set the ssh directory (format string).\n
* * \n
* If the value is NULL, the directory is set to the * If the value is NULL, the directory is set to the
* default ssh directory. * default ssh directory.\n
* * \n
* The ssh directory is used for files like known_hosts * The ssh directory is used for files like known_hosts
* and identity (private and public key). It may include * and identity (private and public key). It may include
* "%s" which will be replaced by the user home * "%s" which will be replaced by the user home
* directory. * directory.
* *
* SSH_OPTIONS_KNOWNHOSTS: * - SSH_OPTIONS_KNOWNHOSTS:
* Set the known hosts file name (format string). * Set the known hosts file name (format string).\n
* * \n
* If the value is NULL, the directory is set to the * If the value is NULL, the directory is set to the
* default known hosts file, normally ~/.ssh/known_hosts. * default known hosts file, normally
* * ~/.ssh/known_hosts.\n
* \n
* The known hosts file is used to certify remote hosts * The known hosts file is used to certify remote hosts
* are genuine. It may include "%s" which will be * are genuine. It may include "%s" which will be
* replaced by the user home directory. * replaced by the user home directory.
* *
* SSH_OPTIONS_IDENTITY: * - SSH_OPTIONS_IDENTITY:
* Set the identity file name (format string). * Set the identity file name (format string).\n
* * \n
* By default identity, id_dsa and id_rsa are checked. * By default identity, id_dsa and id_rsa are checked.\n
* * \n
* The identity file used authenticate with public key. * The identity file used authenticate with public key.
* It may include "%s" which will be replaced by the * It may include "%s" which will be replaced by the
* user home directory. * user home directory.
* *
* SSH_OPTIONS_TIMEOUT: * - SSH_OPTIONS_TIMEOUT:
* Set a timeout for the connection in seconds (integer). * Set a timeout for the connection in seconds (integer).
* *
* SSH_OPTIONS_TIMEOUT_USEC: * - SSH_OPTIONS_TIMEOUT_USEC:
* Set a timeout for the connection in micro seconds * Set a timeout for the connection in micro seconds
* (integer). * (integer).
* *
* SSH_OPTIONS_SSH1: * - SSH_OPTIONS_SSH1:
* Allow or deny the connection to SSH1 servers * Allow or deny the connection to SSH1 servers
* (integer). * (integer).
* *
* SSH_OPTIONS_SSH2: * - SSH_OPTIONS_SSH2:
* Allow or deny the connection to SSH2 servers * Allow or deny the connection to SSH2 servers
* (integer). * (integer).
* *
* SSH_OPTIONS_LOG_VERBOSITY: * - SSH_OPTIONS_LOG_VERBOSITY:
* Set the session logging verbosity (integer). * Set the session logging verbosity (integer).\n
* * \n
* The verbosity of the messages. Every log smaller or * The verbosity of the messages. Every log smaller or
* equal to verbosity will be shown. * equal to verbosity will be shown.
* SSH_LOG_NOLOG: No logging * - SSH_LOG_NOLOG: No logging
* SSH_LOG_RARE: Rare conditions or warnings * - SSH_LOG_RARE: Rare conditions or warnings
* SSH_LOG_ENTRY: API-accessible entrypoints * - SSH_LOG_ENTRY: API-accessible entrypoints
* SSH_LOG_PACKET: Packet id and size * - SSH_LOG_PACKET: Packet id and size
* SSH_LOG_FUNCTIONS: Function entering and leaving * - SSH_LOG_FUNCTIONS: Function entering and leaving
*
* SSH_OPTIONS_LOG_VERBOSITY_STR:
* Set the session logging verbosity (string).
* *
* - SSH_OPTIONS_LOG_VERBOSITY_STR:
* Set the session logging verbosity (string).\n
* \n
* The verbosity of the messages. Every log smaller or * The verbosity of the messages. Every log smaller or
* equal to verbosity will be shown. * equal to verbosity will be shown.
* SSH_LOG_NOLOG: No logging * - SSH_LOG_NOLOG: No logging
* SSH_LOG_RARE: Rare conditions or warnings * - SSH_LOG_RARE: Rare conditions or warnings
* SSH_LOG_ENTRY: API-accessible entrypoints * - SSH_LOG_ENTRY: API-accessible entrypoints
* SSH_LOG_PACKET: Packet id and size * - SSH_LOG_PACKET: Packet id and size
* SSH_LOG_FUNCTIONS: Function entering and leaving * - SSH_LOG_FUNCTIONS: Function entering and leaving
* * \n
* See the corresponding numbers in libssh.h. * See the corresponding numbers in libssh.h.
* *
* SSH_OPTTIONS_AUTH_CALLBACK: * - SSH_OPTTIONS_AUTH_CALLBACK:
* Set a callback to use your own authentication function * Set a callback to use your own authentication function
* (function pointer). * (function pointer).
* *
* SSH_OPTTIONS_AUTH_USERDATA: * - SSH_OPTTIONS_AUTH_USERDATA:
* Set the user data passed to the authentication function * Set the user data passed to the authentication
* (generic pointer). * function (generic pointer).
* *
* SSH_OPTTIONS_LOG_CALLBACK: * - SSH_OPTTIONS_LOG_CALLBACK:
* Set a callback to use your own logging function * Set a callback to use your own logging function
* (function pointer). * (function pointer).
* *
* SSH_OPTTIONS_LOG_USERDATA: * - SSH_OPTTIONS_LOG_USERDATA:
* Set the user data passed to the logging function * Set the user data passed to the logging function
* (generic pointer). * (generic pointer).
* *
* SSH_OPTTIONS_STATUS_CALLBACK: * - SSH_OPTTIONS_STATUS_CALLBACK:
* Set a callback to show connection status in realtime * Set a callback to show connection status in realtime
* (function pointer). * (function pointer).\n
* * \n
* @code
* fn(void *arg, float status) * fn(void *arg, float status)
* * @endcode
* \n
* During ssh_connect(), libssh will call the callback * During ssh_connect(), libssh will call the callback
* with status from 0.0 to 1.0. * with status from 0.0 to 1.0.
* *
* SSH_OPTTIONS_STATUS_ARG: * - SSH_OPTTIONS_STATUS_ARG:
* Set the status argument which should be passed to the * Set the status argument which should be passed to the
* status callback (generic pointer). * status callback (generic pointer).
* *
* SSH_OPTIONS_CIPHERS_C_S: * - SSH_OPTIONS_CIPHERS_C_S:
* Set the symmetric cipher client to server (string, * Set the symmetric cipher client to server (string,
* comma-separated list). * comma-separated list).
* *
* SSH_OPTIONS_CIPHERS_S_C: * - SSH_OPTIONS_CIPHERS_S_C:
* Set the symmetric cipher server to client (string, * Set the symmetric cipher server to client (string,
* comma-separated list). * comma-separated list).
* *
* SSH_OPTIONS_COMPRESSION_C_S: * - SSH_OPTIONS_COMPRESSION_C_S:
* Set the compression to use for client to server * Set the compression to use for client to server
* communication (string, "none" or "zlib"). * communication (string, "none" or "zlib").
* *
* SSH_OPTIONS_COMPRESSION_S_C: * - SSH_OPTIONS_COMPRESSION_S_C:
* Set the compression to use for server to client * Set the compression to use for server to client
* communication (string, "none" or "zlib"). * communication (string, "none" or "zlib").
* *
@@ -553,6 +563,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
session->log_verbosity = *x & 0xffff; session->log_verbosity = *x & 0xffff;
} }
break;
case SSH_OPTIONS_LOG_VERBOSITY_STR: case SSH_OPTIONS_LOG_VERBOSITY_STR:
if (value == NULL) { if (value == NULL) {
session->log_verbosity = 0 & 0xffff; session->log_verbosity = 0 & 0xffff;
@@ -615,8 +626,13 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
return 0; return 0;
} }
/** @} */
#ifdef WITH_SERVER #ifdef WITH_SERVER
/**
* @addtogroup ssh_server
* @{
*/
static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo, static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo,
const char *list) { const char *list) {
if (!verify_existing_algo(algo, list)) { if (!verify_existing_algo(algo, list)) {

View File

@@ -30,8 +30,10 @@
#ifdef WITH_PCAP #ifdef WITH_PCAP
#include <stdio.h> #include <stdio.h>
#ifndef _WIN32
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h> #include <sys/socket.h>
#endif
#include <errno.h> #include <errno.h>
@@ -46,13 +48,13 @@
* Just for information. * Just for information.
*/ */
struct pcap_hdr_s { struct pcap_hdr_s {
u_int32_t magic_number; /* magic number */ uint32_t magic_number; /* magic number */
u_int16_t version_major; /* major version number */ uint16_t version_major; /* major version number */
u_int16_t version_minor; /* minor version number */ uint16_t version_minor; /* minor version number */
int32_t thiszone; /* GMT to local correction */ int32_t thiszone; /* GMT to local correction */
u_int32_t sigfigs; /* accuracy of timestamps */ uint32_t sigfigs; /* accuracy of timestamps */
u_int32_t snaplen; /* max length of captured packets, in octets */ uint32_t snaplen; /* max length of captured packets, in octets */
u_int32_t network; /* data link type */ uint32_t network; /* data link type */
}; };
#define PCAP_MAGIC 0xa1b2c3d4 #define PCAP_MAGIC 0xa1b2c3d4
@@ -73,10 +75,10 @@ struct pcap_hdr_s {
* Just for information. * Just for information.
*/ */
struct pcaprec_hdr_s { struct pcaprec_hdr_s {
u_int32_t ts_sec; /* timestamp seconds */ uint32_t ts_sec; /* timestamp seconds */
u_int32_t ts_usec; /* timestamp microseconds */ uint32_t ts_usec; /* timestamp microseconds */
u_int32_t incl_len; /* number of octets of packet saved in file */ uint32_t incl_len; /* number of octets of packet saved in file */
u_int32_t orig_len; /* actual length of packet */ uint32_t orig_len; /* actual length of packet */
}; };
/** @private /** @private
@@ -92,12 +94,12 @@ struct ssh_pcap_context_struct {
/* All of these informations are useful to generate /* All of these informations are useful to generate
* the dummy IP and TCP packets * the dummy IP and TCP packets
*/ */
u_int32_t ipsource; uint32_t ipsource;
u_int32_t ipdest; uint32_t ipdest;
u_int16_t portsource; uint16_t portsource;
u_int16_t portdest; uint16_t portdest;
u_int32_t outsequence; uint32_t outsequence;
u_int32_t insequence; uint32_t insequence;
}; };
/** @private /** @private
@@ -106,7 +108,7 @@ struct ssh_pcap_context_struct {
*/ */
struct ssh_pcap_file_struct { struct ssh_pcap_file_struct {
FILE *output; FILE *output;
u_int16_t ipsequence; uint16_t ipsequence;
}; };
/** /**
@@ -136,7 +138,7 @@ static int ssh_pcap_file_write(ssh_pcap_file pcap, ssh_buffer packet){
* @brief prepends a packet with the pcap header and writes packet * @brief prepends a packet with the pcap header and writes packet
* on file * on file
*/ */
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, u_int32_t original_len){ int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len){
ssh_buffer header=buffer_new(); ssh_buffer header=buffer_new();
struct timeval now; struct timeval now;
int err; int err;
@@ -282,7 +284,7 @@ static int ssh_pcap_context_connect(ssh_pcap_context ctx){
* @returns SSH_ERROR an error happened. * @returns SSH_ERROR an error happened.
*/ */
int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction direction int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction direction
, void *data, u_int32_t len, u_int32_t origlen){ , void *data, uint32_t len, uint32_t origlen){
ssh_buffer ip; ssh_buffer ip;
int err; int err;
if(ctx==NULL || ctx->file ==NULL) if(ctx==NULL || ctx->file ==NULL)

View File

@@ -278,7 +278,11 @@ void ssh_bind_free(ssh_bind sshbind){
} }
if (sshbind->bindfd >= 0) { if (sshbind->bindfd >= 0) {
#ifdef _WIN32
closesocket(sshbind->bindfd);
#else
close(sshbind->bindfd); close(sshbind->bindfd);
#endif
} }
sshbind->bindfd = -1; sshbind->bindfd = -1;

View File

@@ -157,29 +157,31 @@ static void blowfish_decrypt(struct crypto_struct *cipher, void *in,
} }
static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) { static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) {
int mode=GCRY_CIPHER_MODE_CBC;
if (cipher->key == NULL) { if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) { if (alloc_key(cipher) < 0) {
return -1; return -1;
} }
if(strstr(cipher->name,"-ctr"))
mode=GCRY_CIPHER_MODE_CTR;
switch (cipher->keysize) { switch (cipher->keysize) {
case 128: case 128:
if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES128, if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES128,
GCRY_CIPHER_MODE_CBC, 0)) { mode, 0)) {
SAFE_FREE(cipher->key); SAFE_FREE(cipher->key);
return -1; return -1;
} }
break; break;
case 192: case 192:
if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES192, if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES192,
GCRY_CIPHER_MODE_CBC, 0)) { mode, 0)) {
SAFE_FREE(cipher->key); SAFE_FREE(cipher->key);
return -1; return -1;
} }
break; break;
case 256: case 256:
if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES256, if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES256,
GCRY_CIPHER_MODE_CBC, 0)) { mode, 0)) {
SAFE_FREE(cipher->key); SAFE_FREE(cipher->key);
return -1; return -1;
} }
@@ -189,9 +191,17 @@ static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) {
SAFE_FREE(cipher->key); SAFE_FREE(cipher->key);
return -1; return -1;
} }
if (gcry_cipher_setiv(cipher->key[0], IV, 16)) { if(mode == GCRY_CIPHER_MODE_CBC){
SAFE_FREE(cipher->key); if (gcry_cipher_setiv(cipher->key[0], IV, 16)) {
return -1;
SAFE_FREE(cipher->key);
return -1;
}
} else {
if(gcry_cipher_setctr(cipher->key[0],IV,16)){
SAFE_FREE(cipher->key);
return -1;
}
} }
} }
@@ -319,6 +329,39 @@ static struct crypto_struct ssh_ciphertab[] = {
.cbc_encrypt = blowfish_encrypt, .cbc_encrypt = blowfish_encrypt,
.cbc_decrypt = blowfish_decrypt .cbc_decrypt = blowfish_decrypt
}, },
{
.name = "aes128-ctr",
.blocksize = 16,
.keylen = sizeof(gcry_cipher_hd_t),
.key = NULL,
.keysize = 128,
.set_encrypt_key = aes_set_key,
.set_decrypt_key = aes_set_key,
.cbc_encrypt = aes_encrypt,
.cbc_decrypt = aes_encrypt
},
{
.name = "aes192-ctr",
.blocksize = 16,
.keylen = sizeof(gcry_cipher_hd_t),
.key = NULL,
.keysize = 192,
.set_encrypt_key = aes_set_key,
.set_decrypt_key = aes_set_key,
.cbc_encrypt = aes_encrypt,
.cbc_decrypt = aes_encrypt
},
{
.name = "aes256-ctr",
.blocksize = 16,
.keylen = sizeof(gcry_cipher_hd_t),
.key = NULL,
.keysize = 256,
.set_encrypt_key = aes_set_key,
.set_decrypt_key = aes_set_key,
.cbc_encrypt = aes_encrypt,
.cbc_decrypt = aes_encrypt
},
{ {
.name = "aes128-cbc", .name = "aes128-cbc",
.blocksize = 16, .blocksize = 16,
@@ -570,6 +613,24 @@ static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
unsigned long len, void *IV) { unsigned long len, void *IV) {
AES_cbc_encrypt(in, out, len, cipher->key, IV, AES_DECRYPT); AES_cbc_encrypt(in, out, len, cipher->key, IV, AES_DECRYPT);
} }
/** @internal
* @brief encrypts/decrypts data with stream cipher AES_ctr128. 128 bits is actually
* the size of the CTR counter and incidentally the blocksize, but not the keysize.
* @param len[in] must be a multiple of AES128 block size.
*/
static void aes_ctr128_encrypt(struct crypto_struct *cipher, void *in, void *out,
unsigned long len, void *IV) {
unsigned char tmp_buffer[128/8];
unsigned int num=0;
/* Some things are special with ctr128 :
* In this case, tmp_buffer is not being used, because it is used to store temporary data
* when an encryption is made on lengths that are not multiple of blocksize.
* Same for num, which is being used to store the current offset in blocksize in CTR
* function.
*/
AES_ctr128_encrypt(in, out, len, cipher->key, IV, tmp_buffer, &num);
}
#endif /* HAS_AES */ #endif /* HAS_AES */
#ifdef HAS_DES #ifdef HAS_DES
@@ -661,6 +722,39 @@ static struct crypto_struct ssh_ciphertab[] = {
}, },
#endif /* HAS_BLOWFISH */ #endif /* HAS_BLOWFISH */
#ifdef HAS_AES #ifdef HAS_AES
{
"aes128-ctr",
16,
sizeof(AES_KEY),
NULL,
128,
aes_set_encrypt_key,
aes_set_encrypt_key,
aes_ctr128_encrypt,
aes_ctr128_encrypt
},
{
"aes192-ctr",
16,
sizeof(AES_KEY),
NULL,
192,
aes_set_encrypt_key,
aes_set_encrypt_key,
aes_ctr128_encrypt,
aes_ctr128_encrypt
},
{
"aes256-ctr",
16,
sizeof(AES_KEY),
NULL,
256,
aes_set_encrypt_key,
aes_set_encrypt_key,
aes_ctr128_encrypt,
aes_ctr128_encrypt
},
{ {
"aes128-cbc", "aes128-cbc",
16, 16,