Commit Graph

2678 Commits (8d97ee9250d4b83fefa0479a99516da45e31ad45)

Author SHA1 Message Date
Yosuke Shimizu 0068d52e01 Add service-name check and regress test 2026-05-07 09:45:11 -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 67946018ac sftp: parse attrs and names via Get* parsers
Replace the hand-written ato32 plus localIdx + N > maxIdx checks in
SFTP_ParseAttributes_buffer with GetUint32 and GetSkip, and drop the
manual length plus copy sequences in wolfSSH_SFTP_DoStatus and
wolfSSH_SFTP_DoName in favor of GetStringRef so the bounds-check
arithmetic lives in one place.
2026-04-30 19:28:52 -07:00
John Safranek a79abf7b0c sftp: fix Atributes typo
Rename SFTP_ParseAtributes_buffer and SFTP_AtributesSz (and the
unused SFTP_ParseAtributes) to spell "Attributes".
2026-04-30 19:28:52 -07:00
John Safranek 89e0175222 sftp: route Recv* parsers through GetStringRef
Convert the unflagged server Recv* handlers (RecvRealPath, RecvRMDIR,
RecvMKDIR, RecvOpenDir, RecvReadDir, RecvClose, RecvRemove, RecvFSTAT,
RecvSTAT, RecvLSTAT, RecvSetSTAT, RecvFSetSTAT) to GetStringRef,
GetSize, and GetUint32 so all Recv* paths share one bounds-checked
idiom.
2026-04-30 19:28:52 -07:00
John Safranek 6496007058 sftp: bounds-check ato32 reads in flagged Recv*
Convert RecvOpen, RecvWrite, RecvRead, and RecvRename (POSIX and
Windows) to GetUint32, GetSize, and GetStringRef so each ato32 reads
only what the buffer can supply.

Issue: F-412
2026-04-30 19:28:52 -07:00
John Safranek 73b10ad26d Drop redundant mlkem.h include 2026-04-30 14:23:40 -07:00
John Safranek 4dcaf6e3d2 DoProtoId: skip pre-version banner lines
1. Client skips non-SSH lines (RFC 4253 4.2); server rejects them
2. 255-byte per-line cap and 10-line cap (WOLFSSH_MAX_BANNER_LINES)
3. 28 test vectors plus scripted-IO mock for WANT_READ resumption

Issue: F-606
2026-04-29 14:21:23 -07:00
John Safranek 444aa0f08a Export Windows Function Wrappers
Retag the WS_FindFirstFileA() and WS_FindNextFileA() functions as
WOLFSSH_API, not just local. They are used in the example SFTP client.
2026-04-28 16:31:19 -07:00
John Safranek f0c17282bc Client: check first_packet_follows guess in DoKexDhReply
When a server sends first_kex_packet_follows=TRUE with an incorrect KEX
algorithm guess, the client now silently discards the server's speculative
KEXDH_REPLY message by checking ignoreNextKexMsg at the top of DoKexDhReply,
matching the existing server-side handling in DoKexDhInit. Add regression
test covering the client-side skip path.

Affected functions: DoKexDhReply.
Issue: F-2863
2026-04-27 17:31:36 -07:00
John Safranek b610dd75c4 sftp Client Windows Version
The project file for the wolfSFTP example client is specifying a
too-specific Windows target platform version. It is the only project
file specifying the version to four places. Removed it and using the
default Windows version for the version of the build tools.
2026-04-27 13:42:06 -07:00
Yosuke Shimizu 7241f4e67c Add warning to make non-registered channelOpenCb visible 2026-04-24 10:25:34 -07:00
John Safranek 3a5aa65369 Small Test Reorganization
1. Collect all the test function wrappers in internal.c to one location
   at the end of the file.
2. Update API test to check other algos if RSA or ECDSA are disabled.
3. Added guarded tests TestClientBuffersIdempotent() for WOLFSSH_NO_RSA
   and WOLFSSH_NO_ECDSA_SHA2_NISTP256. If both are set, the test is
   skipped.
2026-04-24 09:43:56 -07:00
Yosuke Shimizu fdf621c83a Add log for LoginGraceTime on windows, Add regress test and fix minor issues 2026-04-23 10:19:13 -07:00
Yosuke Shimizu b557998ddf Add default loginTimer 2026-04-23 10:19:13 -07:00
Yosuke Shimizu 96f3aa7c21 Fix DoRequestSuccess and DoRequestFailure, Add regress test 2026-04-23 10:10:34 -07:00
Yosuke Shimizu 0479a3a705 Add unit test for ChannelPutData 2026-04-23 09:19:42 -07:00
Joseph Chen 8e2e3c5327 Improve MQX filesystem compatibility 2026-04-22 13:45:32 -07:00
John Safranek 3df6bcfaf5 First Kex Packet Follows Test
Add a regression for checking the `first_kex_packet_follows` flag versus
the guesses for KEX algorithm and public key algorithm.
2026-04-22 10:51:01 -07:00
John Safranek 55d48e6b24 First packet follows check needs pubkey guess
When processing the KEX Init message, stash guesses for the peer's
KEX and public key algorithms. When reading first_packet_follows, if set
check the guesses and set the handshake info flag ignoreNextKexMsg. When
processing the KexDhInit message, check that flag.

