Commit Graph

1450 Commits (b04084bff3115e2aa2c65bfbfd7579a86bb65da5)

Author SHA1 Message Date
philljj f670b0cd0d
Merge pull request #11055 from padelsbach/slh-dsa-cryptocb
Add crypto callback mode for SLH-DSA
2026-09-09 10:56:55 -05:00
philljj 768f6462bd
Merge pull request #11139 from gasbytes/gh-11085
tls13: don't report the client handshake complete until its Finished has been flushed
2026-09-09 09:45:18 -05:00
philljj bd753e2f2e
Merge pull request #11177 from julek-wolfssl/fenrir-dtls-record-layer-fixes
DTLS: fix several sequence-number, epoch and Connection ID issues
2026-09-08 20:31:10 -05:00
Paul Adelsbach e4f8a6f9c1 Add crypto callback mode for SLH-DSA 2026-09-08 13:52:19 -07:00
Reda Chouk 87fa090db0 tls13: don't report the client handshake complete until its Finished has been flushed 2026-09-08 13:51:10 +02:00
Tobias Frauenschläger 01426d0fdb
Merge pull request #11395 from julek-wolfssl/x509-name-print-ex-esc-2253
Fix X509_NAME_print_ex flag handling and unsafe value copying
2026-09-08 13:22:50 +02:00
Juliusz Sosinowicz 171d4d84e6 X509_NAME_print_ex: rename misnamed test string
expRFC5523 holds the XN_FLAG_RFC2253 expectation.
2026-09-08 09:38:07 +00:00
Juliusz Sosinowicz 88bf23ffb3 X509_NAME_print_ex: honor separator and attribute name flags
Separate entries with ",", ", ", "; " or a new line for
XN_FLAG_SEP_COMMA_PLUS, XN_FLAG_SEP_CPLUS_SPC, XN_FLAG_SEP_SPLUS_SPC
and XN_FLAG_SEP_MULTILINE, indenting every line for the last one.
Print long names for XN_FLAG_FN_LN, no name for XN_FLAG_FN_NONE and
pad names for XN_FLAG_FN_ALIGN, as OpenSSL does. XN_FLAG_FN_OID still
prints short names as wolfSSL has no OIDs for name attributes.

XN_FLAG_RFC2253 output changes from "CN=a, C=b" to "CN=a,C=b".
2026-09-08 08:23:42 +00:00
Sean Parkinson bd68a1ee33
Merge pull request #11354 from gasbytes/store_ctx-fix
Clear setTrustedSk on X509_STORE_CTX_init
2026-09-08 09:13:12 +10:00
Sean Parkinson 90f723fea4
Merge pull request #11361 from JacobBarthelmeh/extkeyuse
add ssh server extended key usage parsing and missing ssh extended ke…
2026-09-08 09:03:56 +10:00
Juliusz Sosinowicz 878e7ddbd1 X509_NAME_print_ex: honor ASN1_STRFLGS_ESC_2253 without reversing
XN_FLAG_RFC2253 was defined as 1, the same bit as
ASN1_STRFLGS_ESC_2253, so a caller asking only for RFC 2253 escaping
also got the reversed DN order. OpenVPN master now calls
X509_NAME_print_ex() with XN_FLAG_SEP_CPLUS_SPC | XN_FLAG_FN_SN |
ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_UTF8_CONVERT (fix for
CVE-2026-84790) and its ssl_testdriver failed against wolfSSL.

- Define XN_FLAG_RFC2253 and XN_FLAG_MULTILINE as OpenSSL does.
- Reverse the order only on XN_FLAG_DN_REV.
- Implement ASN1_STRFLGS_ESC_2253, ASN1_STRFLGS_ESC_CTRL and
  ASN1_STRFLGS_ESC_MSB escaping as OpenSSL does.
- Write values byte for byte. An embedded NUL previously truncated
  the value and copied uninitialized heap bytes into the BIO.
