Commit Graph

67 Commits (8d97ee9250d4b83fefa0479a99516da45e31ad45)

Author SHA1 Message Date
John Safranek f8c43e17ae Test DoChannelWindowAdjust overflow guard
- Add test_DoChannelWindowAdjust_overflow via new
  wolfSSH_TestDoChannelWindowAdjust wrapper.
- Seed non-zero peer window, feed bytesToAdd = UINT32_MAX,
  assert WS_OVERFLOW_E with window unchanged.
- Feed a fitting value, assert window advances.
- Covers the guard so flipping or deleting it now fails.

Issue: F-2874
2026-07-13 14:26:41 -07:00
John Safranek 9e02350aaa Reject password-change auth requests
- fail userauth when the request sets the password-change flag
- do not invoke the userauth callback with the current password
- parse the new-password field so the message is fully consumed
- add negative unit test asserting USERAUTH_FAILURE and no callback

Per RFC 4252 section 8, an expired password MUST NOT be used to
authenticate; password changes remain unsupported.

Issue: #1047 (6)
2026-07-08 18:00:23 -07:00
John Safranek df635a3e16 Reject packets with too-little padding
- enforce RFC 4253 section 6 minimum of 4 padding bytes on receive
- return WS_BUFFER_E when padding_length is below MIN_PAD_LENGTH
- add negative unit test driving DoReceive with a short-padded packet

Issue: #1047 (5)
2026-07-08 18:00:23 -07:00
John Safranek dcee1ffa87 Simplify redundant KEX method flags
- remove redundant useCurve25519MlKem HandshakeInfo flag
- merge the duplicate Curve25519 keygen branch in SendKexDhInit
- order the client KeyAgree dispatch to match the combined flags
- rename the surviving flags for clarity: useEcc->useEcdh and
  useEccMlKem->useMlKem
- make the flag set orthogonal: each ML-KEM hybrid now sets its
  classical-component flag (useEcdh or useCurve25519) alongside useMlKem,
  so the four bits independently describe every KEX family
- apply the same flag handling to the server SendKexDhReply path
2026-07-08 18:00:23 -07:00
John Safranek 71d8529306 Validate peer KEX public keys
- ECDH and ECC+ML-KEM hybrid: validate the peer point through a shared
  EccCheckPeerKey helper (import + wc_ecc_check_key) on client and server,
  so the plain and hybrid paths cannot diverge
- add wolfSSH_TestKeyAgreeEcdh_server/client and wolfSSH_TestSetDhKexKey
  test hooks
- add negative unit tests rejecting bad DH and off-curve ECDH peer keys on
  client and server; the hybrid paths share the same helper and are
  exercised by kex.test

Issues: F-5690, #1047 (1)
2026-07-08 18:00:23 -07:00
Yosuke Shimizu 90692e6995 Validate peer DH public value before key agreement 2026-07-06 17:10:02 -05:00
Emma Stensland c56dc1027f added ml-dsa plain key and cert algorithms 2026-07-06 16:51:21 -05:00
Yosuke Shimizu 336a759af5 Bind SCP file timestamps to open descriptor 2026-06-26 13:42:52 -07:00
Yosuke Shimizu cd3ccd6f49 Bound SFTP NAME response size on the client 2026-06-26 12:10:32 -07:00
Yosuke Shimizu 916af608f6 wolfscp: fix ExtractFileName for separator-less paths 2026-06-25 11:15:01 -07:00
Paul Adelsbach 1dc30ed97e Set keyAllocated=1 when initializing any key 2026-06-22 10:40:56 -07:00
Yosuke Shimizu 0256f4c8fb Reject SCP receive through pre-existing symlinks 2026-06-18 14:15:36 -07:00
Yosuke Shimizu 00e85522aa Mask special bits from peer-supplied SCP receive mode 2026-06-18 14:05:01 -07:00
Yosuke Shimizu 253c157066 wolfsshd: implement PubkeyAuthentication config directive 2026-06-18 13:08:14 -07:00
Yosuke Shimizu 4cf61a1368 Bound server-side inbound SFTP request size in wolfSSH_SFTP_read 2026-06-18 10:02:10 -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
Yosuke Shimizu b9dfa042bf Add scpDirDepth as depth guard and Add unit tests 2026-05-27 14:06:18 -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 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
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
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 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
Yosuke Shimizu 0479a3a705 Add unit test for ChannelPutData 2026-04-23 09:19:42 -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 fe89681f9b Add unit test for DoUserAuthBanner 2026-04-20 17:05:05 +09:00
John Safranek 16ddcd9764 Validate server's group
The client wasn't validating the DH group parameters in the KEX DH GEX
Group message. This adds a function to perform the validation of the
prime `p` to verify it is safe. (Prime and that ((p - 1) / 2) is
prime.) Also adds a test to a known unsafe prime and known safe prime
to verify the validate function.