Affected functions: DoKexInit, DoKexDhInit.
Issue: F-1686
2026-04-22 10:51:01 -07:00
John Safranek 61186558b8 Fix warning for unchecked dup return in regress.c 2026-04-22 10:27:06 -07:00
John Safranek aad92b54ea Fix warning for unchecked errno in api.c test
Replace rewind() with fseek(f, 0, SEEK_SET) in the test helper
function. rewind() internally clears errno, which scan-build flags
as overwriting a previously unchecked errno value. fseek() to
offset 0 is functionally equivalent without the implicit errno
reset.
2026-04-22 10:27:06 -07:00
John Safranek 97ad915726 Fix warning for unchecked errno in WREWIND macro
Replace rewind() with fseek(s, 0, SEEK_SET) in the WREWIND macro.
rewind() internally clears errno, which scan-build flags as
overwriting a previously unchecked errno value. fseek() to offset 0
is functionally equivalent without the implicit errno reset.
2026-04-22 10:27:06 -07:00
John Safranek 1b971ffaf4 Fix scan-build warning for undefined errno read after execv
Remove the errno check in the condition after execv(). If execv()
returns at all, it has failed, so checking ret alone is sufficient.
The errno check was flagged by clang scan-build as potentially
reading an undefined value (unix.Errno).
2026-04-22 10:27:06 -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
John Safranek afedde7a1d Fix Potential Double Free
Static analysis indicated the potential to double-free a pointer in the
`wolfSSH_CTX_UseCert_buffer()` test. Loading the second cert after
freeing the first cert could fail and the test cleanup would free the
pointer again. Just set pointer to null after freeing.
2026-04-22 10:27:06 -07:00
Yosuke Shimizu 19d34a8df7 Add auth tests to verify cases of invalid/unknowen return value 2026-04-22 08:32:24 -07:00
Yosuke Shimizu e7226d0f29 Add unit test for wolfSSH_RsaVerify 2026-04-22 08:25:13 -07:00
Paul Adelsbach 90c0ee6a7c Add zeroization in wolfSSH_ProcessBuffer 2026-04-21 16:25:12 -07:00
Paul Adelsbach 3f03a851c5 Fix word16 truncation in internal.c 2026-04-21 16:24:01 -07:00
Paul Adelsbach aa974545a0 Fix uninit variable in KeyAgreeEcdh_server 2026-04-21 16:20:30 -07:00
Paul Adelsbach 1cb644d2d4 Fix Nucleus log variable 2026-04-21 16:19:18 -07:00
Yosuke Shimizu cd7a7f47c3 Fix DoChannelRequest and Add unit test for DoChannelRequest 2026-04-21 16:18:24 -07:00
Paul Adelsbach 0d283d2dd3 Add check for all zeros in CreateMpint 2026-04-21 16:03:08 -07:00
Yosuke Shimizu b007310fa2 Fix wolfSSH_RealPath tests 2026-04-21 16:01:41 -07:00
John Safranek 2d981ae87b
Merge pull request #930 from yosuke-wolfssl/f_2073
Add wc_Sha256Free after the final use
2026-04-21 15:55:22 -07:00
John Safranek 6d09901166
Merge pull request #924 from yosuke-wolfssl/f_2485
Add kex integration test for ed25519 server key
2026-04-21 11:14:26 -07:00
John Safranek a608f1944f
Merge pull request #923 from yosuke-wolfssl/f_2484
Add additional regress test for DoKexDhReply
2026-04-21 09:46:43 -07:00
John Safranek 8552be0cc5
Merge pull request #938 from padelsbach/require-wolfssh-cert
Require wolfssl to be built with --enable-wolfssh
2026-04-21 09:34:19 -07:00
Paul Adelsbach 2b0cc74e30 Require wolfssl to be built with --enable-wolfssh 2026-04-21 09:22:11 -07:00
John Safranek 87c0b05d72 Userauth none bypasses wolfSSHd credential check
When wolfsshd is built with WOLFSSH_ALLOW_USERAUTH_NONE, the
DefaultUserAuth() function accepted WOLFSSH_USERAUTH_NONE as a valid
auth type and forwarded it to RequestAuthentication(). Since
RequestAuthentication() only gates credential checks on PASSWORD and
PUBLICKEY types, a none request for any existing system user returned
success without verifying any credential. Removed USERAUTH_NONE as an
accepted auth type in DefaultUserAuth() so it is treated as an invalid
auth type for wolfsshd.

Affected function: DefaultUserAuth.
Issue: F-3215
2026-04-21 09:20:12 -07:00
John Safranek 2568b26b84
Merge pull request #914 from padelsbach/negative-test-cases
Add negative test case for CheckPasswordHashUnix
2026-04-20 11:26:04 -07:00
John Safranek 8efa825d18
Merge pull request #937 from yosuke-wolfssl/f_865
Fix DoUserAuthBanner()
2026-04-20 11:02:05 -07:00
Paul Adelsbach 80da96eebb Add negative test case for CheckPasswordHashUnix 2026-04-20 09:58:07 -07:00
Yosuke Shimizu fe89681f9b Add unit test for DoUserAuthBanner 2026-04-20 17:05:05 +09:00
Yosuke Shimizu c3c51530e1 Fix DoUserAuthBanner() 2026-04-20 16:33:46 +09:00
John Safranek 8643d7be84
Merge pull request #933 from JacobBarthelmeh/release
prepare for release 1.5.0
2026-04-17 18:03:22 -07:00
John Safranek 6b89cb75c7
Merge pull request #928 from JacobBarthelmeh/cpp
fixes for c++ error on missing enum cast and warning on MlKemKey init
2026-04-17 10:34:09 -07:00
John Safranek 0049c55b1b
Merge pull request #931 from yosuke-wolfssl/f_2074
Fix wolfSSHD_ConfigCopy and wolfSSHD_ConfigFree
2026-04-17 10:24:29 -07:00
JacobBarthelmeh 2712061d98 prepare for release 1.5.0 2026-04-17 10:49:48 -06:00