- Escaping can triple the value length. Reject lengths where the
  buffer size would overflow.

Entries are still always separated by ", " and printed with their
short name. XN_FLAG_MULTILINE was 0xFFFF and behaved like
XN_FLAG_RFC2253; it now escapes control and non-ASCII bytes and does
not reverse the order.
2026-09-07 18:14:39 +00:00
philljj ed61c5a778
Merge pull request #11333 from SparkiDev/tls_cert_vfy_tests
TLS certificate verification: add more tests
2026-09-07 12:20:53 -05:00
Tobias Frauenschläger b129dbb625 cryptocb: add WC_ALGO_TYPE_KEYSTORE for hardware key store operations
A hardware key store holds keys with a lifetime of their own, and none of the
existing callbacks can manage them. WC_ALGO_TYPE_SETKEY and
WC_ALGO_TYPE_EXPORT_KEY are bound to a wolfCrypt key object and carry material
for that object's own use: neither can name a stored key, ask for one to be
created exportable, or make one outlive the object that used it. Wrapped keys
add a second reason, since a wrapped blob never becomes plaintext on this side
of the boundary at all.

Add a dedicated algorithm type covering the operations that manage a stored
key, whether or not they cross that boundary:

  WC_KEYSTORE_IMPORT_PLAIN    place plaintext key material into a slot
  WC_KEYSTORE_EXPORT_PLAIN    read a stored key back as plaintext
  WC_KEYSTORE_IMPORT_WRAPPED  unwrap a blob directly into a slot
  WC_KEYSTORE_EXPORT_WRAPPED  wrap a stored key back out
  WC_KEYSTORE_DERIVE          derive slot to slot without touching RAM
  WC_KEYSTORE_DELETE          destroy a stored key
  WC_KEYSTORE_GET_INFO        query what a slot holds

The plaintext pair is what most key stores outside the secure-element class
offer, and it is the shape wc_Pkcs11StoreKey() already implements privately:
that function takes a Pkcs11Token* rather than a devId, so an application using
it is bound to PKCS#11 even though the operation is generic. Devices that hold
keys which may never appear in plaintext decline the pair and offer only the
wrapped form.

Delete is deliberately separate from WC_ALGO_TYPE_FREE: freeing a wolfCrypt key
object must never destroy the hardware key it refers to.

A key reference is not a new naming scheme. It is the identifier
WOLF_PRIVATE_KEY_ID already uses, so the bytes that name a key here are the
bytes wc_ecc_init_id() or wc_AesInit_Id() take to bind an object to that key,
and the bytes read back from key->id afterwards. wolfCrypt copies them through
without inspection.

Two details come from building the NXP EdgeLock port against this surface,
which is what a design like this needs before it is fixed in place.

Every operation that creates a key takes keyType, because a key store has to
know what a key is for before it can set its permissions, and the material
does not always say. Raw bytes carry no metadata, and neither does a bare
RFC 3394 wrap, which is a pure data transformation. A vendor container that
carries its own property word stays authoritative over what it holds and
keyType is then a cross-check, which catches the right blob going into the
wrong kind of slot; a device must refuse a mismatch rather than silently
prefer one source. WC_KEYSTORE_KEY_NONE leaves the choice to the device. The
export operations take no keyType, since the key already exists and GET_INFO
reports it.

attrs travels with every creating operation for the same reason, but as a
source only. A format carrying no attributes of its own leaves attrs as the
device's only word on what the new key may do. A container that carries them
wins and attrs is ignored, and it cannot usefully be cross-checked there:
a container's attributes are inside the wrap and are not known until the key
exists, whereas keyType is checkable up front against the reference being
imported into. wc_KeyStore_GetInfo() is how a caller confirms what an import
produced.