Affected function: DoKexDhGexGroup.
Issue: F-1688
2026-04-16 13:42:24 -07:00
Yosuke Shimizu aa4c9ff9a0 Add unit test for VerifyMac 2026-04-14 09:23:14 +09:00
Andrew Hutchings 64de7a210f Fix gating 2026-04-08 14:57:29 +01:00
Andrew Hutchings d4a6cf80f9 Add more tests 2026-04-08 14:42:30 +01:00
John Safranek 8951bd9209 Release v1.4.22
1. Update copyright date to 2026.
2025-12-29 16:53:33 -08:00
Timo Kokkonen d557c244f2 Add ED25519 key generation support. 2025-07-30 23:45:19 -07:00
John Safranek 1736a4cabf
Update Copyright Date
1. Bring all copyright dates up to 2024.
2. Fix a few files with incorrect licensing.
2024-03-22 12:17:09 -07:00
Juliusz Sosinowicz 37412ff50f Init zephyr support
- SSH
- SFTP
- SCP
2023-10-02 20:38:21 +02:00
John Safranek 95bcc4541c
Release v1.4.13
1. Update the copyright year in all file header comments.
2. Update the STM32CUBE files to use the correct GPL headers.
2023-04-03 10:41:10 -07:00
John Safranek 99bab74d78
Release Cleanup
1. Update the release date in the ChangeLog.
2. Move some compiler guards around to hush warnings depending on the
   build options.
3. Fix a string name for ECDSA P521 algo.
4. Fix a stray static function definition.
5. For FIPSv5 builds, add CAST tests to the API test and testsuite.
6. Add the wolfSSH_Init() and wolfSSH_Cleanup() to the unit test.
2022-12-27 16:19:21 -08:00
John Safranek 6ce7e14cda
Test Tools
1. Remove the flag NO_MAIN_FUNCTION from the test tools.
2. For unit and api tests, follow the patter for the testsuite with its
   NO_TESTSUITE_MAIN_DRIVER check.
2022-10-25 09:03:19 -07:00
John Safranek c580b2c3ba
Module Static Global
1. Move ConvertHexToBin() and Base16_Decode() into test.h.
2. Add a description for the options in test.h.
3. Add a static to the hexDecode const array for Base16_Decode().
4. Add the check for options.h/user_settings.h to api and unit tests.
2022-10-24 11:32:40 -07:00
John Safranek 59b9dc6b5c
Automake Refactor
1. Rename ApiTest() and UnitTest() with wolfSSH prefix.
2. Modify wolfSSH_ApiTest() and wolfSSH_UnitTest() to take argc and argv
   parameters.
3. Add main functions to the unit and api tests, that can be left out of
   the build with the flag NO_MAIN_FUNCTION.
2022-10-20 11:48:17 -07:00
Jacob Barthelmeh 92d1f39065 update copyright date 2022-08-17 16:58:21 -06:00
John Safranek 5b8db26063
Add ECDSA Key Generation Wrapper
1. Added a wrapper function for ECDSA key generation like the RSA key
   generation.
2. Added keygen to the unit test.
2022-05-16 11:58:12 -07:00
John Safranek 796423bfac
Update tests and examples to include config.h
1. All the sources for the tests and examples did not have an include
   for config.h. This fixed some inconsistent builds with an older
   version of gcc.
2. Moved config.h from the src directory to the top level of the repo
   directory.
2022-01-26 15:06:07 -08:00
Jacob Barthelmeh ba99ddda68 run license update script 2021-11-04 13:11:53 -06:00