Commit Graph

214 Commits (2425f7c5945df94320091da343b0ed9ee1533a5e)

Author SHA1 Message Date
Yosuke Shimizu 2425f7c594 Bound OSC index before reads in wolfSSH_DoOSC 2026-06-18 11:00:42 -07:00
Yosuke Shimizu 4cf61a1368 Bound server-side inbound SFTP request size in wolfSSH_SFTP_read 2026-06-18 10:02:10 -07:00
Yosuke Shimizu 1efd64743c wolfssh/scp: complete rekey that starts mid-transfer 2026-06-16 15:56:50 -07:00
Yosuke Shimizu cb9bb7a2a7 Fix SFTP client states dropping unsent bytes after partial channel send 2026-06-16 11:21:19 -07:00
John Safranek 92e1bdcb18 Add DoUserAuthRequestRsaCert sig-parse test
Run the DoUserAuthRequestRsa vectors through the X.509 path to pin
that a raw signature with a high leading bit is accepted via the
RFC 6187 branch. keys/ has no RSA certificate, so the test embeds a
self-signed cert made from keys/hansel-key-rsa.pem (valid until
May 2048).
2026-06-15 21:34:16 -07:00
John Safranek 31d13697a6 Bind ECDSA host key curve to negotiated algo
- Validate blob algorithm name against handshake pubKeyId
- Derive curve from negotiated algo, not the key blob
- Check curve name instead of skipping it
- Add a ParseECCPubKey test checking the key blob algorithm and
  curve names are validated against the negotiated host key
  algorithm.

Issue: #1012
2026-06-15 21:34:16 -07:00
John Safranek 848ba54b55 Reject negative mpints in GetMpint
- GetMpint now rejects values with the sign bit set as
  non-canonical (RFC 4251 Section 5) and is rewritten in
  terms of GetStringRef.
- Parse RSA signature blobs with GetStringRef; they are
  strings of raw signature bytes (RFC 4253 Section 6.6),
  not mpints, and often have the high bit set.
- Add unit test covering GetMpint parsing and rejection.
- Add a DoUserAuthRequestRsa test pinning the string parse of
  the signature blob with a fixed signature whose leading byte
  has the high bit set; an mpint parse would reject it as
  negative.

Issue: #1013
2026-06-15 21:34:16 -07:00
John Safranek e2b7ad5d21 Reject non-CA peer intermediate certs
- Add CertManIntermediateIsCA: require isCA and, for non-self-signed
  intermediates that carry a KeyUsage extension, the keyCertSign bit
  before promoting a cert.
- Only promote a verified intermediate into the trust store when it is
  actually a CA; otherwise fail with WS_CERT_NO_SIGNER_E.
- Prevents a peer-supplied end-entity cert at an intermediate position
  from being trusted to issue certs for arbitrary SSH principals.
- Gate keyCertSign on ALLOW_INVALID_CERTSIGN and on the KeyUsage
  extension being present, matching wolfSSL's AddCA loader.
- Add regression tests: non-CA intermediate is not promoted, and a
  valid CA intermediate (with and without KeyUsage) still is.

Issue: F-5851
2026-06-15 15:48:03 -07:00
David Garske ba09b582ba
Merge pull request #1007 from ejohnstown/hex2octal
Convert file permission hex constants to octal
2026-06-09 14:22:34 -07:00
Yosuke Shimizu a760b9a1d2 apps/wolfssh: fix ssh://hostname destination without explicit port 2026-06-09 11:11:37 -07:00
Yosuke Shimizu d49b15f51a SFTP path confinement and status-reply refactor 2026-06-09 10:46:17 -07:00
John Safranek 3abdc22355 Convert file permission hex constants to octal
- Replace hex literals (0x1ED, 0x124, 0x4000, etc.) with octal
  equivalents (0755, 0444, 040000) in SCP/SFTP attribute handling
2026-06-08 10:39:48 -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 0f11691a07 Harden a file handle validation into SFTP Recv functions 2026-06-08 09:27:01 -07:00
Yosuke Shimizu 5a19e449c6 Add upper limit of max window size and packet size, Add unit tests 2026-06-08 08:53:53 -07:00
Yosuke Shimizu aa04eca815 Fix SFTP rekey transparency in buffer_read and buffer_send 2026-06-04 14:36:20 -07:00
Yosuke Shimizu 4ae8eee109 Add tests for DoUserAuthRequestRsa and DoUserAuthRequestRsaCert 2026-05-27 14:44:10 -07:00
Yosuke Shimizu b9dfa042bf Add scpDirDepth as depth guard and Add unit tests 2026-05-27 14:06:18 -07:00
Yosuke Shimizu 3b867e7313 Add unit tests and regress tests 2026-05-27 11:13:54 -07:00
John Safranek fd29780c8e DoProtoId: case-sensitive SSH- prefix match
- Per RFC 4253 4.2 use WSTRNCMP instead of WSTRNCASECMP for
  prefix and full-ID comparisons.