keyType also fixes how plaintext material is encoded, so no further argument
is needed to say. A symmetric type takes the raw key bytes; an asymmetric type
takes DER, a private key as PKCS#8 PrivateKeyInfo and a public key as
SubjectPublicKeyInfo. Stating it matters: WC_KEYSTORE_KEY_ECC_SIGN and a byte
string do not otherwise say whether the bytes are a scalar, SEC1 or PKCS#8,
and two devices could each pick differently and both be defensible.

Keys that act on other keys need naming. Without WC_KEYSTORE_KEY_WRAP and
WC_KEYSTORE_KEY_DERIVE a device asked about a wrapping key can only answer
NONE, which is indistinguishable from an empty slot and defeats the point of
GET_INFO. Measured on hardware, a 256-bit wrapping key reported type 0 with
256 bits, which tells a caller nothing about what it may do with it. Both are
listed ahead of the algorithm types, since they name what a key acts on rather
than which algorithm it serves.

The algorithm types cover what the two other backends this was checked against
actually store. wc_Pkcs11StoreKey() handles RSA, ECC and ML-KEM today, and
wolfHSM's WH_KEY_ALGO_ENUM names RSA, ECC, Curve25519, Ed25519, ML-DSA, ML-KEM,
LMS and XMSS, so a shorter vocabulary would have left the facility unusable to
both for anything but symmetric keys.

An algorithm serving two purposes a key store grants separately is split, since
one key doing both is the key-separation problem and a caller has to be able to
ask for the narrower key. RSA and ECC are the only two: PKCS#11 carries
CKA_SIGN and CKA_DECRYPT independently for RSA, and CKA_SIGN against CKA_DERIVE
for ECC. wolfCrypt's own PKCS#11 layer honours that for ECC, selecting from the
ecc_key flags, but sets both CKA_DECRYPT and CKA_SIGN unconditionally for RSA
because no equivalent RsaKey flag exists; expressing the distinction here is
what would let that be tightened later. The remaining types serve one purpose
each and are not split. Signature use is listed before agreement or transport
use throughout.

Argument order follows one rule: two interchangeable control words are never
left adjacent, because a transposition between them compiles cleanly and
surfaces much later as an unrelated-looking failure. An earlier arrangement had
attrs and kdfType separated only by a pointer and a length, and swapping them
silently created a key without the exportable attribute, whose export then
failed two operations away from the mistake. Beyond that each control word sits
beside what it describes. wc_KeyStore_ImportPlain is the one place the two aims
collide and the first wins: attrs sits at the tail of every creating operation
rather than beside keyType, because WC_KEYSTORE_ATTR_EXPORTABLE and
WC_KEYSTORE_KEY_WRAP are both 1 and a swap would be silent. All three creating
operations therefore read keyRef, keyRefSz, keyType, then what they draw the
key from, then attrs.

kdfType refers to enum wc_KdfType, and WC_KDF_TYPE_NONE asks for the device's
own derivation, which is all many key stores offer.

Attributes are fixed when a key is created; hardware generally burns them in,
so there is no operation here to change them afterwards. They round-trip: a
device that can represent one must report it back through GET_INFO, so a caller
can ask whether an export is permitted rather than attempting one and
interpreting the error. Attributes the device cannot represent read as absent,
and out parameters it does not fill are cleared rather than left holding the
caller's stack.

Gated behind WOLF_CRYPTO_CB_KEYSTORE, with tests in wolfcrypt/test and
tests/api that assert each operation reaches the device carrying the arguments
the caller passed, not merely that the call returned zero.
2026-09-07 08:22:01 -07:00
philljj a3fa44dddc
Merge pull request #11341 from sameehj/fix/pkcs7-encode-certs-ownership
tests: free PKCS7 cert stack when encode_certs fails
2026-09-05 23:11:08 -05:00
philljj d72f6d9e4e
Merge pull request #11381 from douzzer/20260904-misc-fixes
20260904-misc-fixes
2026-09-04 23:18:46 -05:00
philljj a93e5decf5
Merge pull request #11118 from night1rider/fix/11076-cert-authorities-empty-list
Fix cert authorities empty list
2026-09-04 17:32:43 -05:00
Daniel Pouzzner 5f534629f2 address AI review:
tests/api/test_tls_bounds.c: fix a residual null deref error path, and an introduced error path leak.

