1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-01-27 00:18:12 +03:00
Commit Graph

3010 Commits

Author SHA1 Message Date
Viktor Szakats
8e3c40b2a3 cmake: fixup version detection in mbedTLS find module
- avoid warning with 2.x versions about missing header file while
  extracting the version number.

- clear temp variables.

Closes #1444
2024-08-13 19:34:25 +02:00
Viktor Szakats
814a850c97 buildconf: drop
Use `autoreconf -fi` instead.

Follow-up to fc5d77881e
Closes #1441
2024-08-07 18:19:15 +02:00
Michael Buckley
492bc543bb Implement chacha20-poly1305@openssh.com
Probably the biggest and potentially most controversial change we have
to upstream.

Because earlier versions of OpenSSL implemented the algorithm before
standardization, using an older version of OpenSSL can cause problems
connecting to OpenSSH servers. Because of this, we use the public domain
reference implementation instead of the crypto backends, just like
OpenSSH does.

We've been holding this one for a few years. We were about to upstream
it around the same time as aes128gcm landed upstream, and the two
changes were completely incompatible. Honestly, it took me weeks to
reconcile these two implementations, and it could be much better.

Our original implementation changed every crypt method to decrypt the
entire message at once. the AESGCM implementation instead went with this
firstlast design, where a firstlast paramater indicates whether this is
the first or last call to the crypt method for each message. That added
a lot of bookkeeping overhead, and wasn't compatible with the chacha
public domain implementation.

As far as I could tell, OpenSSH uses the technique of decrypting the
entire message in one go, and doesn't have anything like firstlast.
However, I could not get out aes128gcm implementation to work that way,
nor could I get the chacha implementation to work with firstlast, so I
split it down the middle and let each implementation work differently.
It's kind of a mess, and probably should be cleaned up, but I don't have
the time to spend on it anymore, and it's probably better to have
everything upstream.

Fixes #584
Closes #1426
2024-08-06 10:56:23 +02:00
Viktor Szakats
29a4b607d8 tidy-up: do/while formatting
Also fix an indentation and delete empty lines.

Closes #1440
2024-08-06 10:56:22 +02:00
Viktor Szakats
8ae1b2d742 wolfssl: drop header path hack
The wolfSSL OpenSSL headers reside in `wolfssl/openssl/*.h`.

Before this patch the wolfSSL OpenSSL compatibilty header includes were
shared with the native OpenSSL codepath, and used `openssl/*h`. For
wolfSSL builds this required a hack to append the
`<wolfssl-prefix>/wolfssl` directory to the header search path, to find
the headers.

This patch changes the source to use the correct header references,
allowing to drop the header path hack.

Also fix to use the correct variable to set up the header path in CMake:
`WOLFSSL_INCLUDE_DIRS` (was: `WOLFSSL_INCLUDE_DIR`, without the `S`)

Closes #1439
2024-08-06 10:56:22 +02:00
Viktor Szakats
6d1d13c2a6 cmake: mbedTLS detection tidy-ups
- set and use `MBEDTLS_INCLUDE_DIRS`.
- stop marking `MBEDTLS_LIBRARIES` as advanced.

Closes #1438
2024-08-06 10:56:22 +02:00
Viktor Szakats
2bb46d4481 cmake: add quotes, delete ending dirseps
Follow-up to 3fa5282d62 #1166
Closes #1437
2024-08-06 10:56:22 +02:00
Viktor Szakats
bf3af90b3f CI/appveyor: increase wait for SSH server on GHA [ci skip]
Blind attempt to make AppVeyor CI tests work again.
2024-07-30 23:35:32 +02:00
Viktor Szakats
b7ab0faa70 disable DSA by default
Also:
- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
- test the above option in CI.
- say 'deprecated' in docs and public header.
- disable DSA in the CI server config.
  (OpenSSH 9.8 no longer builds with it by default)
  https://www.openssh.com/txt/release-9.8
  Patch-by: Jose Quaresma
- disable more DSA code when not enabled.

