Commit Graph

410 Commits (52f6db9fe7baff126b9c0fe91f48d9beec7fd72a)

Author SHA1 Message Date
aidan garske 633f627422 Use shared wolfTPM2_SetKeyBlobFromBuffer parser and guard TPM signing args 2026-06-16 13:59:52 -07:00
aidan garske a2c28c9c3c Add TPM 2.0 resident server host keys for ECDSA and RSA 2026-06-16 13:59:52 -07:00
John Safranek d43dfd5b83 Coverity: Uninitialized scalar variable
1. Remove the check on authType, it is covered already.
2. Add Keyboard Setup to the existing check on authType.
3. Add a branch for User Auth None so it reaches its handler
   in the map loop rather than the new error case.
4. Add else case for an error.

Fixes CID: 637345
2026-06-16 10:20:06 -07:00
John Safranek 304955ff94 Move unsafe call out of signal handler
Cleanup clang-tidy bugprone-signal-handler findings.
- wolfsshd: drop fprintf from interruptCatch; the main accept
  loop logs "Closing down wolfSSHD" after seeing quit set.
- sftpclient: annotate wolfSSH_SFTP_Interrupt call in
  sig_handler with NOLINT, since the function is only a single
  byte store and is safe to call from a signal handler.
2026-06-09 17:03:02 -07:00
John Safranek 863a52be63 Add parameter names to function declarations
Clean up clang-tidy readability-named-parameter findings
across wolfSSH headers and sources.
2026-06-09 17:03:02 -07:00
Yosuke Shimizu 12d39dd970 examples/client: guard rxBuf indexing against negative stream_read error 2026-06-09 09:34:14 -07:00
Yosuke Shimizu ca803ec2cc Add a safe mask for peer-supplied mode and extend wolfSSH_SFTP_Open 2026-06-08 10:01:24 -07:00
Yosuke Shimizu 13db37b1b4 Fix retry loop in doAutopilot 2026-06-02 09:48:11 -07:00
John Safranek 1aac6d2f5a ClientFreeBuffers: zero secrets before free
- Zero private key and password buffers in both apps/wolfssh
  and examples client.
- Also zero keyboard-interactive response buffers in the
  example client.

Issue: F-249
2026-05-21 11:42:43 -07:00
Yosuke Shimizu fb1aa6daba Fix minor issues and Add test vectors 2026-05-14 09:36:43 -07:00
John Safranek 834e60fb77 Echoserver Channel Regrouping
Refactor of the echoserver example only; library is unchanged.

1. Collapse FwdStates and AGENT_STATE_* into a single WS_AppState
   (INIT/LISTEN/CONNECT/CONNECTED). FWD_STATE_DIRECT becomes an
   isDirect flag, cleared after connect.
2. Hoist the fields shared by the forwarding, agent, and shell paths
   into a common WS_AppCtx (privateData, listenFd, appFd, channelId,
   state, buffer). Shell only uses buffer.
3. Feature-specific remainder stays in WS_AgentCbActionCtx (name) and
   WS_FwdCbActionCtx (host/origin name+port, isDirect). Drop the unused
   pid field; inline getpid() at the call site.
4. wolfSSH_AGENT_DefaultActions and wolfSSH_FwdDefaultActions now take
   a WS_AppCtx* and reach feature-specific state via
   appCtx->privateData. echoserver_test() is updated to register the
   WS_AppCtx (not the old CbCtx) with wolfSSH_set_agent_cb_ctx and
   wolfSSH_SetFwdCbCtx.
5. Reindent ssh_worker()'s #ifdef blocks and add /* WOLFSSH_xxx */
   markers.
6. fwd.test.expect: redirect echoserver and portfwd output to log files
   and sync on portfwd's -R ready file instead of matching "sampled" in
   the pty. Under --enable-debug the WLOG volume fills the pty and
   stalls portfwd in select() before channel-open.
2026-05-05 09:05:09 -07:00
John Safranek bfbf0edbb9 7-bit Clean ASCII
Clean up the main set of files to be 7-bit clean ASCII. There were many
single and double-quotes and n-dashes.
2026-04-22 10:27:06 -07:00
Yosuke Shimizu 651e4cae8a Add kex integration test for ed25519 server key 2026-04-16 15:14:42 +09:00
Paul Adelsbach 453371f953 Add lcd and lls commands 2026-04-10 12:51:58 -07:00
Paul Adelsbach e74fd71473 Fix underflow in sftp example with empty args 2026-04-09 11:54:58 -07:00
John Safranek 2f1231d185 macOS Semaphore Cleanup
macOS uses GCD for threading and semaphores, but they aren't quite like
POSIX semaphores. macOS allows the use of named POSIX semaphores.