wolfcrypt/src/sha256.c: in Transform_Sha256(), accommodate WOLFSSL_WIDE_BYTE in data copy-in using original construction (no readUnalignedWord32()).

wolfcrypt/test/test.c:

* fix sequence in mldsa_param_test() so that the new NULL payload test follows the last existing test making use of the established sig.

* add missing NULL payload test to xmss_test().
2026-09-04 14:49:16 -05:00
Daniel Pouzzner 916de9cf1e wolfcrypt/src/{wc_lms.c,wc_xmss.c,wc_mldsa.c,wc_slhdsa.c,ed25519.c,ed448.c,falcon.c}
and wolfcrypt/test/test.c: accept the empty message, passed as (NULL, 0), in all
sign and verify entry points -- RFCs 8032, 8554, and 8391, and FIPS 204, 205,
and (pending) 206, all permit empty messages (in fact RFC 8032's first test
vector is for the empty message).  Guards now reject a NULL message only with a
nonzero length (wc_XmssKey_Verify()/wc_XmssKey_Sign() additionally had an
off-by-one, rejecting mLen == 0 outright, unlike their LMS siblings); after
validation, a NULL message is canonicalized to a readable stand-in so downstream
consumers -- hash updates and crypto callbacks -- never see a NULL pointer.

wc_ed448_verify_msg_ex() additionally gains previously absent validation of sig
and res, which were dereferenced unchecked.

Add empty-message sign/verify roundtrips to lms_test() (spending one of the 2**5
signatures; the exhaustion loop drops to 31 iterations), xmss_test(),
mldsa_param_test(), slhdsa_test_param() (fast 128f set only -- the code path is
parameter-independent and "s"-set signing is costly), and falcon_test().  Add
(NULL, 0) sign/verify probes to ed25519_test() and ed448_test(), pinned
byte-identical to the existing (msg, 0) known answers (EdDSA is deterministic).

