Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 9d621e8

Browse files
committed
Merge commit '79900e5246da9a1712d8822a53aaf5fd0abc6f40'
2 parents 750dc91 + 79900e5 commit 9d621e8

194 files changed

Lines changed: 27917 additions & 7196 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 276 additions & 101 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
1010
include(DefineCMakeDefaults)
1111
include(DefineCompilerFlags)
1212

13-
project(libssh VERSION 0.8.7 LANGUAGES C)
13+
project(libssh VERSION 0.9.0 LANGUAGES C)
1414

1515
# global needed variable
1616
set(APPLICATION_NAME ${PROJECT_NAME})
@@ -22,7 +22,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
2222
# Increment AGE. Set REVISION to 0
2323
# If the source code was changed, but there were no interface changes:
2424
# Increment REVISION.
25-
set(LIBRARY_VERSION "4.7.4")
25+
set(LIBRARY_VERSION "4.8.1")
2626
set(LIBRARY_SOVERSION "4")
2727

2828
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
@@ -70,6 +70,10 @@ else (WITH_GCRYPT)
7070
endif (NOT OPENSSL_FOUND)
7171
endif(WITH_GCRYPT)
7272

73+
if (UNIT_TESTING)
74+
find_package(CMocka REQUIRED)
75+
endif ()
76+
7377
# Find out if we have threading available
7478
set(CMAKE_THREAD_PREFER_PTHREADS ON)
7579
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -150,9 +154,8 @@ if (WITH_EXAMPLES)
150154
endif (WITH_EXAMPLES)
151155

152156
if (UNIT_TESTING)
153-
find_package(CMocka REQUIRED)
154-
include(AddCMockaTest)
155-
add_subdirectory(tests)
157+
include(AddCMockaTest)
158+
add_subdirectory(tests)
156159
endif (UNIT_TESTING)
157160

158161
### SOURCE PACKAGE
@@ -220,10 +223,12 @@ message(STATUS "libnacl support: ${WITH_NACL}")
220223
message(STATUS "SFTP support: ${WITH_SFTP}")
221224
message(STATUS "Server support : ${WITH_SERVER}")
222225
message(STATUS "GSSAPI support : ${WITH_GSSAPI}")
226+
message(STATUS "GEX support : ${WITH_GEX}")
223227
message(STATUS "Pcap debugging support : ${WITH_PCAP}")
224228
message(STATUS "With static library: ${WITH_STATIC_LIB}")
225229
message(STATUS "Unit testing: ${UNIT_TESTING}")
226230
message(STATUS "Client code testing: ${CLIENT_TESTING}")
231+
message(STATUS "Blowfish cipher support: ${WITH_BLOWFISH_CIPHER}")
227232
set(_SERVER_TESTING OFF)
228233
if (WITH_SERVER)
229234
set(_SERVER_TESTING ${SERVER_TESTING})
@@ -238,5 +243,9 @@ message(STATUS "Benchmarks: ${WITH_BENCHMARKS}")
238243
message(STATUS "Symbol versioning: ${WITH_SYMBOL_VERSIONING}")
239244
message(STATUS "Allow ABI break: ${WITH_ABI_BREAK}")
240245
message(STATUS "Release is final: ${WITH_FINAL}")
246+
message(STATUS "Global client config: ${GLOBAL_CLIENT_CONFIG}")
247+
if (WITH_SERVER)
248+
message(STATUS "Global bind config: ${GLOBAL_BIND_CONFIG}")
249+
endif()
241250
message(STATUS "********************************************")
242251

ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
ChangeLog
22
==========
33

4+
version 0.9.0 (released 2019-06-28)
5+
* Added support for AES-GCM
6+
* Added improved rekeying support
7+
* Added performance improvements
8+
* Disabled blowfish support by default
9+
* Fixed several ssh config parsing issues
10+
* Added support for DH Group Exchange KEX
11+
* Added support for Encrypt-then-MAC mode
12+
* Added support for parsing server side configuration file
13+
* Added support for ECDSA/Ed25519 certificates
14+
* Added FIPS 140-2 compatibility
15+
* Improved known_hosts parsing
16+
* Improved documentation
17+
* Improved OpenSSL API usage for KEX, DH, and signatures
18+
419
version 0.8.7 (released 2019-02-25)
520
* Fixed handling extension flags in the server implementation
621
* Fixed exporting ed25519 private keys