1. Convert the semaphores to named POSIX semaphores.
2. Simplify all calls for semaphores into single function calls of the
   wrapper API.
3. Update both examples/client/client.c and apps/wolfssh/wolfssh.c.
4. Update both to deregister the WINCH signal.
2026-03-17 19:26:32 -07:00
John Safranek f85ec920e3 Client rsa-sha2-512
1. Separate the key type and signature type when handling user
   authentication. ssh-rsa is a key type used with rsa-sha2-256 and
   rsa-sha2-512 signatures, along with ssh-rsa signatures.
2. Allow rsa-sha2-512 to be used.
3. Fix bug where setting the key algorithm on the client command line
   was setting the list to NULL.
4. Fix bug where adding rsa-sha2-512 to the list of canned algorithms
   was terminating the list, rather that adding it.

Issue: ZD-21247
2026-03-09 10:56:37 -07:00
John Safranek be69a46db0
Merge pull request #882 from JacobBarthelmeh/sftp
More robust SFTP send/read handling
2026-03-06 07:35:58 -08:00
aidan garske 09144d0c7a Add more wolfSSH CI workflows 2026-03-03 21:22:39 -08:00
JacobBarthelmeh 0539f004d3 use NoticeError throughout wolfsftp.c and account for rekey with more sftp client commands 2026-02-27 16:21:46 -07:00
John Safranek 08ce58ce7c Forwarding Test
1. Add a test script and expect script for testing forwarding.
2. Update portfwd to have a ready file option.
3. Fix echoserver error string, needed NL.
2026-02-26 15:02:19 -08:00
John Safranek 5cd81c9f1f Agent Update
1. Fix a couple unused variable warnings.
2. In wolfSSH_AGENT_DefaultActions(), fix comparison to the result of
   snprintf() treating normal result as an error. Reset the return code
   for the error state of the socket() command. Better cleanup of agent
   startup failures.
2026-02-26 14:37:07 -08:00
John Safranek 78e38999a1 Fix Test Term Size
When running the build tests, the terminal size gets set to 0x0. When
then tests finish, things like vim start to misbehave until you change
your term window size.

1. Echoserver will not change the terminal size when in echo mode.
2. Do not update the modes when the echo server is not in echo mode.
3. Do not set the terminal update callback context when the echo server
   is not in echo mode.
4. Update the guards around the above three items to match the guards for
   the modes update function.
2026-01-13 11:33:03 -08:00
John Safranek 8951bd9209 Release v1.4.22
1. Update copyright date to 2026.
2025-12-29 16:53:33 -08:00
hanshenrik 44dc148dbd replace sys/errno.h with errno.h
Historically, some systems have used <sys/errno.h> in place of <errno.h>, but the C standard,
 all the way back to C89/Ansi C, specifies that the correct name is `errno.h` -
and most modern compilers create a sys/errno.h compatibility shim sys/errno.h -
but musl-gcc does not have this compatibility shim,
 reasoning that sys/errno.h is non-standard, and fails to compile:
```
$ CC=musl-gcc ./configure --enable-static --disable-shared --enable-scp --enable-sftp --enable-shell --with-wolfssl=wolfssl/install-musl
(...)
$ make
make -j17  all-am
make[1]: Entering directory '/home/hans/projects/wolfssh'
  CC       examples/client/common.o
  CC       examples/client/client.o
  CC       src/libwolfssh_la-ssh.lo
  CC       src/libwolfssh_la-internal.lo
  CC       src/libwolfssh_la-log.lo
  CC       src/libwolfssh_la-port.lo
  CC       src/libwolfssh_la-io.lo
  CC       src/libwolfssh_la-wolfscp.lo
  CC       src/libwolfssh_la-wolfsftp.lo
  CC       examples/echoserver/echoserver.o
  CC       src/libwolfssh_la-wolfterm.lo
  CC       examples/sftpclient/sftpclient.o
  CC       examples/scpclient/scpclient.o
In file included from examples/echoserver/echoserver.c:91:
/usr/include/x86_64-linux-musl/sys/errno.h:1:2: error: #warning redirecting incorrect #include <sys/errno.h> to <errno.h> [-Werror=cpp]
    1 | #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
      |  ^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1452: examples/echoserver/echoserver.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/hans/projects/wolfssh'
make: *** [Makefile:1020: all] Error 2
```