tests/api/test_lms_xmss.c: fix test_wc_XmssDecisionCoverage() to probe mLen < 0,
not mLen <= 0, consistent with preexisting probes in
test_wc_LmsDecisionCoverage().
2026-09-04 12:48:50 -05:00
Daniel Pouzzner 44c69b62c8 tests/api/test_tls_bounds.c: fix null deref error paths using EXPECT_SUCCESS() checks. 2026-09-04 12:31:30 -05:00
Daniel Pouzzner 0b03b2f6b0 tests/api/test_ossl_x509_str.c: add missing NO_TLS gates re test_untrusted_inter_terminal_anchor_rejected(). 2026-09-04 12:31:30 -05:00
Daniel Pouzzner b3e68d5c09 tests/api/test_aes.c: fix parens in macro gate for test_wc_AesSetIV_RestartsStream(). 2026-09-04 12:31:30 -05:00
philljj 3473701428
Merge pull request #11115 from padelsbach/dh-buffer-copy
Fix UAF in DH buffers
2026-09-04 10:31:57 -05:00
philljj 88c0902c35
Merge pull request #11307 from holtrop-wolfssl/f-8303
Rust wrapper: ed25519: guard generate with ed25519_make_key cfg
2026-09-04 09:19:13 -05:00
JacobBarthelmeh 11a6e284e1 handle extended key usage oid collisions 2026-09-03 13:57:07 -06:00
Marco Oliverio 12601e44e4 dtls: cid: error out/return 0 on BAD_ARGS 2026-09-03 18:56:34 +02:00
philljj 339aa5779f
Merge pull request #11165 from SparkiDev/argon2
Argon2: Add Argon2d/i/id version 1.3
2026-09-03 09:51:30 -05:00
Sean Parkinson 0259226551
Merge pull request #11304 from gasbytes/tls-alert-fixes
Fix extension handling for quic_transport_parameters and trusted_ca_keys
2026-09-03 17:27:47 +10:00
Sean Parkinson 23b33a2635 Argon2: Add Argon2d/i/id version 1.3
Add implementation of Argon2d/Argon2i/Argon2id.
Supports threading.
2026-09-03 15:51:38 +10:00
Sean Parkinson 411c3406c8
Merge pull request #11265 from kaleb-himes/PQ-FS-2026-Part3-SecurityReview-nofallback-E
PKCS callback typedef fixes and SLH-DSA standards updates
2026-09-03 15:15:14 +10:00
Sean Parkinson 847e068535
Merge pull request #11303 from kaleb-himes/PQ-FS-2026-Part3-SecurityReview-nofallback-D
PQ algorithm PCT's and RSA compliance fixes
2026-09-03 15:13:06 +10:00
Sean Parkinson ccb11f354c
Merge pull request #11308 from Frauschi/curve25519-cryptocb-fix
Curve25519 CryptoCb fix
2026-09-03 15:08:20 +10:00
JacobBarthelmeh c3ac2f6da4 add ssh server extended key usage parsing and missing ssh extended key parsing to asn template from asn orig 2026-09-02 23:03:51 -06:00
philljj 9a192651a6
Merge pull request #11215 from SparkiDev/tls13_rfc9846
Conformance to RFC 9846: New version of TLS 1.3 specification
2026-09-02 22:31:24 -05:00
Tobias Frauenschlaeger 0fdf71079f Only offload a key-owned X25519 private scalar to that key's own device
wc_CryptoCb_Curve25519MakePub took no devId and resolved its device with a
lookup for INVALID_DEVID, falling back to the first registered device. Every
route to an X25519 public point derivation went through it, so a key bound to
one device had its private scalar offered to whichever device happened to be
registered first, with no way to opt out.

Give both wc_CryptoCb_Curve25519MakePub and wc_CryptoCb_Curve25519Generic a
devId parameter and let only a caller that selected no device settle for the
first registered one, matching the curve448 siblings. wc_curve25519_make_key
and wc_curve25519_export_public_ex now derive the point through a devId
carrying helper that reaches the callback only when the key names a device.
The keyless public API has no key to take a devId from, so it offers the
scalar to wc_CryptoCb_DefaultDevID() and keeps its old behaviour, while
honouring WC_NO_DEFAULT_DEVID.

Under WOLFSSL_CURVE25519_BLINDING both wc_curve25519_make_pub and
wc_curve25519_generic fall through to their blinded variant after the
callback declined, which dispatched the same private scalar to the same
device a second time. The fall-through now calls the software half of the
blinded derivation directly, so a declining device is offered the scalar
once.

Under WOLF_CRYPTO_CB_ONLY_CURVE25519 an unbound key passed to
wc_curve25519_export_public_ex now returns NO_VALID_DEVID rather than
reaching the first registered device. Such builds must create keys with
wc_curve25519_init_ex and a real devId.
2026-09-02 12:41:29 +02:00
Reda Chouk 9d7ac3ee01 clear setTrustedSk on X509_STORE_CTX_init 2026-09-02 12:32:04 +02:00
Sean Parkinson 80a5e788e1
Merge pull request #11316 from yosuke-wolfssl/fix/f_12559
ssl_bn: skip truncation shift for byte-aligned BN_rand requests
2026-09-02 16:21:59 +10:00
Sean Parkinson e8fac4e0e8 Conformance to RFC 9846: New version of TLS 1.3 specification
RFC 9846, 5.5
CheckTLS13AEADSendLimit(): at the AEAD limit while sending early data,
return TOO_MUCH_EARLY_DATA instead of calling Tls13UpdateKeys(). A KeyUpdate
there would go out pre-handshake.

