1
1

1903 Коммитов

Автор SHA1 Сообщение Дата
Kamil Dudka
712c6cbdd2 session: avoid printing misleading debug messages
... while throwing LIBSSH2_ERROR_EAGAIN out of session_startup()

If the session runs in blocking mode, LIBSSH2_ERROR_EAGAIN never reaches
the libssh2 API boundary and, in non-blocking mode, these messages are
suppressed by the condition in _libssh2_error_flags() anyway.

Closes #211
2017-10-17 15:03:48 +02:00
Viktor Szakats
1d0e694d7d win32/GNUmakefile: allow customizing dll suffixes
- New `LIBSSH2_DLL_SUFFIX` envvar will add a suffix to the generated
  libssh2 dll name. Useful to add `-x64` to 64-bit builds so that
  it can live in the same directory as the 32-bit one. By default
  this is empty.

- New `LIBSSH2_DLL_A_SUFFIX` envvar to customize the suffix of the
  generated import library (implib) for libssh2 .dll. It defaults
  to `dll`, and it's useful to modify that to `.dll` to have the
  standard naming scheme for mingw-built .dlls, i.e. `libssh2.dll.a`.

Ref: aaa16f8025

Closes https://github.com/libssh2/libssh2/pull/215
2017-10-15 20:36:59 +00:00
Viktor Szakats
e41d6f4b0e makefile.m32: allow to override gcc, ar and ranlib
Allow to ovverride certain build tools, making it possible to
use LLVM/Clang to build libssh2. The default behavior is unchanged.
To build with clang (as offered by MSYS2), these settings can
be used:

LIBSSH2_CC=clang
LIBSSH2_AR=llvm-ar
LIBSSH2_RANLIB=llvm-ranlib

Also adjust ranlib parameters to be compatible with LLVM/Clang's
ranlib tool.