so, unless we need to support pre-C89 (35+ year old C) compilers,
we can just replace sys/errno.h with errno.h.
2025-11-22 17:40:20 +01:00
JacobBarthelmeh 59a9227913 example max() conflicts with toolchains max() function 2025-10-17 17:00:03 -06:00
John Safranek 50aa10d717
Merge pull request #793 from JacobBarthelmeh/rekey
sanity checks on message types during rekey
2025-10-06 13:54:03 -07:00
JacobBarthelmeh 4862400a37 fix spelling issues and SFTP send state 2025-10-06 00:42:05 -06:00
JacobBarthelmeh 813ec263cc fix for scan-build report of unused return value 2025-09-16 13:52:12 -06:00
JacobBarthelmeh 2a11471bb7 refactor introducing more use of NoticeError 2025-09-16 13:30:25 -06:00
gojimmypi dccc62bafd
Rename wolfssh test certs 2025-09-03 11:10:53 -07:00
JacobBarthelmeh d74c942c84 refactor SFTP to use NoticeError 2025-08-26 10:53:38 -06:00
JacobBarthelmeh af45bc3719 update example client for rekey and sanity check on window update after read attempt 2025-08-26 10:50:14 -06:00
JacobBarthelmeh 8a8ee954d3 in want write case with example echoserver do not wait on select for data 2025-07-25 11:32:02 -06:00
JacobBarthelmeh a6e523886f fix for clang scan-build warning of variable not used 2025-07-25 11:32:02 -06:00
JacobBarthelmeh 559de0bb3d better handling of rekeying with SFTP 2025-07-25 11:32:02 -06:00
JacobBarthelmeh 01dd6ec3dc fixes for SFTP want read/write cases 2025-07-25 11:32:02 -06:00
JacobBarthelmeh 88d4eae96a remove keyboard auth callback and use generic auth callback 2025-07-25 11:31:02 -06:00
John Safranek 903bbc7fb2 Coverity: Argument cannot be negative
1. Due to not checking the result of fseek(), it is possible to try to
   malloc() -1 bytes of storage. Checking the return from fseek() and
   erring if negative.
2. Changing the check between the result of fseek() and fread() to match
   signedness. Adding some casting, as at that point the fseek() result
   is always positive.

Fixes CIDs:
  573009 572928 572868
2025-07-21 09:36:35 -07:00
John Safranek f24c3c262c Coverity: Dereference before null check
1. When cleaning the path, check that the path pointer is not null
   before using it.
2. Move the strlen of path.
3. Remove the second check of path, and just loop over it.

Fixed CID: 572847
2025-07-21 09:17:21 -07:00
John Safranek c855d9c16e Simplify Test Build Flags
1. Modify all the test executable `CPPFLAGS` to only have
   `-DNO_MAIN_LOOP` and `AM_CPPFLAGS`. This removes a lot of duplicate
   setup of flags for each of the tests.
2. Delete the echoserver's `CFLAGS`. It is just setting the `CFLAGS` for
   its compile to `AM_CFLAGS` and `AM_CPPFLAGS` which are included by
   default.
3. Add the macro WS_MAYBE_UNUSED that may be the unused attribute.
4. If INLINE isn't set to some form of inline, set it to
   WS_MAYBE_UNUSED.
5. Remove redundant ThreadStartNoJoin() macros from the testing header.
2025-07-17 15:30:24 -07:00
JacobBarthelmeh 1422697e43 add check for want write in example echoserver to handle new test case 2025-05-20 16:55:42 -06:00
JacobBarthelmeh 71cda6d16c add test case for want write return from highwater callback 2025-05-20 15:18:27 -06:00
John Safranek 0f650789de Soft Disable AES-CBC
1. By default, soft disable AES-CBC. It isn't offered as a default
   encrypt algorithm, but may be set at runtime.
2. Add guard where AES-CBC can be added back as a default.
3. Add option to example client to run it with a custom encrypt
   algorithm list.
4. In the client, add macro to add items to the arg lists while checking
   the number of items in the list.
2025-05-16 11:41:52 -05:00
Andrew Hutchings c368efb8b2 Make Keyboard Interactive a compile time option
Now an off-by-default compile-time option. This saves resources and
confusion if you are not expecting it.

ZD #19704
2025-04-22 13:12:42 +01:00
Anthony Hu 03afce7236 Forgive a socket error 2025-04-03 19:19:36 -04:00
aidan garske a52c3b120e Used W port.h file operations for keyblob and added username argument so can append any username needed. 2025-04-02 10:33:27 -07:00
aidan garske 69e266178f Used port.h macros 2025-04-01 21:58:49 -07:00
aidan garske 77c8db6cc2 Rebase for tpm public key authentication with wolfssh 2025-04-01 16:44:55 -07:00
Andrew Hutchings 08759f1943 Add FATFS Linux example
This allows a file on the Linux filesystem to be used as a FATFS file.

It also fixes a bug in `port.h` when opening file on a FATFS filesystem.
2025-02-27 12:18:05 +00:00