1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00
Commit Graph

32207 Commits

Author SHA1 Message Date
Marco Oliverio
5d1903ff34 dtls13: support session export and import
wolfSSL_dtls_export()/wolfSSL_dtls_import() only ever carried a DTLS 1.2
session. A DTLS 1.3 connection additionally keeps a table of epochs, each
with its own traffic secret, record and record number keys, sequence numbers
and replay window, and none of that was serialized.

Export version 7 adds two trailing sections to the blob, the DTLS 1.3 record
layer state and the Connection ID, both length prefixed so a reader that does
not know a section can step over it and a version 6 blob still imports.

- dtls13: serialize the send epoch, the peer epoch and, when there is one,
  the previous peer epoch: epoch numbers, sequence numbers, replay window,
  traffic secrets and key material. Import re-derives the record keys through
  Tls13DeriveRecordKeys(), the same expansion the handshake runs
- dtls: carry a tx Connection ID of any length. The peer picks it and RFC 9146
  bounds it only by its one byte length field, so DTLS_CID_MAX_SIZE may not
  refuse it. The rx id keeps that bound: it is the one we hand the peer and it
  has to fit the record layer buffers. Clear the target's CID when the blob
  carries none

Refusals, so a blob never describes a connection that cannot be restored:
- refuse to export a half sent fragmented handshake message, or while a write
  dup still has work parked
- refuse a state only import into a DTLS 1.3 session, and keep stamping the
  state only blob with export version 6
- require the imported epochs to be the ones the blob names, reset the epoch
  table on import and commit a slot only once every field of it has been read

Bounds checking on the import path:
- keep every exported section inside the buffer the caller sized, and step
  over the import sections by their declared length
- check the imported epoch key lengths against the negotiated suite and the
  traffic secret length against the hash
- size the exported key state from the build's own cipher sizes
- scrub the session export scratch buffer before freeing it
- use IsAtLeastTLSv1_3() for the imported version check

CI: build the session export job with Connection ID support.
2026-08-26 18:42:12 +02:00
Marco Oliverio
a09ec82b9b tls13: factor the record key expansion out of DeriveTls13Keys
The second half of DeriveTls13Keys() - the "key"/"iv" labels, the provision
computation and the four Tls13DeriveKey() calls, plus Dtls13DeriveSnKeys() -
is the expansion of a pair of traffic secrets into the record keys. It is
reachable only through a full secret derivation, so a caller that already
holds the secrets cannot use it.

- add Tls13DeriveRecordKeys(), which expands the traffic secrets in
  ssl->clientSecret/serverSecret into ssl->keys and derives the DTLS 1.3
  record number key; it owns the key_dig buffer and its zeroization
- DeriveTls13Keys() keeps the secret derivation, the store gate and the
  DTLS 1.3 epoch bookkeeping, and no longer allocates key_dig when store is 0

No functional change.
2026-08-26 18:42:12 +02:00
philljj
3f9f17e010 Merge pull request #11281 from danielinux/fenrir-stsafe-2026-08-26
[STSAFE] Normalize the digest to field size in ECDSA verify
2026-08-26 11:01:41 -05:00
Daniele Lacamera
5f25d46345 CI: pin STSAFE-A120 simulators ref to the merged F-11238 test
wolfSSL/simulators#17 (P-256 + 28-byte-digest verify case in
wolfcrypt-test) merged to main as c827ac7. Pin the workflow to that
merge commit so the STSAFE job exercises the regression test against
the digest normalization fixed on this branch.
2026-08-26 10:49:03 +02:00
Daniele Lacamera
5c6f5a5a9f F-11238: validate arguments before use in the A100 verify path
The A100/A110 stsafe_verify wrote *pResult before validating any of
its arguments, unlike the A120 variant which rejects NULL inputs.
Move the argument validation (pointers plus hashSz) ahead of the
*pResult write and the buffer allocation, so a NULL argument returns
BAD_FUNC_ARG instead of dereferencing, and the early return happens
before the SMALL_STACK buffers are allocated.

Addresses the PR review note on *pResult before validation.
2026-08-26 09:26:24 +02:00
Daniele Lacamera
2b1d12f871 F-11238: clamp hashSz to key_sz before the int conversion
hashSz is a caller-supplied word32 (the public wc_ecc_verify_hash API
passes its length straight through to the crypto-cb). Converting it to
int before clamping lets values above INT_MAX wrap negative, and the
normalized-copy pointer arithmetic then writes out of bounds of the
field-size digest buffer. Clamp in the word32 domain first; the int
conversion then only happens for values bounded by key_sz.

Both variants (A120, A100/A110) carry the same fix. Both call sites
already reject key_sz <= 0, so no key_sz check is added here.