Closes https://github.com/libssh2/libssh2/pull/214
2017-10-15 17:23:47 +00:00
Will Cosgrove
23b873a9e5 Fixes out of bounds memory access (#210)
If an invalid PEM file is read and the lines are longer than 128 characters it will go out of bounds and crash on line 91.
2017-09-27 11:08:50 -07:00
Kamil Dudka
819ef4f203 scp: do not NUL-terminate the command for remote exec (#208)
It breaks SCP download/upload from/to certain server implementations.

The bug does not manifest with OpenSSH, which silently drops the NUL
byte (eventually with any garbage that follows the NUL byte) before
executing it.

Bug: https://bugzilla.redhat.com/1489736
2017-09-11 12:13:45 -07:00
Viktor Szakats
fe186fef3a openssl.c: remove no longer used variable (#204)
after e378d2e30a40bd9bcee06dc3a4250f269098e200
2017-08-21 17:49:57 -05:00
Will Cosgrove
6762664e7e Fix for #188 (#189)
* Update openssl.c

* Create openssl.h
2017-06-09 14:59:18 -07:00
Marcel Raad
c423b543ca openssl: fix build with OpenSSL 1.1 API (#176)
When building with OPENSSL_API_COMPAT=0x10100000L, OpenSSL_add_all_algorithms
and OpenSSL_add_all_ciphers don't exist. The corresponding functionality is
handled automatically with OpenSSL 1.1.
2017-05-24 10:21:22 -07:00
Sune Bredahl
bbc43cb333 Add support for SHA256 hostkey fingerprints (#180)
Looks good, thanks!
2017-05-24 10:15:53 -07:00
Will Cosgrove
97518ca8bd Fix memory leak of crypt_ctx->h using openSSL 1.1+ (#177)
Need to use EVP_CIPHER_CTX_free instead of EVP_CIPHER_CTX_reset.
2017-05-12 16:34:26 -07:00
Marc Hoersken
323aa08f01 tests/openssh_server/authorized_keys: add key_rsa_encrypted.pub 2017-03-02 22:29:14 +01:00
Marc Hoersken
20a545d37d tests: add simple test for passphrase-protected PEM file support 2017-03-02 00:51:37 +01:00
Marc Hoersken
aefc5db56a os400qc3: enable passphrase-protected PEM file support using pem.c 2017-03-02 00:15:31 +01:00
Marc Hoersken
fe963dfd3a pem: fix indentation and replace assert after 386e012292 2017-03-02 00:14:36 +01:00
Keno Fischer
386e012292 pem: add passphrase-protected PEM file support for libgcrypt and wincng
Since they use our own PEM parser which did not support encrypted
PEM files, trying to use such files on these backends failed.
Fix that by augmenting the PEM parser to support encrypted PEM files.
2017-03-02 00:12:06 +01:00
Thomas
674299c346 misc: use time constant implementation for AES CTR increment 2017-03-01 23:09:33 +01:00
Thomas
2de14f8f9a wincng: add AES CTR mode support (aes128-ctr, aes192-ctr, aes256-ctr) 2017-03-01 23:09:16 +01:00
Thomas
e378d2e30a openssl: move shared AES-CTR code into misc 2017-03-01 23:00:32 +01:00
Alex Crichton
b3f9557f52 kex: acknowledge error code from libssh2_dh_key_pair()
Fixes a segfault using ssh-agent on Windows

This commit fixes a segfault seen dereferencing a null pointer on
Windows when using ssh-agent. The problem ended up being that errors
weren't being communicated all the way through, causing null pointers to
be used when functions should have bailed out sooner.

The `_libssh2_dh_key_pair` function for WinCNG was modified to propagate
errors, and then the two callsites in kex.c of
`diffie_hellman_sha{1,256}` were updated to recognize this error and
bail out.

Fixes #162
Closes #163
2016-12-20 23:34:43 +01:00
monnerat
f7daf3185a Implement Diffie-Hellman computations in crypto backends. (#149)
Not all backends feature the low level API needed to compute a Diffie-Hellman
secret, but some of them directly implement Diffie-Hellman support with opaque
private data. The later approach is now generalized and backends are
responsible for all Diffie Hellman computations.
As a side effect, procedures/macros _libssh2_bn_rand and _libssh2_bn_mod_exp
are no longer needed outside the backends.
2016-11-27 18:39:00 +00:00
Peter Stuge
5abceec571 acinclude.m4: The mbedtls crypto backend actually requires libmbedcrypto
Examples can't be linked with libmbedtls but need libmbedcrypto, and
any users of libssh2 which use libtool and libssh2.la would encounter
the same problem.

This changes the mbedtls detection to search for libmbedcrypto, which
is the actual dependency for the backend.
2016-11-16 22:32:39 +01:00
Peter Stuge
ab8f0bc0bf acinclude.m4: Add CPPFLAGS=-I$prefix-dir/include in LIBSSH2_LIB_HAVE_LINKFLAGS
This is absolutely neccessary for header files to be found when
AC_LIB_HAVE_LINKFLAGS searches for libraries.
2016-11-16 22:25:16 +01:00
Peter Stuge
5621a97e38 acinclude.m4: Make saved variables in LIBSSH2_LIB_HAVE_LINKFLAGS uniform 2016-11-16 22:23:53 +01:00
Peter Stuge
ddb0c65856 docs/HACKING.CRYPTO: Improve documentation for autoconf build system 2016-11-16 22:20:02 +01:00
Alex Arslan
8dc9f4c156 Check for netinet/in.h in the tests cmake file (#148) 2016-11-16 08:45:38 +00:00
Patrick Monnerat
028a0ba4ed Define new Diffie-Hellman context for mbedTLS 2016-11-13 18:14:50 +00:00
monnerat
c8c1b4a050 Make libssh2 work again on os400. (#118)
* os400: minimum supported OS version is now V6R1.
Do not log compiler informational messages.

* Implement crypto backend specific Diffie-Hellman computation.

This feature is now needed on os400 because the QC3 library does not
implement bn_mod_exp() natively. Up to now, this function was emulated using
an RSA encryption, but commits ca5222ea819cc5ed797860070b4c6c1aeeb28420 and
7934c9ce2a029c43e3642a492d3b9e494d1542be (CVE-2016-0787) broke the emulation
because QC3 only supports RSA exponents up to 512 bits.

Happily, QC3 supports a native API for Diffie-Hellman computation, with
opaque random value: this commit implements the use of this API and, as a
side effect, enables support of this feature for any other crypto backend that
would use it.

A "generic" Diffie-Hellman computation internal API supports crypto backends
not implementing their own: this generic API uses the same functions as before.

* Fix typos in docs/HACKING.CRYPTO.
2016-11-12 18:15:49 +00:00
Peter Stuge
c81b2384ac acinclude.m4: Fixup OpenSSL EVP_aes_128_ctr() detection 2016-11-12 10:46:06 +00:00
Peter Stuge
e70e71a3b1 configure.ac: Add --with-crypto= instead of many different --with-$backend
The new --with-crypto option replaces the previous backend-specific
--with-{openssl,libgcrypt,mbedtls,wincng} options and fixes some issues.

* libgcrypt or mbedtls would previously be used whenever found, even
  if configure was passed --without-libgcrypt or --without-mbedtls.

* If --with-$backend was specified then configure would not fail even
  if that library could not be found, and would instead use whichever
  crypto library was found first.

The new option defaults to `auto`, which makes configure check for all
supported crypto libraries in turn, choosing the first one found, or
exiting with an error if none can be found.
2016-11-12 10:46:06 +00:00
Tony Kelman
e83bbc48ab Build mbedtls from source on Travis (#133)
* Revert "Revert "travis: Test mbedtls too""

This reverts commit c4c60eac5ca756333034b07dd9e0b97741493ed3.

* travis: Build mbedtls from source on Travis

Use TOOLCHAIN_OPTION when calling cmake on mbedtls

* tests: only run DSA tests for non-mbedtls

crypto backends
2016-11-12 10:41:48 +00:00
Peter Stuge
a68356418d configure.ac src/Makefile.am: Remove dead AM_CONDITIONAL(OS400QC3)
According to os400/README400 this backend can not be built
with configure+make, and the conditional is hard coded to false.
2016-11-05 22:18:04 +00:00
Peter Stuge
6b0a09bc11 configure.ac: Add -DNDEBUG to CPPFLAGS in non-debug builds
There are a few uses of assert() in channel.c, sftp.c and transport.c.
2016-11-05 22:18:04 +00:00
Peter Stuge
b3636eaad5 src/global.c: Fix conditional AES-CTR support
Most of libssh2 already has conditional support for AES-CTR according to
the LIBSSH2_AES_CTR crypto backend #define, but global.c needed fixing.
2016-11-05 22:18:04 +00:00
Peter Stuge
3806115d3d src/crypto.h src/userauth.c: Fix conditional RSA support
Most of libssh2 already has conditional support for RSA according to
the LIBSSH2_RSA crypto backend #define, but crypto.h and userauth.c
needed a few small fixes.
2016-11-05 22:18:04 +00:00
Peter Stuge
8a7232be61 src/kex.c: Cast libssh2_sha{1,256}_update data arguments properly
The update functions take a const unsigned char * but were called
with (const) char * in some places, causing unneccessary warnings.
2016-11-05 22:17:02 +00:00
Peter Stuge
ef60f292d2 docs/HACKING.CRYPTO: Fix two type typos 2016-11-05 22:17:02 +00:00
Sergei Trofimovich
ced924b78a acinclude.m4: fix ./configure --with-libgcrypt
The change fixes passing of bogus gcrypt prefix.
Reproducible as:

    $ ./configure --with-libgcrypt
    $ make V=1
    ...
    /bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2 -Iyes/include -version-info 1:1:0 -no-undefined -export-symbols-regex '^libssh2_.*' -lgcrypt  -lz -Lyes/lib -o libssh2.la -rpath /usr/local/lib channel.lo comp.lo crypt.lo hostkey.lo kex.lo mac.lo misc.lo packet.lo publickey.lo scp.lo session.lo sftp.lo userauth.lo transport.lo version.lo knownhost.lo agent.lo libgcrypt.lo pem.lo keepalive.lo global.lo   -lgcrypt
    ../libtool: line 7475: cd: yes/lib: No such file or directory
    libtool:   error: cannot determine absolute directory name of 'yes/lib'

These
    -Iyes/include
    -Lyes/lib
come from libgcrypt code autodetection:
  if test -n "$use_libgcrypt" && test "$use_libgcrypt" != "no"; then
     LDFLAGS="$LDFLAGS -L$use_libgcrypt/lib"
     CFLAGS="$CFLAGS -I$use_libgcrypt/include"

I assume it's a typo to use yes/no flag as a prefix and changed
it to '$with_libgcrypt_prefix'.

Reported-by: Mikhail Pukhlikov <cynede@gentoo.org>
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
2016-11-05 21:58:07 +00:00
Zenju
1d8db1d854 libssh2_sftp_init hang: last error not set
The problem is that the original if statement simply returns NULL, but does not set the session last error code. The consequence is that libssh2_sftp_init() also returns NULL and libssh2_session_last_errno(sshSession) == LIBSSH2_ERROR_NONE.

In my test the LIBSSH2_ERROR_EAGAIN is coming from sftp.c row 337:
            if(4 != sftp->partial_size_len)
                /* we got a short read for the length part */
                return LIBSSH2_ERROR_EAGAIN;

with "partial_size_len == 0". Not sure if this is expected.
2016-11-05 21:50:24 +00:00
Aidan Hobson Sayers
18fd7a0894 docs: correctly describe channel_wait_eof
channel_wait_eof waits for channel->remote.eof, which is set on
receiving a `SSH_MSG_CHANNEL_EOF` message. This message is sent
when a party has no more data to send on a channel.
2016-11-05 21:05:20 +00:00
Zenju
33637f136e Fix MSVC 14 compilation warning (#92)
1>  sftp.c
1>libssh2-files\src\sftp.c(3393): warning C4456: declaration of 'retcode' hides previous local declaration
1>  libssh2-files\src\sftp.c(3315): note: see declaration of 'retcode'
2016-11-05 21:04:03 +00:00
Salvador Fandino
84172e5188 LIBSSH2_ERROR_CHANNEL_WINDOW_FULL: add new error code
In order to signal that the requested operation can not succeed
because the receiving window had been exhausted, the error code
LIBSSH2_ERROR_BUFFER_TOO_SMALL has been reused but I have found
that in certain context it may be ambigous.

This patch introduces a new error code,
LIBSSH2_ERROR_CHANNEL_WINDOW_FULL, exclusive to signal that condition.
2016-11-05 19:45:33 +00:00
Salvador Fandino
fdfcb2f9e6 channel_wait_eof: handle receive window exhaustion
Until now, in blocking mode, if the remote receiving window is
exhausted this function hangs forever as data is not read and the
remote side just keeps waiting for the window to grow before sending
more data.

This patch, makes this function check for that condition and abort
with an error when it happens.
2016-11-05 19:45:33 +00:00
Salvador Fandino
d013a6b070 channel_wait_closed: don't fail when unread data is queued
This function was calling channel_wait_eof to ensure that the EOF
packet has already been received, but that function also checks that
the read data queue is empty before reporting the EOF. That caused
channel_wait_closed to fail with a LIBSSH2_ERROR_INVAL when some data
was queued even after a successful call to libssh2_channel_wait_eof.

This patch changes libssh2_channel_wait_closed to look directly into
channel->remote.eof so that both libssh2_channel_wait_eof and
libssh2_channel_wait_closed bahave consistently.
2016-11-05 19:45:33 +00:00
Salvador Fandino
56dffb0262 channel_wait_eof: fix debug message 2016-11-05 19:45:33 +00:00
Daniel Stenberg
d75e9c5c0d libssh2.h: start working on 1.8.1 2016-10-25 08:50:06 +02:00
Daniel Stenberg
30e9c1347e RELEASE-NOTES: adjusted for 1.8.0 2016-10-25 08:43:39 +02:00
Kamil Dudka
e9207ee2d1 Revert "aes: the init function fails when OpenSSL has AES support"
This partially reverts commit f4f2298ef3635acd031cc2ee0e71026cdcda5864
because it caused the compatibility code to call initialization routines
redundantly, leading to memory leakage with OpenSSL 1.1 and broken curl
test-suite in Fedora:

88 bytes in 1 blocks are definitely lost in loss record 5 of 8
   at 0x4C2DB8D: malloc (vg_replace_malloc.c:299)
   by 0x72C607D: CRYPTO_zalloc (mem.c:100)
   by 0x72A2480: EVP_CIPHER_meth_new (cmeth_lib.c:18)
   by 0x4E5A550: make_ctr_evp.isra.0 (openssl.c:407)
   by 0x4E5A8E8: _libssh2_init_aes_ctr (openssl.c:471)
   by 0x4E5BB5A: libssh2_init (global.c:49)
2016-10-20 17:32:27 +02:00
Charles Collicutt
29bcf75fb1 libssh2_wait_socket: Fix comparison with api_timeout to use milliseconds (#134)
Fixes #74
2016-10-19 09:49:37 +02:00
Charles Collicutt
15851ba78e Set err_msg on _libssh2_wait_socket errors (#135) 2016-10-19 09:46:41 +02:00
Daniel Stenberg
c4c60eac5c Revert "travis: Test mbedtls too"
This reverts commit 3e6de50a24815e72ec5597947f1831f6083b7da8.

Travis doesn't seem to support the mbedtls-dev package
2016-10-17 10:15:16 +02:00