- Update client tests; add server test vectors expecting
  rejection of lowercase/mixed case.

Issue: F-2865
2026-05-21 11:42:43 -07:00
John Safranek be4aa445d5 DoNewKeys: reject NEWKEYS with non-empty payload
- Reject SSH_MSG_NEWKEYS when len != 0 per RFC 4253 7.3.
- Update wolfSSH_TestDoNewKeys to take buf/len/idx instead
  of assuming NULL/0, and add a non-zero len test case.

Issue: F-2079
2026-05-21 11:42:43 -07:00
John Safranek 63a63cf0fb CERTMAN_VerifyCerts_buffer: reject certsCount=0
- Without the guard, inner loops short-circuit and WS_SUCCESS
  is returned without any verification.
- Add test case covering the new and existing bad-arg paths.

Issue: F-409
2026-05-21 11:42:43 -07:00
John Safranek bcbb8e1ad7 DoKexInit: enforce zero KEXINIT reserved field
- Per RFC 4253 7.1 the reserved field is uint32 0, not a length
  prefix; reject non-zero values with WS_PARSE_E.
- Add regression test.

Issue: F-869
2026-05-21 11:42:43 -07:00
John Safranek e8793bb268 UTF-8 -> 7-bit ASCII cleanup
1. replace section symbol with 'sec'
2. replace right arrow with '->'
3. replace m-dash with '--'
4. replace less-than-equatal-to with '<='
2026-05-18 14:35:58 -07:00
Yosuke Shimizu 67496a385d Fix minor issues and Add unit tests 2026-05-18 14:02:52 -07:00
John Safranek 162dd7fbc6 Test ForceZero of secrets in free and DH KEX
- Add retain-on-free and size-tracking capture allocators to inspect
  freed buffers post-free.
- Verify SshResourceFree zeroes ssh->k, ssh->keys, and ssh->peerKeys
  before wolfSSH_free releases the struct.
- Verify KeyAgreeDh_client wipes ssh->handshake->x even when wc_DhAgree
  fails (ForceZero is unconditional).
- Verify KeyAgreeDh_server zeroes the MAX_KEX_KEY_SZ y_ptr allocation
  under WOLFSSH_SMALL_STACK via 0xCC poisoning.
- Expose KeyAgreeDh_client / KeyAgreeDh_server via wolfSSH_Test* hooks
  under WOLFSSH_TEST_INTERNAL.

Issues: F-2488, F-2492, F-2493, F-2875
2026-05-14 14:42:20 -07:00
Yosuke Shimizu 7d4fa32ce5 Fix minor issues and add unit test for IdentifyAsn1Key 2026-05-13 09:12:20 -07:00
Yosuke Shimizu 7d7d04dc70 Fix minor issues and Add unit test for wrong padded OpenSSH key 2026-05-12 13:14:56 -07:00
John Safranek 8231703875 Fix Ed25519 user-auth verify and add unit test
- Map ed25519 verify_msg_final errors to WS_CRYPTO_FAILED
  and status==0 to WS_ED25519_E (no longer overwritten)
- Expose DoUserAuthRequestEd25519 via test shim
- Add unit test covering valid and tampered signatures

Issue: F-3445
2026-05-11 22:28:44 -07:00
Yosuke Shimizu a5eb03c01b Add integration test for wrong ECC signature scenario 2026-05-11 16:25:21 -07:00
John Safranek 60de6ff9c5 rekey: trigger highwater on per-key packet count
- Track txMsgCount/rxMsgCount per key epoch and reset on NEW_KEYS;
  seq/peerSeq still wrap freely per RFC 4253 Sec 6.4.
- Extend HighwaterCheck to fire highwaterCb when packet count crosses
  msgHighwaterMark (default 2^31, RFC 4344 Sec 3.1).
- Add wolfSSH_CTX_SetMsgHighwater / SetMsgHighwater / GetMsgHighwater.
- Consolidate receive-path HighwaterCheck into DoPacket so byte- and
  packet-count thresholds share a single canonical fire site.

Issue: F-246
2026-05-11 12:29:21 -07:00
Yosuke Shimizu a8a443214b Add independent ciper and MAC algorithms negotiation for each direction, And add regress test 2026-05-08 10:26:22 -07:00
Yosuke Shimizu 0068d52e01 Add service-name check and regress test 2026-05-07 09:45:11 -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 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 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 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
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 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 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
Yosuke Shimizu cd7a7f47c3 Fix DoChannelRequest and Add unit test for DoChannelRequest 2026-04-21 16:18:24 -07:00
Yosuke Shimizu b007310fa2 Fix wolfSSH_RealPath tests 2026-04-21 16:01:41 -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
Yosuke Shimizu fe89681f9b Add unit test for DoUserAuthBanner 2026-04-20 17:05:05 +09:00