Addresses the PR review note on the copy_sz cast.
2026-08-26 09:26:08 +02:00
Daniele Lacamera
1740c3bcb1 CI: bump STSAFE-A120 simulators ref for the F-11238 regression test
The pinned wolfSSL/simulators ref gains the P-256 + 28-byte-digest
verify case in wolfcrypt-test, which exercises the digest
normalization fixed in the previous commit. The simulators branch
carrying 9f9900295 (PR wolfSSL/simulators#17) must be pushed/merged before this ref is reachable.
2026-08-26 09:19:27 +02:00
Daniele Lacamera
68888746b7 F-11238: normalize the digest to field size in STSAFE ECDSA verify
stsafe_verify copied key_sz bytes from the caller's digest buffer and
told the SE the digest was key_sz bytes long. For a digest shorter than
the field size (P-256 with a 28-byte SHA-224 hash, P-384 with SHA-256)
that reads past the end of the buffer and submits a wrong digest, so a
valid signature fails to verify.

The A120 expects a field-size prehash on the wire, so the digest is
normalized host-side before submission: truncate if longer, left-pad if
shorter - the same convention the sign path already applies. The SE
still receives key_sz bytes, so the wire contract is unchanged; only
the buffer contents for short digests are corrected.

Both variants (A120 STSELib, A100/A110 legacy SDK) and both call sites
(crypto-cb, TLS verify-peer callback) now use the real digest length.

Verification:
- Built: host x86_64, --enable-stsafe=a120, STSELib v1.1.7 + Rust
  A120 simulator.
- Tested: wolfCrypt STSAFE-A120 sim test (wolfSSL/simulators
  wolfcrypt-test): new P-256 + 28-byte-digest verify case fails on the
  pre-fix build (valid signature rejected) and passes post-fix; rng,
  on-device keygen, sign and 32-byte verify round-trip unchanged.
- A100/A110 variant not runnable here (closed SDK, no silicon); change
  mirrors the A120 logic on the existing buffer and keeps Length=key_sz.
2026-08-26 09:06:54 +02:00
David Garske
63b02a1586 CI: assert test-lib exit status in the wolfBoot host-smoke job 2026-08-26 07:55:01 +02:00
philljj
b83f5d60f3 Merge pull request #11216 from dgarske/rng_seed_device
random: add WC_RNG_SEED_DEVICE to seed from a nominated device
2026-08-25 14:20:57 -05:00
philljj
7afd4a2c68 Merge pull request #11236 from JacobBarthelmeh/netscape
Restrict duplicate netscape certificate type extensions f-10626
2026-08-25 14:12:11 -05:00
philljj
a417ee3a4c Merge pull request #11038 from gasbytes/dupcrl_entry-copies-fix
Deep copy revoked cert entry extensions in DupCRL_Entry()
2026-08-25 13:36:51 -05:00
David Garske
fcb31dea21 random: add WC_RNG_SEED_DEVICE to seed from a nominated device 2026-08-25 08:19:24 -07:00
philljj
514af438d7 Merge pull request #11156 from gasbytes/x509_store_ctx_verify_cb_fix
Report X509_VERIFY_PARAM hostname/IP mismatches to the verify callback so applications can inspect or override them
2026-08-25 09:38:08 -05:00
Reda Chouk
53647f9dcd Deep copy revoked cert entry extensions in DupCRL_Entry() when CRL_STATIC_REVOKED_LIST and OPENSSL_EXTRA are enabled, and add a regression test for the X509_CRL_dup path. 2026-08-25 16:04:26 +02:00
philljj
33824d8053 Merge pull request #11006 from rlm2002/coverity
20260729 Coverity fixes
2026-08-25 08:46:03 -05:00
Sean Parkinson
94dca6fdd4 Merge pull request #11228 from aidangarske/fenrir-fixes-9961
Encode default cert validity as UTCTime through 2049
2026-08-25 17:16:56 +10:00
Sean Parkinson
feca5c4247 Merge pull request #11249 from night1rider/Expand-AES-Benchmark
Expand aes benchmark and fix leak in benchmark
2026-08-25 16:19:57 +10:00
Sean Parkinson
6c36c71c5f Merge pull request #11237 from holtrop-wolfssl/f-7106
wolfssl_local_MatchBaseName: fix 1-byte read out of bounds looking for "@"
2026-08-25 16:09:06 +10:00
Sean Parkinson
df727d6b90 Merge pull request #11233 from dgarske/ecc_blind_k_fixes
Fix private scalar handling under ECC key blinding and add CI coverage
2026-08-25 16:07:06 +10:00
Sean Parkinson
e15720e4e3 Merge pull request #11185 from embhorn/zd22296
Enforce RFC 8446 SHA-1 certificate rule on TLS 1.3 chains
2026-08-25 11:07:37 +10:00
Sean Parkinson
2cda28008c Merge pull request #10992 from padelsbach/sm2-verify-overlap-test
Add SM2 verify hash test with identical points
2026-08-25 10:08:28 +10:00
JacobBarthelmeh
678a065f10 Merge pull request #11248 from night1rider/ASU-ECIES-Improvements
Asu ecies improvements
2026-08-24 16:42:06 -06:00
night1rider
d851d60427 Free the Aes on every AES-OFB benchmark error path 2026-08-24 15:48:30 -06:00
night1rider
2d81662d6c Route the AES-CFB and AES-OFB benchmarks through the crypto callback devId 2026-08-24 15:46:32 -06:00
philljj
f8b140f511 Merge pull request #11204 from padelsbach/falcon-cb-free
Add CB_FREE mode for Falcon
2026-08-24 16:30:18 -05:00
philljj
d3c63a06f6 Merge pull request #11224 from anhu/fake_alloc
Macro guard to prevent dead code.
2026-08-24 15:15:40 -05:00
night1rider
69786c2f00 Add unit test coverage for wc_ecc_ctx_get_rng 2026-08-24 14:13:37 -06:00
philljj
cf27755f89 Merge pull request #11244 from SparkiDev/asn_template_doc
ASN Template documentation: add more content
2026-08-24 15:09:08 -05:00
night1rider
6d2454826f Offload ASU ECIES on NIST P-192 2026-08-24 13:40:37 -06:00
night1rider
69e82f1f40 Use the caller's RNG for the ASU ECIES GCM nonce 2026-08-24 11:51:36 -06:00
JacobBarthelmeh
ff17d489d3 Merge pull request #11209 from night1rider/curve448-callbacks
Add curve448 crypto callback support
2026-08-24 09:50:17 -06:00
JacobBarthelmeh
74b8207b72 Merge pull request #11053 from night1rider/Xilinx-ASU-ECC-standalone
Xilinx asu ecc standalone
2026-08-24 09:46:02 -06:00
Sean Parkinson
78c2528c56 ASN Template documentation: add more content
Added a bunch of content about how to use ASN templates.
Added a section with a list of things to do when adding a new template.
Added mappiong of ASN.1 notation to template lines.
Added ASN.1 type specific information.
Added a checklist at the end to head off the common issues.
Added references to ASN_TEMPLATE.md.
Added other informatrion.
2026-08-24 10:52:23 +10:00
philljj
cb138b22a2 Merge pull request #11163 from kareem-wolfssl/vanessa
Fix a few sniffer issues.  Document DES function size requirements.
2026-08-22 09:56:06 -05:00
night1rider
51975e27a5 Guard curve448 shared secret software path on ret so the cryptocb reset is read 2026-08-21 17:04:19 -06:00
night1rider
5dd72727cb Fix curve448 test guards for CB_FIND and zero-check builds, cover cb zero result 2026-08-21 17:04:19 -06:00
night1rider
2c5d885233 Fix curve448_key_make_pub being unused under WOLF_CRYPTO_CB_ONLY_CURVE448 with key export disabled 2026-08-21 17:04:19 -06:00
night1rider
06abdc18e6 Only offload a key-owned X448 private scalar to that key's own device
wc_curve448_make_key and wc_curve448_export_public_ex derived the public
point through the keyless wc_curve448_make_pub, which dispatches to the
first registered device; route them through a devId-carrying helper.
2026-08-21 17:04:19 -06:00
night1rider
93d71fdda9 Address second round of review findings on curve448 cryptocb support
Restore key devId on the keygen stub's error return, full-buffer-check
callback output, cover the new/delete NULL out-params, drop a dead guard.
2026-08-21 17:04:19 -06:00
night1rider
eb1cde51ab Address review findings on curve448 cryptocb support
Assert cryptocb output in curve448_onlycb_test, reject an all-zero
wc_curve448_generic result, guard the new API test for CB-only builds.
2026-08-21 17:04:18 -06:00
night1rider
3d7f7ad4d6 Add curve448 crypto callback support
Mirror curve25519: keygen, shared secret, make pub and generic
callbacks, wc_curve448_init_ex/new/delete, new wc_curve448_generic
API with scalar clamp checks, WOLF_CRYPTO_CB_ONLY_CURVE448 mode,
TLS devId plumbing, tests (test.c, api unit tests, swdev),
benchmark devId, CI entries.
2026-08-21 17:04:18 -06:00
philljj
ac45965828 Merge pull request #11217 from night1rider/ShakeCB-Issue
Set hashType on SHAKE128/256 contexts so crypto-callback Copy/Free can clean up correctly
2026-08-21 17:58:06 -05:00
Ruby Martin
589b9eb4bf Free the unexpected return in test_wolfSSL_load_client_CA_file 2026-08-21 16:50:11 -06:00
philljj
97a52ed9f6 Merge pull request #11235 from padelsbach/crypto-cb-ci-timeout
CI: increase timeout and fix minutes in cryptocb-only test
2026-08-21 16:55:34 -05:00
philljj
583f214057 Merge pull request #11234 from aidankeefe2022/fenrir-10721
Fix: Out of date comment
2026-08-21 14:53:46 -05:00
Josh Holtrop
4eb192d4c8 wolfssl_local_MatchBaseName: fix 1-byte read out of bounds looking for "@"
Fixes F-7106
2026-08-21 15:47:05 -04:00
JacobBarthelmeh
986066c856 Restrict duplicate netscape certificate type extensions f-10626 2026-08-21 13:19:09 -06:00
Paul Adelsbach
bded1f48c8 CI: increase timeout and fix minutes in cryptocb-only test 2026-08-21 11:48:55 -07:00
night1rider
ddbd4c10b0 Xilinx Versal Gen2 ASU: TRNG seed in the template, no compressed key ECIES 2026-08-21 11:58:32 -06:00