CompilerChecks.cmake

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if (UNIX)
4141
add_c_compiler_flag("-Werror=strict-overflow" SUPPORTED_COMPILER_FLAGS)
4242
add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
4343
add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
44+
add_c_compiler_flag("-Wmissing-field-initializers" SUPPORTED_COMPILER_FLAGS)
4445

4546
check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
4647
if (REQUIRED_FLAGS_WFORMAT)
@@ -51,7 +52,10 @@ if (UNIX)
5152
add_c_compiler_flag("-Werror=format-security" SUPPORTED_COMPILER_FLAGS)
5253

5354
# Allow zero for a variadic macro argument
54-
add_c_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments" SUPPORTED_COMPILER_FLAGS)
55+
string(TOLOWER "${CMAKE_C_COMPILER_ID}" _C_COMPILER_ID)
56+
if ("${_C_COMPILER_ID}" STREQUAL "clang")
57+
add_c_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments" SUPPORTED_COMPILER_FLAGS)
58+
endif()
5559

5660
add_c_compiler_flag("-fno-common" SUPPORTED_COMPILER_FLAGS)
5761

@@ -65,10 +69,18 @@ if (UNIX)
6569
check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
6670
if (WITH_STACK_PROTECTOR_STRONG)
6771
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector-strong")
72+
# This is needed as Solaris has a seperate libssp
73+
if (SOLARIS)
74+
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector-strong")
75+
endif()
6876
else (WITH_STACK_PROTECTOR_STRONG)
6977
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
7078
if (WITH_STACK_PROTECTOR)
7179
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector")
80+
# This is needed as Solaris has a seperate libssp
81+
if (SOLARIS)
82+
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector")
83+
endif()
7284
endif()
7385
endif (WITH_STACK_PROTECTOR_STRONG)
7486

@@ -82,6 +94,8 @@ if (UNIX)
8294
add_c_compiler_flag("-Wno-error=tautological-compare" SUPPORTED_COMPILER_FLAGS)
8395
endif()
8496

97+
add_c_compiler_flag("-Wno-deprecated-declarations" DEPRECATION_COMPILER_FLAGS)
98+
8599
# Unset CMAKE_REQUIRED_FLAGS
86100
unset(CMAKE_REQUIRED_FLAGS)
87101
endif()
@@ -100,3 +114,8 @@ if (OSX)
100114
endif()
101115

102116
set(DEFAULT_C_COMPILE_FLAGS ${SUPPORTED_COMPILER_FLAGS} CACHE INTERNAL "Default C Compiler Flags" FORCE)
117+
set(DEFAULT_LINK_FLAGS ${SUPPORTED_LINKER_FLAGS} CACHE INTERNAL "Default C Linker Flags" FORCE)
118+
119+
if (DEPRECATION_COMPILER_FLAGS)
120+
set(DEFAULT_C_NO_DEPRECATION_FLAGS ${DEPRECATION_COMPILER_FLAGS} CACHE INTERNAL "Default no deprecation flags" FORCE)
121+
endif()

ConfigureChecks.cmake

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ check_include_file(sys/param.h HAVE_SYS_PARAM_H)
6464
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
6565
check_include_file(byteswap.h HAVE_BYTESWAP_H)
6666
check_include_file(glob.h HAVE_GLOB_H)
67+
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
6768

6869
if (WIN32)
6970
check_include_file(io.h HAVE_IO_H)
@@ -88,8 +89,10 @@ if (OPENSSL_FOUND)
8889
message(FATAL_ERROR "Could not detect openssl/aes.h")
8990
endif()
9091

91-
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
92-
check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
92+
if (WITH_BLOWFISH_CIPHER)
93+
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
94+
check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
95+
endif()
9396