Fixes #1433
Closes #1435
2024-07-30 22:59:02 +02:00
Viktor Szakats
c905bfd27c tidy-up: link updates (#1434) 2024-07-30 19:35:38 +02:00
Marc Hoersken
e4c042f6c2 ci/GHA: revert concurrency and improve permissions
Statuses are per AppVeyor event and commit, not pull-request.
Also align permissions approach with curl, least priviledge.

Partially reverts b08cfbc99f.
2024-07-27 20:50:42 +02:00
Will Cosgrove
a50d7debfd Always init mbedtls_pk_context (#1430)
In the failure case, mbedtls_pk_context could be free'd without first being initialized.
2024-07-23 10:32:13 -07:00
Viktor Szakats
457b02e8dd mbedtls: tidy-up (#1429) 2024-07-22 11:50:38 -07:00
Will Cosgrove
1701d5c0d3 Correctly initialize values (#1428)
Fix regression with commit from #1421
2024-07-22 09:57:24 -07:00
Viktor Szakats
c0357b73a2 RELEASE-NOTES: sync [ci skip] 2024-07-14 11:01:49 +02:00
Seo Suchan
1628f6cab8 mbedtls: expose mbedtls_pk_load_file() for our use
While it's moved to pk_internal, it won't removed in mbedTLS 3.6 LTS
so it's safe to redeclare it on our side to find it.

This is implementing emergency fix suggested from
2e4c5ec462 (commitcomment-141379351)

Follow-up to e973493f99 #1393
Follow-up to 2e4c5ec462 #1349
Closes #1421
2024-07-13 17:47:53 +02:00
Viktor Szakats
42ef8f3f0b ci/GHA: simplify mbedTLS build hack for autotools (#1425)
Follow-up to e973493f99 #1393
2024-07-13 11:40:07 +02:00
Michael Buckley
9f23a3bbaf Always check for null pointers before calling _libssh2_bn_set_word (#1423) 2024-07-12 21:24:18 -07:00
Viktor Szakats
ae04b1b953 ci/GHA: FreeBSD 14.1, actions bump (#1424) 2024-07-12 01:54:26 +02:00
Michael Buckley
75de6a37cb Increase SFTP_HANDLE_MAXLEN back to 4092 (#1422)
Match OpenSSH for compatibility.
2024-07-11 13:42:00 -07:00
Viktor Szakats
c6d42df5d3 ci/GHA: tidy up casing [ci skip] 2024-07-10 00:29:00 +02:00
Viktor Szakats
420f902617 REUSE: fix typo in comment 2024-07-06 02:37:34 +02:00
Viktor Szakats
99723f07af REUSE: shorten and improve
Follow-up to 70b8bf314c #1419
2024-07-05 16:42:31 +02:00
Viktor Szakats
70b8bf314c REUSE: upgrade to REUSE.toml
Closes #1419
2024-07-05 15:13:18 +02:00
Viktor Szakats
2677d3b087 build: stop detecting sys/param.h header
This header is no longer used.

Follow-up to 12427f4fb8 #1415
Closes #1418
2024-07-04 01:59:58 +02:00
Nicolas Mora
12427f4fb8 tests: avoid using MAXPATHLEN, for portability
`MAXPATHLEN` is not present in some systems, e.g. GNU Hurd.

Co-authored-by: Viktor Szakats
Ref: 54bef4c5da #198
Fixes #1414
Closes #1415
2024-07-03 23:42:43 +02:00
Viktor Szakats
a0310699f5 cmake: sync formatting in cmake/Find* modules 2024-07-03 22:27:18 +02:00
Michael Buckley
fb6527468c sftp: implement posix-rename@openssh.com
Add a new function `libssh2_sftp_posix_rename_ex()` and
`libssh2_sftp_posix_rename()`, which implement
the posix-rename@openssh.com extension.

If the server does not support this extension, the function returns
`LIBSSH2_FX_OP_UNSUPPORTED` and it's up to the user to recover, possibly
by calling `libssh2_sftp_rename()`.

Co-authored-by: Viktor Szakats (bump to size_t)
Closes #1386
2024-06-26 19:31:34 +02:00
Viktor Szakats
dc206408c1 src: use UINT32_MAX
Needs to be defined for platforms missing it, e.g. VS2008.

Closes #1413
2024-06-26 16:34:40 +02:00
Michael Buckley
1910184376 Fix a memory leak in key exchange. (#1412)
Original fix submitted as a patch by Trzik.

Co-authored-by: Michael Buckley <michael@panic.com>
2024-06-25 11:11:25 -07:00
Viktor Szakats
dd74b02bba RELEASE-NOTES: sync [ci skip] 2024-06-25 12:33:42 +02:00
Viktor Szakats
a5b0fac292 wolfssl: fix EVP_Cipher() use with v5.6.0 and older
Add workaround for the wolfSSL `EVP_Cipher(*p, NULL, NULL, 0)` bug to
make libssh2 work with wolfSSL v5.6.0 and older.

wolfSSL fixed this issue in v5.7.0:
https://github.com/wolfSSL/wolfssl/pull/7143
b0de0a1c95

Without our local workaround:

- v5.3.0 and older fail most tests:
  Ref: https://github.com/libssh2/libssh2/actions/runs/9646827522/job/26604211476#step:17:1263

- v5.4.0, v5.5.x, v5.6.0 fail these:
  ```
  29 - test_read-aes128-cbc (Failed)
  30 - test_read-aes128-ctr (Failed)
  32 - test_read-aes192-cbc (Failed)
  33 - test_read-aes192-ctr (Failed)
  34 - test_read-aes256-cbc (Failed)
  35 - test_read-aes256-ctr (Failed)
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/9646827522/job/26604233819#step:17:978

Oddly enough the workaround breaks OpenSSL tests, so only enable it for
the affected wolfSSL versions.

Also add new build-from-source wolfSSL CI job to test the new codepath.

wolfSSL has a build bug where `wolfssl/options.h` and
`wolfssl/version.h` are not copied to the `install` destination with
autotools. With CMake it has a different bug where `wolfcrypt/sp_int.h`
is not copied (with v5.4.0). And another with CMake where `FIPS_mode()`
remains missing (with v5.6.0 and earlier.)

Therefore use CMake with v5.5.4 and a workaround for `FIPS_mode()`.
Another option is autotools with v5.4.0 and a workaround for `install`,
but CMake builds quicker.

Regression-from 3c953c05d6 #797
Fixes #1020
Fixes #1299
Assisted-by: Michael Buckley via #1394
Closes #1394 (another attempt to fix the mentioned wolfSSL bug)
Closes #1407
2024-06-24 17:01:39 +02:00
Viktor Szakats
5cab802c55 wolfssl: bump version in upstream issue comment [ci skip] 2024-06-24 15:00:29 +02:00
Viktor Szakats
260a721cbe wolfssl: require v5.4.0 for AES-GCM
Earlier versions crash while running tests.

This patch is part of a series of fixes to make wolfSSL AES-GCM support
work together with libssh2.

Possibly related is this wolfSSL bugfix patch, released in v5.4.0:
https://github.com/wolfSSL/wolfssl/pull/5205
fb3c611275
"Fix another AES-GCM EVP control command issue"

Ref: #1020
Ref: #1299
Cherry-picked from #1407
Closes #1411
2024-06-24 14:59:02 +02:00
Viktor Szakats
fbd9d19279 tests: fix excluding AES-GCM tests
Replace hard-coded crypto backends and rely on `LIBSSH2_GCM` macro
to decide whether to run AES-GCM tests.

Without this, build attempted to run AES-GCM tests (and failed)
for crypto backends that have conditional support for this feature, e.g.
wolfSSL without the necessary features built-in
(as in before Homewbrew wolfssl 5.7.0_1, or OpenSSL v1.1.0 and older).

This patch is part of a series of fixes to make wolfSSL AES-GCM support
work together with libssh2.

Cherry-picked from #1407
Closes #1410
2024-06-24 14:39:31 +02:00
Viktor Szakats
1c0b07a726 ci/GHA: fix wolfSSL-from-source AES-GCM tests
Turns out these tests:
```
31 - test_read-aes128-gcm@openssh.com (Failed)
36 - test_read-aes256-gcm@openssh.com (Failed)
```
were failing because AES-GCM wasn't enabled in libssh2. This in turn
happened because the `WOLFSSL_AESGCM_STREAM` macro wasn't enabled while
building wolfSSL. Which happened because this macro isn't enabled by
any CMake-level wolfSSL option. Passing it as `CPPFLAGS` fixes it.

This allows enabling tests with wolfSSL 5.7.0.

Follow-up to d4cea53f53 #1408
Closes #1409
2024-06-22 01:56:17 +02:00
Viktor Szakats
d4cea53f53 ci/GHA: add Linux job with latest wolfSSL built from source
After this patch it's possible to run tests with wolfSSL 5.7.0.

wolfSSL 5.7.0 fixes this bug that affects open issues #1020 and #1299:
https://github.com/wolfSSL/wolfssl/pull/7143

`-DWOLFSSL_OPENSSLALL=ON` is necessary for `wolfSSL_FIPS_mode()`

Closes #1408
2024-06-22 00:52:47 +02:00
Viktor Szakats
2c63303384 ci/GHA: tidy up build-from-source steps [ci skip]
- make curl downloads less verbose.

- fix cmake warning:
  ```
  CMake Warning:
    No source or binary directory provided.  Both will be assumed to be the
    same as the current working directory, but note that this warning will
    become a fatal error in future CMake releases.
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/9509866494/job/26213472410#step:5:32
2024-06-22 00:29:25 +02:00
Adam
ac2e8c73b1 src: fix type warning in libssh2_sftp_unlink macro
The `libssh2_sftp_unlink` macro was implicitly casting the `size_t`
returned by `strlen` to the `unsigned int` type expected by
`libssh2_sftp_unlink_ex`.

This fix adds an explicit cast to match similar macro definitions in
the same file (e.g. `libssh2_sftp_rename`, `libssh2_sftp_mkdir`).

Closes #1406
2024-06-14 04:47:44 +02:00
Viktor Szakats
c149a12721 libssh2.pc: reference mbedcrypto pkgconfig
mbedtls 3.6.0 got pkgconfig support:
a4d17b34f3

Reference it from `libssh2.pc`.

Closes #1405
2024-06-08 02:53:20 +02:00
Viktor Szakats
792e1b6fbc tidy-up: typo in comment [ci skip] 2024-06-08 00:49:14 +02:00
Viktor Szakats
e23dea609a RELEASE-NOTES: sync [ci skip]
Also bump planned deprecation dates.
2024-06-07 00:55:18 +02:00
Viktor Szakats
dab48398b9 ci/GHA: show configure logs on failure and other tidy-ups
- dump cmake error log on configure failure. (for cmake 3.26 and newer)
- dump `config.log` on autotools configure failure.
- convert specs filename to Windows format before passing to CMake.
- add missing quotes.

Closes #1403
2024-06-05 14:05:03 +02:00
Viktor Szakats
6f3d3bc8ff ci/GHA: bump parallel jobs to nproc+1
Ref: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

Closes #1402
2024-06-04 23:26:53 +02:00
Viktor Szakats
b8ffa7a56d ci/GHA: show test logs on failure
Closes #1401
2024-05-31 22:34:23 +02:00
Viktor Szakats
839bb84e89 ci/GHA: fix Dockerfile failing after Ubuntu package update
Likely due an upstream Ubuntu package update (requiring an apt-get
install call beforehand), tests run via autotools started failing with
no change in the libssh2 repo:
```
FAIL: test_aa_warmup
====================

Error running command 'docker build --quiet -t libssh2/openssh_server %s' (exit 256): Dockerfile:10
--------------------
   8 |      && apt-get clean \
   9 |      && rm -rf /var/lib/apt/lists/*
  10 | >>> RUN mkdir /var/run/sshd
  11 |
  12 |     # Chmodding because, when building on Windows, files are copied in with
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /var/run/sshd" did not complete successfully: exit code: 1

Failed to build docker image
Cannot stop session - none started
Cannot stop container - none started
Command: docker build --quiet -t libssh2/openssh_server ../../tests/openssh_server
FAIL test_aa_warmup (exit status: 1)
```
Ref: https://github.com/libssh2/libssh2/actions/runs/9322194756/job/25662748095#step:11:390

Fix it by skipping `mkdir` if `/var/run/sshd` already exists.

(Why cmake-based jobs aren't affected, I don't know.)

Ref: 50143d5867 (commitcomment-142560875)
Closes #1400
2024-05-31 21:21:30 +02:00
Viktor Szakats
50143d5867 ci/GHA: use ubuntu-latest with OmniOS job
It's the same as ubuntu-22.04.

Also update OmniOS package search link.
2024-05-30 12:12:20 +02:00
Viktor Szakats
e44f041805 ci: disable dependency tracking in autotools builds
For better build performance. Dependency tracking causes a build
overhead while compiling to help a subsequent build, but in CI there is
never one and the extra work is discarded.

Closes #1396
2024-05-27 21:41:38 +02:00
Viktor Szakats
e973493f99 mbedtls: fail to compile with v3.6.0 outside CI
A compile-time failure is preferred over an unexpected one at
runtime.

The problem is silenced with a macro in CI and this macro will have
to be added to more platforms when mbedTLS v3.6.0 reaches them.

Follow-up to 2e4c5ec462 #1349
Closes #1393
2024-05-24 19:22:29 +02:00
Viktor Szakats
38e50aa06e tests: drop default cygpath option -u 2024-05-24 15:40:54 +02:00