RFC 9846, 6.1
Three alert sites in DoAlert() / DoProcessAlertRecord(): TLS 1.3
user_canceled is now exempt from teardown and session invalidation at any
AlertLevel, not just warning. TLS 1.2 unchanged.

RFC 9846, 4.7.3
New Tls13KeyUpdateLimitReached() helper shared by send and receive
paths. At the 2^48-1 cap, DoTls13KeyUpdate() drops a peer's update_requested
and continues, rather than failing the connection. App-initiated
wolfSSL_update_keys() still returns BAD_STATE_E.

RFC 9846, 4.3
TranslateErrorToAlert() maps BUFFER_E to decode_error as well as
BUFFER_ERROR — one case label covering 27 malformed-extension sites that
previously aborted with no alert sent.

Tests added.
2026-09-02 16:07:47 +10:00
Sean Parkinson 0e3155cece
Merge pull request #11283 from miyazakh/f9972_curve25519
Fix peer key masking
2026-09-02 15:54:01 +10:00
kaleb-himes 4308349c01 Trim FIPS comments and share one ML-DSA seed entry point 2026-09-01 20:17:22 -06:00
kaleb-himes 66544ec02d Simplify FIPS comments and correct two wrong citations 2026-09-01 20:17:22 -06:00
kaleb-himes 2ce1432bc5 Expect PSS max-salt refusal under FIPS v7 with long salts 2026-09-01 20:17:22 -06:00
Sean Parkinson 835a7c17c6 TLS certificate verification: add more tests
Add tests for different modes when doing certificate verification in TLS.
Update comments.
2026-09-02 07:31:27 +10:00
philljj 88c766b6b6
Merge pull request #11221 from gasbytes/certificatePolicies-fix
certificatePolicies fixes
2026-09-01 12:04:43 -05:00
Sameeh Jubran 4bef71c2df tests: free PKCS7 cert stack when encode_certs fails
wolfSSL_PKCS7_encode_certs takes the stack only on success. These tests
dropped sk whenever p7 and the BIO were non-NULL, which leaked under
MEM_FAIL_CNT.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
2026-09-01 19:53:37 +03:00
kaleb-himes e8e0630c76 SLH-DSA pre-hash enforcement per FIPS 205 and FIPS v7 test fixes 2026-09-01 10:38:43 -06:00
philljj b273b7d11b
Merge pull request #11222 from danielinux/mcdc-test-coverage
Mcdc test coverage - part 7
2026-09-01 09:25:32 -05:00
philljj 0827c4bca6
Merge pull request #11268 from holtrop-wolfssl/f-8148
Return MISSING_KEY from wc_SlhDsaKey_Export* when key not present
2026-08-31 15:25:20 -05:00
Josh Holtrop 055b1285b1 Rust wrapper: ed25519: guard generate with ed25519_make_key cfg
Detect based on wc_ed25519_make_key prototype presence and guard
prototype presence with HAVE_ED25519_MAKE_KEY.
2026-08-31 09:33:09 -04:00
Yosuke Shimizu 900bcf745f ssl_bn: skip truncation shift for byte-aligned BN_rand requests
- wolfSSL_BN_rand() calls mp_rshb() only when bits is not a
  multiple of 8.
- test_wolfSSL_BN_rand() declares i and seen, and samples 8-bit
  TOP_ANY, 16-bit TOP_ANY, and 8-bit TOP_ONE requests to assert
  the results are not confined to the low byte.

Issue: F-12559
2026-08-31 10:28:42 +09:00
philljj 34213711b8
Merge pull request #11138 from sameehj/fix/mem-fail-ecc-x509-ext
Fix nightly-mem-fail-test (jenkins-supervisor #501): ECC/X509 tests and RPK
2026-08-28 08:55:27 -05:00