9497
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
9598
check_include_file(openssl/ecdh.h HAVE_OPENSSL_ECDH_H)
@@ -108,6 +111,10 @@ if (OPENSSL_FOUND)
108111
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
109112
check_function_exists(EVP_aes_128_cbc HAVE_OPENSSL_EVP_AES_CBC)
110113

114+
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
115+
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
116+
check_function_exists(EVP_aes_128_gcm HAVE_OPENSSL_EVP_AES_GCM)
117+
111118
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
112119
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
113120
check_function_exists(CRYPTO_THREADID_set_callback HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK)
@@ -120,10 +127,16 @@ if (OPENSSL_FOUND)
120127
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
121128
check_function_exists(EVP_CIPHER_CTX_new HAVE_OPENSSL_EVP_CIPHER_CTX_NEW)
122129

130+
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
131+
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
132+
check_function_exists(EVP_KDF_CTX_new_id HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID)
133+
123134
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
124135
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
125136
check_function_exists(RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES)
126137

138+
check_function_exists(OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC)
139+
127140
unset(CMAKE_REQUIRED_INCLUDES)
128141
unset(CMAKE_REQUIRED_LIBRARIES)
129142
endif()
@@ -254,6 +267,14 @@ if (CMAKE_USE_PTHREADS_INIT)
254267
set(HAVE_PTHREAD 1)
255268
endif (CMAKE_USE_PTHREADS_INIT)
256269

