1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-01-06 14:21:57 +03:00
Commit Graph

2177 Commits

Author SHA1 Message Date
Hayden Roche
17c9c1fcdf Add support for a wolfSSL crypto backend. (#629)
It uses wolfSSL's OpenSSL compatibility layer, so rather than introduce new
wolfssl.h/c files, the new backend just reuses openssl.h/c. Additionally,
replace EVP_Cipher() calls with EVP_CipherUpdate(), since EVP_Cipher() is not
recommended.

Credit: Hayden Roche
2022-01-06 10:25:34 -08:00
Bastien Durel
e24a4a9d48 Runtime engine detection with libssh2_crypto_engine() (#643)
File:
version.c, HACKING-CRYPTO, libssh2.h, libssh2_crypto_engine.3, makefile.

Notes:
libssh2_crypto_engine() API to get crypto engine at runtime.

Credit: Bastien Durel
2022-01-06 10:06:02 -08:00
Will Cosgrove
64a555d6f5 RSA SHA2 256/512 key upgrade support RFC 8332 #536 (#626)
Notes:
* Host Key RSA 256/512 support #536
* Client side key hash upgrading for RFC 8332
* Support for server-sig-algs, ext-info-c server messages
* Customizing preferred server-sig-algs via the preference LIBSSH2_METHOD_SIGN_ALGO

Credit: Anders Borum, Will Cosgrove
2022-01-06 09:50:58 -08:00
xalopp
967792c896 fix: use userauth name length to check memory boundaries for userauth name, fixes #653 (#654)
File: userauth.c

Notes:
Fixes `userauth_kybd_auth_name_len` length check 

Co-authored-by: Xaver Lopenstedt <xaver@lopenstedt.de>
2022-01-05 10:35:26 -08:00
Daniel Stenberg
552e20df38 agent: handle overly large comment lengths (#651)
Reported-by: Harry Sintonen
2021-12-17 08:56:29 -08:00
Daniel Stenberg
37ee0aa214 userauth: check for too large userauth_kybd_auth_name_len (#650)
... before using it.

Reported-by: MarcoPoloPie
Fixes #649
2021-12-17 08:46:29 -08:00
Daniel Stenberg
6c662e7b17 .github/SECURITY.md: fix the URL 2021-12-17 16:50:20 +01:00
Daniel Stenberg
1494e6c9f4 .github/SECURITY.md: add security policy 2021-12-17 16:48:53 +01:00
Will Cosgrove
9990b38d27 hostkey_method_ssh_ed25519_init() check key bounds (#645)
* hostkey_method_ssh_ed25519_init() check key bounds

File: hostkey.c

Notes:
Additional key length checking before calling _libssh2_ed25519_new_public()

Credit:
Will Cosgrove
2021-11-30 13:21:36 -08:00
Will Cosgrove
69f3cf0bea Fix error message in memory_read_privatekey #636
file: userauth.c
note: fix error message
credit:
volund
2021-11-18 10:38:32 -08:00
cntrump
3332d95396 Update maketgz for macOS (#543)
File:
maketgz

Notes:
Fix error on macOS: sed: -e: No such file or directory

Credit:
cntrump
2021-11-11 11:35:47 -08:00
Jun Tseng
a77ca0fcd3 CMake update minimum version to 2.8.12 (#639)
File:
CMakeLists.txt

Notes:
Following CMake's advice, Update the minimum required version.

Credit:
Jun Tseng
2021-11-10 16:09:04 -08:00
David Korczynski
1a799d30ca ci: Add CIFuzz integration
Notes:
Add CIFuzz integration to run fuzzer using the OSS-Fuzz infrastructure
at each PR.

Signed-off-by: David Korczynski <david@adalogics.com>
Closes #635
2021-11-08 17:35:40 +01:00
Uwe L. Korn
1f0fe7443a Use libssh2_EXPORTS as an alternative to _WINDLL (#470)
Files: libssh2.h

Notes:
`_WINDLL` is only defined when a Visual Studio CMake generator is used, `libssh2_EXPORTS` is used though for all CMake generator if a shared libssh2 library is being built.

Credit:
Uwe L. Korn
2021-10-26 09:21:56 -07:00
Viktor Szakats
d39e9ccc5e windows: fix clang and WinCNG warnings
Fix these categories of warning:

- in `wincng.c` disagreement in signed/unsigned char when passing around
  the passphrase string:
  `warning: pointer targets in passing argument [...] differ in signedness [-Wpointer-sign]`
  Fixed by using `const unsigned char *` in all static functions and
  applying/updating casts as necessary.

- in each use of `libssh2_*_init()` macros where the result is not used:
  `warning: value computed is not used [-Wunused-value]`
  Fixed by using `(void)` casts.

- `channel.c:1171:7: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  Fixed by initializing this variable with `LIBSSH2_ERROR_CHANNEL_UNKNOWN`.
  While there I replaced a few 0 literals with `LIBSSH2_ERROR_NONE`.

- in `sftp.c`, several of these two warnings:
  `warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  `warning: 'data_len' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  Fixed by initializing these variables with NULL and 0 respectively.

- Also removed the exec attribute from `wincng.h`.

Notes:
- There are many pre-existing checksrc issues.
- The `sftp.c` and `channel.c` warnings may apply to other platforms as well.

Closes #628
2021-10-01 20:09:03 +00:00
Daniel Stenberg
db34d2c400 README: use www.libssh2.org for the license link 2021-09-25 16:21:33 +02:00
Daniel Stenberg
4bcf8415a7 libssh2.h: bump it to 1.10.1-dev 2021-09-16 12:56:20 +02:00
Daniel Stenberg
6eb132f159 mailing list: moved to lists.haxx.se 2021-09-03 09:17:34 +02:00
Laurent Stacul
7daee037d1 openssh_fixture.c: Fix openssh_server build not working (#616) (#620)
File: openssh_fixture.c

Notes:
fixes too long of output lines building docker image

Credit:
Laurent Stacul
2021-09-02 13:17:35 -07:00
Will Cosgrove
f0417cb196 openssh_fixture.c: fix warning (#621)
File: openssh_fixture.c

Notes:
Fix `portable_sleep` return type warning

Credit:
Will Cosgrove
2021-09-02 13:14:46 -07:00
Will Cosgrove
d9b4222ef1 Update CI to use latest Ubuntu #624 (#625)
File: ci.yml

Notes:
Update CI to use latest Ubuntu #624

Also removed 32 bit building in the matrix. 

Credit:
Will Cosgrove
2021-09-02 13:13:53 -07:00
Will Cosgrove
af4a4d3f35 Update .gitignore
Add .DS_Store files for macOS
2021-08-31 09:51:25 -07:00
Laurent Stacul
a4fc97bf0a Makefile.am: Add missing key in case openssl > 1.1.0 (#617)
File: Makefile.am

Notes: fix missing test keys

Credit: 
Laurent Stacul
2021-08-30 09:59:27 -07:00
Will Cosgrove
635caa9078 updated docs for 1.10.0 release libssh2-1.10.0 2021-08-29 22:36:43 +02:00
Laurent Stacul
a88a727c2a [tests] Try several times to connect the ssh server
Sometimes, as the OCI container is run in detached mode, it is possible
the actual server is not ready yet to handle SSH traffic. The goal of
this PR is to try several times (max 3). The mechanism is the same as
for the connection to the docker machine.
2021-05-30 12:33:05 +02:00
Laurent Stacul
3709037b26 Remove openssh_server container on test exit 2021-05-30 11:41:52 +02:00
Laurent Stacul
718bcb03d2 Allow the tests to run inside a container
The current tests suite starts SSH server as OCI container. This commit
add the possibility to run the tests in a container provided that:

* the docker client is installed builder container
* the host docker daemon unix socket has been mounted in the builder
  container (with, if needed, the DOCKER_HOST environment variable
  accordingly set, and the permission to write on this socket)
* the builder container is run on the default bridge network, or the
  host network. This PR does not handle the case where the builder
  container is on another network.
2021-05-29 12:01:51 +02:00
Marc Hoersken
fee3125b3b CI/appveyor: run SSH server for tests on GitHub Actions (#607)
No longer rely on DigitalOcean to host the Docker container.

Unfortunately we require a small dispatcher script that has
access to a GitHub access token with scope repo in order to
trigger the daemon workflow on GitHub Actions also for PRs.

This script is hosted by myself for the time being until GitHub
provides a tighter scope to trigger the workflow_dispatch event.
2021-05-28 08:52:27 +02:00
Will Cosgrove
6f68e8d064 openssl.c: guards around calling FIPS_mode() #596 (#603)
Notes:
FIPS_mode() is not implemented in LibreSSL and this API is removed in OpenSSL 3.0 and was introduced in 0.9.7. Added guards around making this call.

Credit:
Will Cosgrove
2021-05-26 16:43:32 -07:00
Will Cosgrove
35ac220a44 configure.ac: don't undefine scoped variable (#594)
* configure.ac: don't undefine scoped variable

To get this script to run with Autoconf 2.71 on macOS I had to remove the undefine of the backend for loop variable. It seems scoped to the for loop and also isn't referenced later in the script so it seems OK to remove it.

* configure.ac: remove cygwin specific CFLAGS #598

Notes:
Remove cygwin specific Win32 CFLAGS and treat the build like a posix build

Credit:
Will Cosgrove, Brian Inglis
2021-05-26 16:42:38 -07:00
Laurent Stacul
f1f47ef79b tests: Makefile.am: Add missing tests client keys in distribution tarball (#604)
Notes:
Added missing test keys.

Credit:
Laurent Stacul
2021-05-18 08:18:06 -07:00
Laurent Stacul
62bc25c987 Makefile.am: Add missing test keys in the distribution tarball (#601)
Notes: 
Fix tests missing key to build the OCI image

Credit:
Laurent Stacul
2021-05-17 09:11:10 -07:00
Daniel Stenberg
8adbab3f6c dist: add src/agent.h
Fixes #597
Closes #599
2021-05-16 00:08:39 +02:00
Will Cosgrove
36fcd543d9 packet.c: Reset read timeout after received a packet (#576) (#586)
File:
packet.c

Notes:
Attempt keyboard interactive login (Azure AD 2FA login) and use more than 60 seconds to complete the login, the connection fails.

The _libssh2_packet_require function does almost the same as _libssh2_packet_requirev but this function sets state->start = 0 before returning.

Credit:
teottin, Co-authored-by: Tor Erik Ottinsen <tor.ottinsen@kdi.kongsberg.com>
2021-05-12 09:14:09 -07:00
kkoenig
3f9d505353 Support ECDSA certificate authentication (#570)
Files: hostkey.c, userauth.c, test_public_key_auth_succeeds_with_correct_ecdsa_key.c

Notes:
Support ECDSA certificate authentication

Add a test for:
  - Existing ecdsa basic public key authentication
  - ecdsa public key authentication with a signed public key

Credit:
kkoenig
2021-05-12 09:13:19 -07:00
Gabriel Smith
c998f79384 agent.c: Add support for Windows OpenSSH agent (#517)
Files: agent.c, agent.h, agent_win.c

Notes:
* agent: Add support for Windows OpenSSH agent

The implementation was partially taken and modified from that found in
the Portable OpenSSH port to Win32 by the PowerShell team, but mostly
based on the existing Unix OpenSSH agent support.

https://github.com/PowerShell/openssh-portable

Regarding the partial transfer support implementation: partial transfers
are easy to deal with, but you need to track additional state when
non-blocking IO enters the picture. A tracker of how many bytes have
been transfered has been placed in the transfer context struct as that's
where it makes most sense. This tracker isn't placed behind a WIN32
 #ifdef as it will probably be useful for other agent implementations.

* agent: win32 openssh: Disable overlapped IO

Non-blocking IO is not currently supported by the surrounding agent
code, despite a lot of the code having everything set up to handle it.

Credit:
Co-authored-by: Gabriel Smith <gabriel.smith@precisionot.com>
2021-05-11 14:13:37 -07:00
Zenju
58ae048c92 Fix detailed _libssh2_error being overwritten (#473)
Files: openssl.c, pem.c, userauth.c

Notes:
* Fix detailed _libssh2_error being overwritten by generic errors
* Unified error handling

Credit:
Zenju
2021-05-11 14:09:57 -07:00
Paul Capron
b3a8a6d27c Fix _libssh2_random() silently discarding errors (#520)
Notes:
* Make _libssh2_random return code consistent

Previously, _libssh2_random was advertized in HACKING.CRYPTO as
returning `void` (and was implemented that way in os400qc3.c), but that
was in other crypto backends a lie; _libssh2_random is (a macro
expanding) to an int-value expression or function.

Moreover, that returned code was:
  — 0 or success, -1 on error for the MbedTLS & WinCNG crypto backends
But also:
  — 1 on success, -1 or 0 on error for the OpenSSL backend!
  – 1 on success, error cannot happen for libgcrypt!

This commit makes explicit that _libssh2_random can fail (because most of
the underlying crypto functions can indeed fail!), and it makes its result
code consistent: 0 on success, -1 on error.

This is related to issue #519 https://github.com/libssh2/libssh2/issues/519
It fixes the first half of it.

* Don't silent errors of _libssh2_random

Make sure to check the returned code of _libssh2_random(), and
propagates any failure.

A new LIBSSH_ERROR_RANDGEN constant is added to libssh2.h
None of the existing error constants seemed fit.

This commit is related to d74285b684
and to https://github.com/libssh2/libssh2/issues/519 (see the issue
for more info.)  It closes #519.

Credit:
Paul Capron
2021-05-11 14:06:18 -07:00
Gabriel Smith
1270fdfe4b ci: Remove caching of docker image layers (#589)
Notes:
continued ci reliability work.

Credit:
Gabriel Smith
2021-05-11 13:44:12 -07:00
Gabriel Smith
92366cdb79 ci: Speed up docker builds for tests (#587)
Notes:
The OpenSSH server docker image used for tests is pre-built to prevent
wasting time building it during a test, and unneeded rebuilds are
prevented by caching the image layers.

Credit:
Gabriel Smith
2021-05-04 09:16:54 -07:00
Will Cosgrove
7118582a7c userauth.c: don't error if using keys without RSA (#555)
file: userauth.c

notes: libssh2 now supports many other key types besides RSA, if the library is built without RSA support and a user attempts RSA auth it shouldn't be an automatic error

credit: 
Will Cosgrove
2021-05-03 14:49:53 -07:00
Marc
b853d7a86e openssl.c: Avoid OpenSSL latent error in FIPS mode (#528)
File:
openssl.c

Notes:
Avoid initing MD5 digest, which is not permitted in OpenSSL FIPS certified cryptography mode.

Credit:
Marc
2021-05-03 14:49:02 -07:00
Laurent Stacul
35695772d0 openssl.c: Fix EVP_Cipher interface change in openssl 3 #463
File:
openssl.c

Notes:
Fixes building with OpenSSL 3, #463.

The change is described there:
f7397f0d58

Credit:
Laurent Stacul, reported by Sergei
2021-05-03 14:47:06 -07:00
Gabriel Smith
b5c071d180 openssh_fixture.c: Fix potential overwrite of buffer when reading stdout of command (#580)
File:
openssh_fixture.c 
Notes:
If reading the full output from the executed command took multiple
passes (such as when reading multiple lines) the old code would read
into the buffer starting at the some position (the start) every time.
The old code only works if fgets updated p or had an offset parameter,
both of which are not true.

Credit:
Gabriel Smith
2021-05-03 14:41:25 -07:00
Gabriel Smith
fb375d6fe2 ci: explicitly state the default branch (#585)
Notes:
It looks like the $default-branch macro only works in templates, not
workflows. This is not explicitly stated anywhere except the linked PR
comment.

https://github.com/actions/starter-workflows/pull/590#issuecomment-672360634

credit:
Gabriel Smith
2021-05-02 17:32:48 -07:00
Gabriel Smith
ee199144fe ci: Swap from Travis to Github Actions (#581)
Files: ci files

Notes:
Move Linux CI using Github Actions

Credit:
Gabriel Smith, Marc Hörsken
2021-04-30 16:10:52 -07:00
Mary
91393d6631 libssh2_priv.h: add iovec on 3ds (#575)
file: libssh2_priv.h
note: include iovec for 3DS
credit: Mary Mstrodl
2021-04-22 13:20:43 -07:00
Laurent Stacul
5627b82be6 Tests: Fix unused variables warning (#561)
file: test_public_key_auth_succeeds_with_correct_ed25519_key_from_mem.c

notes: fixed unused vars

credit:
Laurent Stacul
2021-03-04 14:17:00 -08:00
Viktor Szakats
4bb166a2a8 bcrypt_pbkdf.c: fix clang10 false positive warning (#563)
File: bcrypt_pbkdf.c

Notes:
blf_enc() takes a number of 64-bit blocks to encrypt, but using
sizeof(uint64_t) in the calculation triggers a warning with
clang 10 because the actual data type is uint32_t. Pass
BCRYPT_BLOCKS / 2 for the number of blocks like libc bcrypt(3)
does.

Ref: 04a2240bd8

Fixes #562

Credit:
Viktor Szakats
2021-03-04 13:10:07 -08:00
Will Cosgrove
ae26886671 transport.c: release payload on error (#554)
file: transport.c
notes: If the payload is invalid and there is an early return, we could leak the payload
credit:
Will Cosgrove
2021-02-11 09:18:16 -08:00