270+
if (UNIT_TESTING)
271+
if (CMOCKA_FOUND)
272+
set(CMAKE_REQUIRED_LIBRARIES ${CMOCKA_LIBRARIES})
273+
check_function_exists(cmocka_set_test_filter HAVE_CMOCKA_SET_TEST_FILTER)
274+
unset(CMAKE_REQUIRED_LIBRARIES)
275+
endif ()
276+
endif ()
277+
257278
# OPTIONS
258279
check_c_source_compiles("
259280
__thread int tls;
@@ -272,19 +293,19 @@ int main(void) {
272293
###########################################################
273294
# For detecting attributes we need to treat warnings as
274295
# errors
275-
if (UNIX)
296+
if (UNIX OR MINGW)
276297
# Get warnings for attributs
277-
check_c_compiler_flag("-Wattributs" REQUIRED_FLAGS_WERROR)
298+
check_c_compiler_flag("-Wattributes" REQUIRED_FLAGS_WERROR)
278299
if (REQUIRED_FLAGS_WERROR)
279-
set(CMAKE_REQUIRED_FLAGS "-Wattributes")
300+
string(APPEND CMAKE_REQUIRED_FLAGS "-Wattributes ")
280301
endif()
281302

282303
# Turn warnings into errors
283304
check_c_compiler_flag("-Werror" REQUIRED_FLAGS_WERROR)
284305
if (REQUIRED_FLAGS_WERROR)
285-
set(CMAKE_REQUIRED_FLAGS "-Werror")
306+
string(APPEND CMAKE_REQUIRED_FLAGS "-Werror ")
286307
endif()
287-
endif (UNIX)
308+
endif ()
288309

289310
check_c_source_compiles("
290311
void test_constructor_attribute(void) __attribute__ ((constructor));
@@ -328,6 +349,28 @@ int main(void) {
328349
return 0;
329350
}" HAVE_FALLTHROUGH_ATTRIBUTE)
330351

352+
if (NOT WIN32)
353+
check_c_source_compiles("
354+
#define __unused __attribute__((unused))
355+
356+
static int do_nothing(int i __unused)
357+
{
358+
return 0;
359+
}
360+
361+
int main(void)
362+
{
363+
int i;
364+
365+
i = do_nothing(5);
366+
if (i > 5) {
367+
return 1;
368+
}
369+
370+
return 0;
371+
}" HAVE_UNUSED_ATTRIBUTE)
372+
endif()
373+
331374
check_c_source_compiles("
332375
#include <string.h>
333376
@@ -340,18 +383,6 @@ int main(void)
340383
return 0;
341384
}" HAVE_GCC_VOLATILE_MEMORY_PROTECTION)
342385

343-
check_c_source_compiles("
344-
#include <stdio.h>
345-
#define __VA_NARG__(...) (__VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) - 1)
346-
#define __VA_NARG_(...) __VA_ARG_N(__VA_ARGS__)
347-
#define __VA_ARG_N( _1, _2, _3, _4, _5, _6, _7, _8, _9,_10,N,...) N
348-
#define __RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
349-
#define myprintf(format, ...) printf((format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__)
350-
int main(void) {
351-
myprintf(\"%d %d %d %d\",1,2,3);
352-
return 0;
353-
}" HAVE_GCC_NARG_MACRO)
354-
355386
check_c_source_compiles("
356387
#include <stdio.h>
357388
int main(void) {
@@ -366,6 +397,8 @@ int main(void) {
366397
return 0;
367398
}" HAVE_COMPILER__FUNCTION__)
368399

400+
# This is only available with OpenBSD's gcc implementation */
401+
if (OPENBSD)
369402
check_c_source_compiles("
370403
#define ARRAY_LEN 16
371404
void test_attr(const unsigned char *k)
@@ -374,6 +407,7 @@ void test_attr(const unsigned char *k)
374407
int main(void) {
375408
return 0;
376409
}" HAVE_GCC_BOUNDED_ATTRIBUTE)
410+
endif(OPENBSD)
377411

378412
# Stop treating warnings as errors
379413
unset(CMAKE_REQUIRED_FLAGS)

DefineOptions.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ option(WITH_DEBUG_PACKET "Build with packet debug output" OFF)
88
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
99
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
1010
option(WITH_MBEDTLS "Compile against libmbedtls" OFF)
11+
option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF)
1112
option(WITH_PCAP "Compile with Pcap generation support" ON)
1213
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
1314
option(UNIT_TESTING "Build with unit tests" OFF)
@@ -18,6 +19,7 @@ option(WITH_EXAMPLES "Build examples" ON)
1819
option(WITH_NACL "Build with libnacl (curve25519)" ON)
1920
option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON)
2021
option(WITH_ABI_BREAK "Allow ABI break" OFF)
22+
option(WITH_GEX "Enable DH Group exchange mechanisms" ON)
2123
option(FUZZ_TESTING "Build with fuzzer for the server" OFF)
2224
option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
2325

@@ -47,3 +49,11 @@ endif (WITH_NACL)
4749
if (WITH_ABI_BREAK)
4850
set(WITH_SYMBOL_VERSIONING ON)
4951
endif (WITH_ABI_BREAK)
52+
53+
if (NOT GLOBAL_BIND_CONFIG)
54+
set(GLOBAL_BIND_CONFIG "/etc/ssh/libssh_server_config")
55+
endif (NOT GLOBAL_BIND_CONFIG)
56+
57+
if (NOT GLOBAL_CLIENT_CONFIG)
58+
set(GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config")
59+
endif (NOT GLOBAL_CLIENT_CONFIG)

INSTALL

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ In order to build libssh, you need to install several components:
1111
- [openssl](http://www.openssl.org) >= 0.9.8
1212
or
1313
- [gcrypt](http://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
14+
- [libz](http://www.zlib.net) >= 1.2
1415

1516
optional:
16-
- [libz](http://www.zlib.net) >= 1.2
17+
- [cmocka](https://cmocka.org/) >= 1.1.0
1718
- [socket_wrapper](https://cwrap.org/) >= 1.1.5
1819
- [nss_wrapper](https://cwrap.org/) >= 1.1.2
1920
- [uid_wrapper](https://cwrap.org/) >= 1.2.0
@@ -22,12 +23,12 @@ optional:
2223
Note that these version numbers are version we know works correctly. If you
2324
build and run libssh successfully with an older version, please let us know.
2425

25-
Windows binaries known to be working:
26+
For Windows use vcpkg:
2627

27-
- http://www.slproweb.com/products/Win32OpenSSL.html
28-
- http://zlib.net/ -> zlib compiled DLL
28+
https://github.com/Microsoft/vcpkg
2929

30-
We installed them in C:\Program Files
30+
which you can use to install openssl and zlib. libssh itself is also part of
31+
vcpkg!
3132

3233
## Building
3334
First, you need to configure the compilation, using CMake. Go inside the

0 commit comments

Comments
 (0)