Compare commits

...
Sign in to create a new pull request.

349 commits

Author SHA1 Message Date
Brady Foster
971b8d060e Update SSL_CTX_set1_curves.pod for OpenSSL 3.5 additions
Some checks failed
Run-checker merge / run-checker (no-srp) (push) Failing after 7s
Run-checker merge / run-checker (no-ocsp) (push) Failing after 23s
Run-checker merge / run-checker (no-pinshared) (push) Failing after 22s
Run-checker merge / run-checker (no-shared) (push) Failing after 16s
Run-checker merge / run-checker (no-srtp) (push) Failing after 7s
Run-checker merge / run-checker (no-ts) (push) Failing after 9s
Run-checker merge / run-checker (no-ui) (push) Failing after 10s
Run-checker merge / jitter (push) Failing after 9s
Run-checker merge / threads_sanitizer_atomic_fallback (push) Failing after 6s
Compiler Zoo CI / gcc (gcc-14) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-10) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-12) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-13) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-9) (push) Has been cancelled
Compiler Zoo CI / clang (clang-11) (push) Has been cancelled
Documentation and Installability CI / out-of-readonly-source-and-install-macos (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-11) (push) Has been cancelled
Compiler Zoo CI / clang (clang-12) (push) Has been cancelled
Compiler Zoo CI / clang (clang-13) (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:afl-clang-fast config:enable-fuzz-afl no-module install:afl++ name:AFL]) (push) Has been cancelled
Compiler Zoo CI / clang (clang-14) (push) Has been cancelled
Compiler Zoo CI / clang (clang-15) (push) Has been cancelled
Compiler Zoo CI / clang (clang-16) (push) Has been cancelled
Compiler Zoo CI / clang (clang-17) (push) Has been cancelled
Compiler Zoo CI / clang (clang-18) (push) Has been cancelled
Compiler Zoo CI / clang (clang-19) (push) Has been cancelled
Compiler Zoo CI / clang (clang-20) (push) Has been cancelled
Compiler Zoo CI / clang (clang-21) (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:clang-18 config:enable-fuzz-libfuzzer enable-asan enable-ubsan -fno-sanitize=function -fsanitize-coverage=trace-cmp -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION extra:enable-fips enable-lms enable-ec_nistp_64_gcc_128 -fno-sanitize=al… (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:clang-18 config:enable-fuzz-libfuzzer enable-asan enable-ubsan -fno-sanitize=function install:libfuzzer-18-dev libs:--with-fuzzer-lib=/usr/lib/llvm-18/lib/libFuzzer.a --with-fuzzer-include=/usr/include/clang/18/include/fuzzer linke… (push) Has been cancelled
Added documentation of the addition of group tuples in openSSL 3.5
in HISTORY section of SSL_CTX_set1_curves.pod.

CLA: trivial

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul 24 13:13:26 2026
(Merged from https://github.com/openssl/openssl/pull/32007)
2026-07-24 15:13:02 +02:00
Mounir IDRASSI
5f48317d6d Restore empty raw PKCS#1 verify-recover behavior
EVP_PKEY_verify_recover() with RSA PKCS#1 v1.5 padding and no configured
signature digest rejected a valid signature whose recovered payload is
empty, instead of returning success with a recovered length of zero.

RSA_public_decrypt() returns -1 on error and otherwise the number of
recovered bytes, which may legitimately be zero for a raw PKCS#1 v1.5
signature that encodes an empty payload.  Pull request #28306 ("Make
error checks on RSA_public_decrypt() consistent") changed the error
check in the raw, no-digest verify-recover path from "ret < 0" to
"ret <= 0", so a valid zero recovered length was mistaken for an error.

Restore the "< 0" check in that branch only, leaving the digest-aware
PKCS#1, X9.31, PSS and ordinary verification paths untouched.

Add test_RSA_verify_recover_empty_payload, which performs a complete
zero-length raw PKCS#1 v1.5 sign-and-recover round trip through EVP and
fails on the unmodified implementation specifically at the
EVP_PKEY_verify_recover() call.  OpenSSL 3.0.13 recovers the same
signature and reports a zero-byte result.

The behavior regressed as a result of #28306.

Fixes #32000

Assisted-by: OpenCode:GLM-5.2

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Jakub Zelenka <jakub.zelenka@openssl.foundation>
MergeDate: Fri Jul 24 13:06:58 2026
(Merged from https://github.com/openssl/openssl/pull/32001)
2026-07-24 15:06:51 +02:00
Mounir IDRASSI
3e4f7e7720 Reject unknown TLS 1.3 ServerHello extensions
TLS 1.3 does not permit clients to ignore unknown extensions in ServerHello
or HelloRetryRequest. Add a validation pass for these messages so fully
unknown extension types fail early with unsupported_extension.

Keep the existing ignore behavior for other extension contexts and leave
TLS 1.2 ServerHello processing unchanged. Add TLSProxy coverage for the
TLS 1.3 ServerHello case.

Correct the unknown-extension path in tls_collect_extensions(). Collection
still runs before the new TLS 1.3 validation, and verify_extension()
returns success with thisex == NULL for fully unknown extension types.
The previous idx calculation used invalid pointer arithmetic on NULL in
that path. Map unknown extensions explicitly outside the built-in extension
range instead, preserving the existing ignore semantics while avoiding
undefined behavior.

Update the truncated HRR ECH corruption vector to keep testing malformed
ECH length after the new unknown-extension validation. The old 0xdddd bytes
were only padding to preserve the replacement length, but they now trigger
the unknown-extension check before the ECH parser. Use a known HRR cookie
extension as padding so the test still reaches the intended
SSL_R_LENGTH_MISMATCH path.

Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul 23 15:55:09 2026
(Merged from https://github.com/openssl/openssl/pull/31086)
2026-07-23 17:55:07 +02:00
Christoph Müllner
d2c0db0d9d crypto: use void * in LoongArch SHA shim
The LoongArch SHA dispatch shim uses the same deprecated typed
interfaces as the RISC-V shim. Switch its entry points to void *
so it no longer depends on deprecated SHA context types.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul 23 15:43:31 2026
(Merged from https://github.com/openssl/openssl/pull/30763)
2026-07-23 17:43:21 +02:00
Christoph Müllner
4499e9abe1 crypto: use void * in RISC-V digest shims
The RISC-V MD5 and SHA dispatch files use low-level digest context
types that are hidden in no-deprecated builds. Switch their shim
entry points to void * so they no longer depend on deprecated typed
interfaces.

Update the local MD5 declaration to match the untyped shim
interface.

Fixes: openssl/openssl#29357

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul 23 15:43:30 2026
(Merged from https://github.com/openssl/openssl/pull/30763)
2026-07-23 17:43:21 +02:00
Greensi7
10413cceb6 Add OSSL_ECHSTORE_read_echconfiglist fuzzer
Fuzz OSSL_ECHSTORE_read_echconfiglist with raw
fuzzer input in stage 1. Then fixup the starting
bytes to reach deeper code withotu relying only on
corpus. Fixup is done for binary encoding only (not base64).

Assisted-by: ChatGPT:gpt-5.5

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Thu Jul 23 13:57:54 2026
(Merged from https://github.com/openssl/openssl/pull/32021)
2026-07-23 15:57:53 +02:00
Nicky Mouha
0723430177 doc: document that HMAC_Update cannot be called after HMAC_Final
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
MergeDate: Thu Jul 23 08:33:21 2026
(Merged from https://github.com/openssl/openssl/pull/31570)
2026-07-23 10:33:15 +02:00
codingsushi79
b80761945b Fix capitalization of 'Swiss Army knife' in README
CLA: trivial

Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jul 23 08:30:57 2026
(Merged from https://github.com/openssl/openssl/pull/31871)
2026-07-23 10:30:51 +02:00
Mounir IDRASSI
f7112c925c docs: clarify EVP_PKEY context workflow and operation descriptions
Document that a generated key is returned separately from its generation
context and that a new key-bound context is needed for subsequent
operations. Correct the encrypt and decrypt initialization descriptions
and examples accordingly.

Correct two copy-and-paste errors in the verify-recover documentation:
describe its initializer as starting a verify-recover operation and refer
to EVP_PKEY_verify_recover() when discussing its input.

Fixes #31989

Assisted-by: Grok:Grok-4.5

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jul 23 08:29:24 2026
(Merged from https://github.com/openssl/openssl/pull/31995)
2026-07-23 10:28:42 +02:00
Alexander Nesterovskiy
e7a8d9c19e Added Nvidia/Olympus CPU dispatch for SHA3/EOR3 AES GCM on Vera CPU
CLA: trivial

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Thu Jul 23 08:26:09 2026
(Merged from https://github.com/openssl/openssl/pull/31191)
2026-07-23 10:26:05 +02:00
Neil Horman
05b241cb09 Fix missing NULL check in statem_clnt_construct_test
Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695905

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Thu Jul 23 08:24:25 2026
(Merged from https://github.com/openssl/openssl/pull/31992)
2026-07-23 10:24:01 +02:00
Neil Horman
9375418a87 use safe_math on do_name_ex
Coverity caught some potential overflows in do_name_ex.  Seems unlikely
to occur, but lets just do all the adds under safe_math to ensure we
don't overflow our buffer length.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695278

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Thu Jul 23 08:24:23 2026
(Merged from https://github.com/openssl/openssl/pull/31992)
2026-07-23 10:24:01 +02:00
Neil Horman
eac8ed4825 Add return check to OSSL_DECODER_up_ref
Coverity flagged a location where we didn't check this return code, fix
it up.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1696759

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Thu Jul 23 08:24:22 2026
(Merged from https://github.com/openssl/openssl/pull/31992)
2026-07-23 10:24:01 +02:00
Todd Short
ba2f3b557a errors: fix stale string overrides in openssl.txt for renamed SSL error codes
Commit b3d26e438a ("merge feature/removesslv3", PR #29338) renamed SSL3
error codes to TLS equivalents and updated the string descriptions in
crypto/ssl_err.c (e.g. from "ssl/tls alert bad certificate" to
"tls alert bad certificate"), but did not update the corresponding
strings in crypto/err/openssl.txt.

This caused a latent divergence: running mkerr.pl -rebuild would
regenerate ssl_err.c with the old openssl.txt strings, undoing the
intentional name cleanup. Similarly, adding any new SSL error code
triggers a full SSL regeneration that would revert the strings and
reorder entries to their correct alphabetical positions, producing
spurious changes unrelated to the new code.

Update openssl.txt to match the strings already in ssl_err.c, which
also happen to be the auto-generated strings derived from the reason
code names. Regenerate ssl_err.c and sslerr.h with the correct
alphabetical ordering so that future make update runs are idempotent:
adding and removing a new SSL error code now produces only the expected
changes to the generated files, with no side-effect reordering or
string reversions.

Fixes: b3d26e438a ("Rename SSL3 error codes to TLS equivalents")
Signed-off-by: Todd Short <todd.short@me.com>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Jul 21 14:28:22 2026
(Merged from https://github.com/openssl/openssl/pull/31993)
2026-07-21 10:28:19 -04:00
Viktor Dukhovni
9f8231027b CHANGES.md updates
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jul 21 14:12:07 2026
(Merged from https://github.com/openssl/openssl/pull/31964)
2026-07-21 16:11:36 +02:00
Viktor Dukhovni
4abb70d327 PSK: Handle non-empty client sid_ctx
- Do not reject external PSKs when client-side sid_ctx is set, fixed
  by copying the sid_ctx into the pending session.

Tests added for this and also the server side sid_ctx issues.

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jul 21 14:12:06 2026
(Merged from https://github.com/openssl/openssl/pull/31964)
2026-07-21 16:11:36 +02:00
Viktor Dukhovni
ecd8d329f3 Fix TLS 1.3 PSKs with SSL_VERIFY_PEER and no sid_ctx.
A server with client certificate verification requested, but no
session ID context configured, wrongly rejected every TLS 1.3
PSK-based connection, whether a resumption ticket, or an external
PSK.  After a full non-PSK handshake the same server issued a
poison resumption PSK (session ticket) that led to handshake
failure if/when used.

The session ID context check exists to stop SSL acceptors with
distinct authentication policies that share a session cache from
resuming each other's sessions and trusting their authentication
results; it doesn't apply to a just-validated external PSK, so
the corresponding sessions are now exempted.  Ticket issuance is
also suppressed when it's already known that the ticket would lead
to a handshake failure with the same server's configuration.

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jul 21 14:12:04 2026
(Merged from https://github.com/openssl/openssl/pull/31964)
2026-07-21 16:11:36 +02:00
Norbert Pocs
4cef487f2a Guard against NULL data in empty ASN1_STRINGs
Since 28179061bf a zero-length ASN1_STRING has data == NULL in
fuzzing builds instead of a 1-byte allocation. Several call sites
did pointer arithmetic or memcpy on the data pointer before any
length check, which is undefined behaviour for NULL even with a
zero offset and aborts the fuzz targets under UBSan:

- asn1_string_canon: skip canonicalisation of empty values
- do_buf, do_hex_dump: return early on an empty buffer
- i2d_ocsp_nonce: skip the memcpy for an empty nonce

The loops at these sites were already no-ops for zero length, so
there is no behaviour change outside sanitizer builds.

Assisted-By: Claude:claude-fable-5

Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jul 21 12:54:48 2026
(Merged from https://github.com/openssl/openssl/pull/31998)
2026-07-21 14:54:46 +02:00
Nikola Pajkovsky
63afe63914 quic: report SRTM entry match status via an output argument
Coverity (CID 1696969, CHECKED_RETURN) flagged the ignored return value of
ossl_quic_srtm_remove() in ch_enqueue_retire_conn_id(). The return value
could not be usefully checked because 0 was overloaded to mean both "no
matching entry" and a genuine internal failure (alloc_failed or an
lhash consistency error).

Give the return value a single meaning (1 on success, 0 on internal
error) and report whether a matching entry was found through a new
uint8_t *match output argument, which may be NULL if the caller does not
need it.

Resolved: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=1696969
Signed-off-by: Nikola Pajkovsky <nikola@pajkovsky.cz>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Jul 21 09:24:45 2026
(Merged from https://github.com/openssl/openssl/pull/31974)
2026-07-21 11:24:37 +02:00
Andrew Dinh
fcba83dc4d Wire radix QUIC test framework clock to simulated time
script_17/18/19 (key update tests) rely on OP_SKIP_TIME to advance
simulated time so that TXKU cooldown/RTT-gated behaviour can be
exercised deterministically, but the framework never actually plumbed
that simulated clock into the QUIC channels under test -- OP_SKIP_TIME
only affected the terp's own bookkeeping, so real key updates only
ever occurred by chance regardless of how much time was "skipped".

Fix this by:

- Calling ossl_quic_set_override_now_cb() in hf_new_ssl() so each QUIC
  channel actually uses the framework's simulated clock, matching what
  the older quictestlib.c harness already did via fake_now_cb().
- Activating the server-side connection object in hf_accept_conn() so
  it gets ticked (SSL_handle_events()) like every other object, driving
  its internal key-update/timer processing forward.

Two correctness issues had to be addressed to make this clock
plumbing safe and deterministic:

- The clock handed to QUIC channels must be purely virtual (a fixed
  base time plus an explicit slip that only advances via
  radix_skip_time()/OP_SKIP_TIME), not real wall-clock time, or
  protocol-timing-sensitive assertions become flaky depending on how
  long real cryptographic work takes on a given machine (e.g. much
  slower on ASAN+UBSAN debug builds), occasionally triggering a
  spurious second TXKU before the first is confirmed. radix_process is
  a single static struct reused across every script in the suite, so
  time_slip must be reset in RADIX_PROCESS_init() -- otherwise a
  script would inherit the previous script's accumulated slip and see
  time jump forward all at once for a brand new connection. The
  virtual clock also needs a small, fixed per-tick advance
  (do_per_op(), mirroring the old harness's qtest_add_time(1) in its
  own connect-wait loop), since QUIC's internal timers need to
  observe time actually passing to make progress during a busy-wait
  such as hf_connect_wait spinning on SSL_connect().
- time_slip needs its own dedicated mutex (time_m) rather than being
  protected by the existing global mutex (gm): get_time() is now
  called by libssl/QUIC's internals (e.g. from within the reactor tick
  while holding QUIC's own locks), whereas gm is held by test code
  across calls into libssl (e.g. hf_clear() holds gm while calling
  SSL_free()). Sharing gm would take gm and QUIC's internal lock in
  opposite orders across those two paths, risking a real deadlock
  (confirmed via a ThreadSanitizer lock-order-inversion report).
- The terp's own script-execution watchdog (max_execution_time) needs
  its own now_cb (terp_now) based on real wall-clock time, so that
  OP_SKIP_TIME doesn't eat into its execution budget, and so it can
  still catch a genuinely stuck script independent of the virtual
  protocol clock. Some scripts also legitimately need a larger budget
  than the terp default on slow or heavily instrumented CI machines.

Assisted-by: Claude:claude-sonnet-5

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:53 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
08d3dd81b2 Port script_19 to radix test framework
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:51 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
7c6adaee6b Port script_18 to radix test framework
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:49 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
9b94348003 Port script_17 to radix test framework
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:48 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
e528888bc0 Port script_16 to radix test framework
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:46 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
b27fe1419c Port script_15 to radix test framework
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:22:44 2026
(Merged from https://github.com/openssl/openssl/pull/31889)
2026-07-21 11:22:31 +02:00
Andrew Dinh
458bfef110 Fix clean target find/-prune precedence bug
The clean target's find command intended -prune to apply to the whole
-o chain of excluded submodule paths, but -prune only binds to the
immediately preceding -path, so only the last path (wycheproof) was
actually protected from recursion. Earlier
submodules (cloudflare-quiche, pkcs11-provider, etc.) were still
descended into, letting make clean delete vendored symlinks inside
them. Move -prune outside the parenthesized path list so it applies
whenever any excluded path matches.

Assisted-by: Claude:claude-sonnet-5
Fixes: 70741ee62a "Configurations/unix-Makefile.tmpl: make cleanup faster"

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Tue Jul 21 09:21:37 2026
(Merged from https://github.com/openssl/openssl/pull/32006)
2026-07-21 11:21:31 +02:00
Andrew Dinh
db5b985369 Migrate QUIC_TSERVER script 13 and script 14 to radix
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul 21 09:19:57 2026
(Merged from https://github.com/openssl/openssl/pull/31945)
2026-07-21 11:19:33 +02:00
Jakub Zelenka
a44ba221ab apps: test rsa -text option
The -text option of the rsa app was not exercised by any test. Add a
subtest that prints both a private and a public key in text form and,
after stripping the colon-separated hex formatting, verifies the printed
modulus and private exponent match the committed testrsa.pem keypair
rather than merely checking that the labels are present.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/31950)
2026-07-21 09:32:12 +10:00
Loganaden Velvindron
695eb4bd64 ml_kem: Add a check for shared_secret
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Mon Jul 20 11:21:15 2026
(Merged from https://github.com/openssl/openssl/pull/31822)
2026-07-20 13:21:13 +02:00
Eugene Syromiatnikov
ef6f59329d demos: wire up echecho
Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Reported-by: Frederik Wedel-Heinen <frederik.wedel-heinen@dencrypt.dk>
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:19:04 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
2216d3b10f demos/sslecho/echecho.c: apply Windows-specific changes
Similar to the ones present in demos/sslecho/main.c.

Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:19:03 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
87b0f363dc demos/sslecho/echecho.c: check return values of SSL_* calls
As otherwise it triggers -Werror=unused-result when built
with --strict-warnings.

Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:19:01 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
7a4522bf26 demos/sslecho/echecho.c: use SSL_set1_ipaddr() instead of SSL_set1_host()
As the latter was deprecated in commit f584ae959c "Let's support
multiple names for certificate verification".

Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:19:00 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
bf1f522f34 demos/sslecho/echecho.c: declare locally used functions as static
Otherwise it triggers -Werror=missing-prototypes when built
with --strict-warnings.

Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:59 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
936a9ce283 demos/sslecho/echecho.c: use <stdbool.h>
...instead of defining it (incorrectly).

Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:58 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
0e1176078f demos/sslecho/echecho.c: reflow overly long lines
Complements: 50580382ca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:57 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
913cd240c7 demos: add PKCS#12 reading and writing demos to the primary build system
For some reason, demos in the pkcs12 directory were omitted during
the initial conversion done in commit 2000281dad "Convert demos
to primary build system".  Rescind this omission.

Complements: 2000281dad "Convert demos to primary build system"
Reported-by: Frederik Wedel-Heinen <frederik.wedel-heinen@dencrypt.dk>
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:55 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
3227ca41ec demos/pkcs12/pkwrite.c: drop deprecated init calls
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:54 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
25a7067b3d demos/README.txt: mention quic-server-block.c and quic-server-non-block.c
Complements: dad45ea769 "Adds a new demo blocking QUIC server for use with the existing demo QUIC clients"
Complements: d9d4d84ceb "Add demo QUIC non-blocking server"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:53 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
8f8c42fa2d demos: wire up tls-server-block
The blocking TLS server demo code was added f4b4a185b5 "MVP demo TLS
server", which, while was applied after 2000281dad "Convert demos
to primary build system", was authored before, and hasn't been updated
accordingly.  Rescind that omission by add the relevant introes
to build.info.

Also, while at it, mention tls-server-block in demos/README.txt.

Complements: f4b4a185b5 "MVP demo TLS server"
Reported-by: Frederik Wedel-Heinen <frederik.wedel-heinen@dencrypt.dk>
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:52 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Eugene Syromiatnikov
940f4930c8 demos/guide/tls-server-block.c: check results of __owur API calls
Check results of SSL_CTX_set_session_id_context()
and SSL_CTX_set_timeout() calls, as these functions are marked
with __owur, leading to compilation error when compiled
with -Werror=unused-result.

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:18:51 2026
(Merged from https://github.com/openssl/openssl/pull/31751)
2026-07-20 13:18:33 +02:00
Weidong Wang
8194b426f9 Add regression test for negative EVP_CIPHER_get_iv_length() in PKCS5_pbe2_set_scrypt
A malicious provider returning SIZE_MAX as IV length causes
evp_cipher_cache_constants() to store -1 via size_t->int truncation.
Without the ivlen > 0 guard, this leads to memcpy(iv[16], aiv, SIZE_MAX)
— a stack buffer overflow.

The test registers a fake provider with SIZE_MAX IV length, then calls
PKCS5_pbe2_set_scrypt() and asserts it returns NULL without crashing.

test for #30510

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Mon Jul 20 11:15:18 2026
(Merged from https://github.com/openssl/openssl/pull/30615)
2026-07-20 13:15:11 +02:00
Frederik Wedel-Heinen
437e09afb1 Make sure we always check return of CRYPTO_UP_REF which can fail.
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Mon Jul 20 11:13:58 2026
(Merged from https://github.com/openssl/openssl/pull/31753)
2026-07-20 13:13:57 +02:00
John Claus
4f258c3f3c Fix DSA with SHA-384 / SHA-512 X.509 verification (issue openssl#30432)
Register dsa_with_SHA384 and dsa_with_SHA512 in obj_xref so signature verification resolves digest + DSA key type.

Add test_verify regression tests and PEM fixtures; add executable DSA cert generation in test/certs/setup.sh. CHANGES.md and NEWS.md entries for 4.0→4.1.

Address review: plan tests 215, remove CHANGES merge artifact, replace comment-only setup.sh notes with actual openssl commands.

Fixes openssl#30432

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 20 11:10:47 2026
(Merged from https://github.com/openssl/openssl/pull/30655)
2026-07-20 13:10:45 +02:00
Norbert Pocs
0345927a02 test_ocsp: bump test number
Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 20 10:19:08 2026
(Merged from https://github.com/openssl/openssl/pull/32014)
2026-07-20 12:02:17 +02:00
Enji Cooper
1512b30732 INSTALL.md: document --manpage-format changes
This change documents the new Configure option, `--manpage-format`.

Address formatting issues and expound on the `Reconfigure` section.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 20 09:52:30 2026
(Merged from https://github.com/openssl/openssl/pull/28450)
2026-07-20 11:52:21 +02:00
Enji Cooper
5bbc49a5c9 Add mandoc output support for manpages
This change modifies the Makefile generator to support mandoc format
manpages, in lieu of \*roff format manpages.

After this commit the user has the ability of specifying the manpage
format to the `--manpage-format` flag. The 2 supported manpage formats
as of writing are "mdoc" and "roff" and the default remains the "roff"
format for legacy and portability reasons.

The mandoc format requires pod2mdoc to be installed, whereas the roff
output format requires pod2man to be installed. The former requires an
additional utility be installed, whereas the latter uses pod2man, a
utility that has been present with perl distributions for well over a
decade.

mandoc format support is being added as it is an easier/arguably more
structured manpage format to parse, making it easier for downstream
consumers like FreeBSD to implement OS-specific build support, as the
minimum dependencies for the OpenSSL build process are more involved
than the tools available for the FreeBSD OS bootstrapping process.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 20 09:52:29 2026
(Merged from https://github.com/openssl/openssl/pull/28450)
2026-07-20 11:52:21 +02:00
Mounir IDRASSI
a5b3f8863f Fix SM2 RISC-V64 crash from functions emitted into .rodata
The ecp_sm2p256-riscv64.pl generator switches to .section .rodata
to emit constant data (.Lpoly, .Lord, .Lpoly_div_2, .Lord_div_2), but
never switches back before emitting function code.

As a result, the function symbols defined by this file are assembled
into .rodata instead of executable .text. On systems enforcing NX for
.rodata, calling the RISC-V64 SM2 assembly faults immediately.

Fix this by adding .previous after the constant block, restoring the
initial .text section before function emission.

Verified with readelf: before the fix, .text is empty and the function
symbols are in .rodata; after the fix, constants remain in .rodata and
the function symbols are in executable .text.

Introduced in commit 05301b100f (PR #25918).

Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Mon Jul 20 09:47:35 2026
(Merged from https://github.com/openssl/openssl/pull/31874)
2026-07-20 11:47:26 +02:00
Frederik Wedel-Heinen
f106d7632a Only verify software can build if it is not a documentation only PR.
Resolves: https://github.com/openssl/openssl/issues/29167

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Mon Jul 20 09:46:03 2026
(Merged from https://github.com/openssl/openssl/pull/30712)
2026-07-20 11:46:00 +02:00
Jakub Zelenka
6a1f43c5dd apps: add offline OCSP request/responder/verify round-trip test
Exercise the request-generation and built-in responder halves of the
ocsp app without any sockets: build a request, have the responder
answer it against the static index, then verify the self-generated
response.

This covers make_ocsp_response, lookup_serial, add_ocsp_cert,
add_ocsp_serial and the status-printing body of print_ocsp_summary
(GOOD and UNKNOWN), none of which were reached by the existing
-respin-only app tests.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Mon Jul 20 09:29:35 2026
(Merged from https://github.com/openssl/openssl/pull/31834)
2026-07-20 11:29:31 +02:00
olszomal
27858603cb doc: clarify pkeyutl -rawin and -digest for no-prehash signatures
Complements: 5421423 "Flexible encoders for ML-DSA"

Signed-off-by: olszomal <Malgorzata.Olszowka@stunnel.org>

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Mon Jul 20 09:13:08 2026
(Merged from https://github.com/openssl/openssl/pull/31478)
2026-07-20 11:13:03 +02:00
Jakub Zelenka
2e49fe4ad8 statem: test tls_construct_client_certificate
Exercise the certificate output functions under mfail with real key
material embedded in the test: an x509 chain over TLS 1.3 and an RPK over
TLS 1.2.  Add deterministic tests for the error branches mfail cannot
reach: an unknown certificate type, a failed write-key change, and
WPACKET failures writing the TLS 1.3 context.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 20 09:11:48 2026
(Merged from https://github.com/openssl/openssl/pull/31861)
2026-07-20 11:11:36 +02:00
Jakub Zelenka
7f850c3dbb statem: test tls_construct_end_of_early_data
Cover the success path (state advances to FINISHED_WRITING, empty body)
and the invalid-state error path.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 20 09:11:47 2026
(Merged from https://github.com/openssl/openssl/pull/31861)
2026-07-20 11:11:36 +02:00
Jakub Zelenka
3a38f542ad statem: generalize statem_clnt construct test helpers
Parameterize prime_ssl() by message type and extract a generic
finish_msg() so the scaffolding is reusable by other client construct
tests.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 20 09:11:45 2026
(Merged from https://github.com/openssl/openssl/pull/31861)
2026-07-20 11:11:36 +02:00
Jakub Zelenka
e0bf61917a apps: decode DTLSv1.2 records in s_client/s_server -msg output
The msg_cb message callback used by the -msg option only recognised
DTLSv1.0 among the DTLS versions, so DTLSv1.2 records were logged as
"Not TLS data or unknown version" instead of being decoded. Add
DTLS1_2_VERSION to the recognised version check and to the ssl_versions
lookup table, and wrap the now-overlong condition.

Add a test that runs s_client against s_server over TLSv1.2, TLSv1.3 and
DTLSv1.2, logging the protocol messages via -msg, and checks that every
record is decoded (no "Not TLS data or unknown version" lines).

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
MergeDate: Mon Jul 20 09:09:07 2026
(Merged from https://github.com/openssl/openssl/pull/31994)
2026-07-20 11:08:51 +02:00
Nikola Pajkovsky
1865b55846 test: update provider Valgrind suppression
The internal provider test intentionally retains its configured provider
when OPENSSL_cleanup() is skipped under OSSL_USE_VALGRIND. The existing
suppression accounts for this state but no longer matches the provider
activation stack because provider_init() appears between
OSSL_provider_init() and provider_activate().

Add the missing frame so the provider context and its diagnostic strings
are correctly suppressed.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Mon Jul 20 09:07:11 2026
(Merged from https://github.com/openssl/openssl/pull/31961)
2026-07-20 11:06:53 +02:00
Nikola Pajkovsky
29616c15e4 test: clean up thread-local key in QUIC radix tests
The QUIC radix test creates a new thread-local key for each script but
only clears the associated value during teardown. The key itself
is never deleted.

Delete the thread-local key after all child threads have joined and the
main-thread value has been cleared.

  1,536 bytes in 3 blocks are still reachable in loss record 873 of 915
     at 0x488D0B0: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
     by 0x49561CF: pthread_setspecific@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
     by 0x5C0FD7: CRYPTO_THREAD_set_local (threads_pthread.c:1030)
     by 0x41132F: radix_thread_init (quic_bindings.c:570)
     by 0x4114F7: bindings_process_init (quic_bindings.c:604)
     by 0x422563: test_script (main.c:28)
     by 0x5152DF: run_tests (driver.c:518)
     by 0x517447: main (main.c:52)

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Mon Jul 20 09:07:10 2026
(Merged from https://github.com/openssl/openssl/pull/31961)
2026-07-20 11:06:53 +02:00
Nikola Pajkovsky
a20fa49828 test/p_ossltest: fix uninitialised bytes written in TLS1-AAD GCM mode
The test provider's fake AES-128-GCM cipher works by running the real
sub-cipher for its side effects and then copying the memdup'd input
back over the output buffer, so the "encrypted" record is really the
plaintext.

In a TLS record the buffer handed to the cipher reserves an
uninitialised 8-byte explicit IV at the front and a 16-byte auth tag
at the end for the cipher to fill. OPENSSL_memdup() duplicated those
uninitialised IV/tag regions, and the subsequent memcpy(out, inbuf, inl)
copied them into out. That output was then written to the socket,
triggering valgrind's "Syscall param write(buf) points to uninitialised
byte(s)":

    at sock_write (bss_sock.c:155)
    by bwrite_conv (bio_meth.c:79)
    by BIO_write (bio_lib.c:397)
    by statem_flush (statem.c:963)
    by ossl_statem_client_post_work (statem_clnt.c:881)
    ...

Track whether EVP_CTRL_AEAD_TLS1_AAD was set (recorded in
set_ctx_params) and, when encrypting a TLS record, copy only the
plaintext payload back, leaving the explicit IV and tag that the real
sub-cipher actually produced intact.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Mon Jul 20 09:07:08 2026
(Merged from https://github.com/openssl/openssl/pull/31961)
2026-07-20 11:06:53 +02:00
Nikola Pajkovsky
d00cf645c1 test: include PID in valgrind log file names
Append the %p (process ID) placeholder to valgrind's --log-file in
both app() and test(). When a test spawns multiple processes sharing
the same result index, they previously wrote to the same log file and
clobbered each other's output. Using %p gives each process its own
log, so no valgrind findings are lost.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Mon Jul 20 09:07:07 2026
(Merged from https://github.com/openssl/openssl/pull/31961)
2026-07-20 11:06:53 +02:00
Frederik Wedel-Heinen
7f58002be8 Removes unused functions and macros from ssl_local.h and recmethod_local.h
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Mon Jul 20 09:06:08 2026
(Merged from https://github.com/openssl/openssl/pull/31719)
2026-07-20 11:05:57 +02:00
Norbert Pocs
13bef2616f tests: Check the return value of BN_hex2bn()
Fixes coverity issues 1398635, 1696548, 1696549.

Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jul 20 09:04:13 2026
(Merged from https://github.com/openssl/openssl/pull/31943)
2026-07-20 11:04:11 +02:00
Viktor Dukhovni
5bf14bcaae Extend TLS group list parser test cases
The new edge case tests cover potential parser invariant violations
fixed in the prior commit.

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Mon Jul 20 07:12:31 2026
(Merged from https://github.com/openssl/openssl/pull/31926)
2026-07-20 09:12:19 +02:00
Viktor Dukhovni
5b445cd96a Fix removal of sole key exchange group in tuple
- Don't attempt to float its keyshare if any
- Include active tuple in memmove() that excises a newly empty closed tuple.

Add comments to clarify the logic.

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Mon Jul 20 07:12:30 2026
(Merged from https://github.com/openssl/openssl/pull/31926)
2026-07-20 09:12:19 +02:00
Jakub Zelenka
d4357db45c mkwraps: resolve system (libc) functions via compiler include paths
WRAP[] lists mix OpenSSL functions with libc/POSIX ones such as read()
or socket(), which mkwraps.pl reported as "declaration not found" since
it only searched the project's INCLUDE[] directories.

Fall back to the C compiler's default include search paths for functions
missing from the project headers.  They are queried lazily, only on such
a miss, so the all-OpenSSL case still does not walk /usr/include.  Parse
the glibc trailing attribute macros (__THROW, __wur, ...) and restrict
qualifier, and add --cc and --no-system.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Mon Jul 20 07:00:57 2026
(Merged from https://github.com/openssl/openssl/pull/31936)
2026-07-20 09:00:49 +02:00
Billy Brumley
4bf85819b7 [providers/implementations/ciphers] GCM-SIV: reject out-of-order update calls
For GCM-SIV:

1. AAD must precede the payload
2. the payload must be single shot

(2) was already happening, this change moves from a silent fail to
an explicit error message for multiple update calls on the payload.

For (1), this change unifies the logic for (2) one level up in the wrapper.
So the code previously allowed (1), and now errors out after this change.

Follow-up to #31906

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 06:56:04 2026
(Merged from https://github.com/openssl/openssl/pull/31940)
2026-07-20 08:55:44 +02:00
Jakub Zelenka
caf63500b6 apps: add dgst test coverage for -keyform option
The -keyform (OPT_KEYFORM) option of the dgst app was not exercised by
any test.  Add a subtest that converts the RSA test keys to DER and
then signs and verifies with -keyform DER, covering the option for both
the private and public key loading paths.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Mon Jul 20 06:40:45 2026
(Merged from https://github.com/openssl/openssl/pull/31946)
2026-07-20 08:40:40 +02:00
Ondrej Moris
61b8506921 tests: reduce pkcs11-provider log test to failures
If pkcs11-provider external test fails, only output of failed tests
is printed.

Signed-off-by: Ondrej Moris <omoris@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Igor Ustinov <igus@openssl.foundation>
MergeDate: Mon Jul 20 06:29:41 2026
(Merged from https://github.com/openssl/openssl/pull/31947)
2026-07-20 08:29:37 +02:00
Jakub Zelenka
5eb81718bc apps: test dsa -text option
The -text option of the dsa app was not exercised by any test. Add a
subtest that prints both a private and a public key in text form and,
after stripping the colon-separated hex formatting, verifies the printed
private and public values match the committed testdsa.pem keypair rather
than merely checking that the labels are present.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Mon Jul 20 06:26:08 2026
(Merged from https://github.com/openssl/openssl/pull/31949)
2026-07-20 08:26:03 +02:00
Bob Beck
ba569d08ed Add a patch disabling the pem_encoder test
This seems to have strange internal failures retrieving EC keys from
the kryoptic soft hsm. (based on reading the meson stuff this also
occurs on some linux distros and this is disabled there too)

The same test appears to work fine with RSA keys, but diagnosing
this is challenging with nothing int the voluminous output that
might say why it didn't work. So disable this for now

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sat Jul 18 13:01:21 2026
(Merged from https://github.com/openssl/openssl/pull/31194)
2026-07-18 15:01:13 +02:00
Bob Beck
9044e5f425 Convert internal use of ASN1_STRING_set and ASN1_STRING_length
to use their non-deprecated replacements. For "pretty-printing"
applications and test code that use a length and require an int, size_t lengths
are simply cast to an int. For writes and protocol level things
size_t lengths are checked against INT_MAX and take the error
path if the returned value is too large to be used for a funciton
that takes an integer length.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sat Jul 18 13:01:19 2026
(Merged from https://github.com/openssl/openssl/pull/31194)
2026-07-18 15:01:13 +02:00
Bob Beck
0161fe45d1 Add a CHANGES.md entry
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sat Jul 18 13:01:18 2026
(Merged from https://github.com/openssl/openssl/pull/31194)
2026-07-18 15:00:57 +02:00
Bob Beck
8d9fb09b9e pass length in cmp_msg stuff
ossl_cmp_sk_ASN1_UTF8STRING_push_str depended under the covers on
passing a -1 to have strlen magically called in the setter. Don't
depend on this and simply pass in the correct length

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sat Jul 18 13:01:17 2026
(Merged from https://github.com/openssl/openssl/pull/31194)
2026-07-18 15:00:57 +02:00
Bob Beck
28179061bf Prepare a now opaque ASN1_STRING for the size_t rapture.
Now that ASN1_STRING is opaque, we can finally move away
from an int for the length internally. The remaining problematic
piece for this is that ASN1_STRING_length() returns an int
and is public API.

Therefore, we deprecate ASN1_STRING_length() and provide a
replacement ASN1_STRING_length_ex() that returns a size_t length.

We also provide setting functions that take size_t lengths,
they are ASN1_STRING_set_data() which takes a uint8_t data
pointer and a size_t length, and ASN1_STRING_set_string() which
takes a argument that must be a c string and will use strlen
to determine the length. (This replaces th previous arcane
behaviour of calling "strlen" on a magical input length value
of -1, which leads to bugs.)  We then deprecate ASN1_STRING_set().

ASN1_STRING_set_string() requires a valid C string argument that
may not be NULL - refer to the documentation.

Both new functions do not magically add 0 bytes on the end of
values, as ASN1_STRING has already been documented for a long
time to not depend on this behaviour.

Both new functions do not allow the setting of values on an
ASN1_BIT_STRING, as ASN1_BIT_STRING_set1 must be used for that.

Note that this does *NOT* yet change ASN1_STRING to use size_t
internally, this must wait until the integer-returning ASN1_STRING_length()
has been deprecated, and then removed in future major. Once
ASN1_STRING_length() has been removed then ASN1_STRING internally
can change to using a size_t for the length of the data.
(And the setters will no longer return an error if the provided
size_t length exceeds INT_MAX)

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sat Jul 18 13:01:15 2026
(Merged from https://github.com/openssl/openssl/pull/31194)
2026-07-18 15:00:57 +02:00
Jakub Zelenka
d8bf6cdd48 test: don't depend on DTLS alert delivery in sslrecords test
The unknown-record-type tests (tests 5 and 6) inferred failure of a DTLS
connection from TLSProxy's socket-teardown timing ($proxy_start_success == 0).
This relied on the client's fatal alert reaching the peer before the client
closes its socket, which is a race: DTLS alerts are best-effort and are never
retransmitted (RFC 6347 section 4.2.7 / RFC 9147 section 5.10), and after the
s_client shutdown drain was skipped for datagram protocols the alert can be
lost during teardown, making the test flaky.

Verify instead what is actually under test: that the DTLS client rejected the
unrecognised record type, i.e. that s_client exited with a failure. This is a
deterministic, local decision that does not depend on the alert being observed
by the peer. Keep the alert observation as a best-effort diagnostic note.

Capture the s_client exit status in TLSProxy (previously discarded after
waitpid) and expose it via a new clientexit accessor.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Sat Jul 18 12:53:26 2026
(Merged from https://github.com/openssl/openssl/pull/31927)
2026-07-18 14:53:09 +02:00
Jakub Zelenka
49057cbe91 apps: test pkey -encopt option
The -encopt option of the pkey app was not exercised by any test; the
existing ML-DSA codec tests only used genpkey -encopt and pkey with
-provparam. Re-encode the seed-priv key into each supported PKCS#8
output format via 'pkey -encopt output_formats:<form>' and check the
result matches the reference for that form. A control compares against
the default (no -encopt) encoding so the match is attributed to -encopt
rather than the default behaviour.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Fri Jul 17 08:51:40 2026
(Merged from https://github.com/openssl/openssl/pull/31951)
2026-07-17 10:51:33 +02:00
Jakub Zelenka
4ef7e3b3cd apps: test ec and ecparam -text options
The -text option was not exercised for the ec or ecparam apps. Add a
subtest to 15-test_ec.t that prints a private and a public EC key and,
after stripping the colon-separated hex formatting, verifies the printed
private and public values match the committed testec-p256.pem keypair as
well as the curve identification. Add a subtest to 15-test_ecparam.t
that prints named and explicit parameters, checking the named form emits
the expected curve OID and NIST name while the explicit form emits the
field parameters and no OID.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Fri Jul 17 08:47:12 2026
(Merged from https://github.com/openssl/openssl/pull/31952)
2026-07-17 10:47:02 +02:00
Andrew Dinh
98a726d3ca Introduce OP_BIND() to QUIC RADIX test framework
RADIX framework keeps objects needed by test scripts
in two places:
  - hash table bound to radix process (`RP()->objs`), all
  objects are stored there
  - slot which is an array bound to radix thread (`RT()->slot[]`)

The `slot` is an array which is used to pass arguments
to RADIX ops. The typically script is doing something
like this:
```
   OP_SELECT_SSL(0, C); /* places 'C' object to slot 0 in thread */
   OP_FUNC(print_ssl);  /* calls print_ssl function, which prints object */
```
All objects are managed by RADIX framework, scripts have very
limited options to control object's lifetime. The only way for
scripts to let object go is to use `OP_UNBIND()`. The operation
removes the object from hastable (`RP()->objs`) and frees the
object afterwards. This is good enough as long a all tests
are running in single thread. Currently `OP_UNBIND()` is
required when test needs to accept/create more than one stream.
The test has two options. It can use unique name for each
stream it creates/accepts:
```
   OP_ACCEPT_STREAM_WAIT(C, C0, 0);
   OP_ACCEPT_STREAM_WAIT(C, C1, 0);
   OP_ACCEPT_STREAM_WAIT(C, C2, 0);
```
Or script may re-use the same variable for stream,
in that case `OP_UNBIND()` is needed:
```
   OP_ACCEPT_STREAM_WAIT(C, C0, 0);
   OP_UNBIND(C0);
   OP_ACCEPT_STREAM_WAIT(C, C0, 0);
   OP_UNBIND(C0);
   OP_ACCEPT_STREAM_WAIT(C, C0, 0);
   OP_UNBIND(C0);
```
Unfortunately `OP_UNBIND()` can not be used when test
uses more than one thread due to missing locking of `RP()->objs`.

Introducing a locking scheme seems to be bit invasive change,
The OP_BIND()  here hopes to be sufficient and good enough for now.

The idea is as follows:
  - `OP_BIND()` allows  script to insert empty object
  into `RP()->objs` OP_BIND() is supposed to run before
  script spawns thread(s). No manipulation of `RP()->objs`
  is allowed after threads are spawned, operations
  OP_BIND()/OP_UNBIND() are not thread safe.

  - Introduce `OP_F_REPLACE_STREAM` flag which tells
  `OP_ACCEPT_STREAM_WAIT()`/`OP_NEW_STREAM()` to re-use
   existing id for stream. This `_REPLACE_` flag requires
   read-only access to `RP()->objs` hash table.

  - change introduces a per radix object mutex so object can
  be updated safely w.r.t. RADIX thread which ticks SSL object
  bound in radix object.

The guideline for tests which require more then one thread
is as follows:
   - the first thread creates complete set of empty objects
   for all threads.

   - each test thread gets its own set of variables, so it
   can populate them later during test with SSL objects

   - objects are not supposed to be shared between threads

This is a snippet of script executed by main thread before
additional threads are spawned:

```
   ...
   OP_BIND(C1);  /* stream id for child */
   OP_BIND(S1);  /* stream id for parent */

   OP_SPAWN_THREAD(child);
   for (i = 0; i < 10; i++) {
      OP_NEW_STREAM(S, S1, OP_F_REPLACE_STREAM);
      OP_WRITE_B(S1, "foo");
      OP_CONCLUDE(S1);
   }
```
This snippet comes from child:
```
   for (i = 0; i < 10; i++) {
      OP_ACCEPT_STREAM_WAIT(C, C1, OP_F_REPLACE_STREAM);
      OP_READ_EXPECT_B(C1, "foo");
      OP_EXPECT_FIN(C1);
   }
```
As you can see parent and child don't use OP_BIND()/OP_UNBIND()
after child thread is spawned.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Fri Jul 17 08:02:04 2026
(Merged from https://github.com/openssl/openssl/pull/31821)
2026-07-17 10:01:58 +02:00
Andrew Dinh
4eab5e3bb2 Port script12
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Fri Jul 17 08:02:03 2026
(Merged from https://github.com/openssl/openssl/pull/31821)
2026-07-17 10:01:26 +02:00
Andrew Dinh
c86b202ef4 Port script11
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Fri Jul 17 08:02:02 2026
(Merged from https://github.com/openssl/openssl/pull/31821)
2026-07-17 10:01:26 +02:00
Andrew Dinh
e1febbd01a Port script10
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Fri Jul 17 08:02:00 2026
(Merged from https://github.com/openssl/openssl/pull/31821)
2026-07-17 10:01:26 +02:00
Jakub Zelenka
e8a742176a rand: fix jitter seed macro logic
The seeding macro logic was mixed up and incompletely applied. The
macro logic was also cleaned up.

Co-authored-by: Paul Dale <pauli@openssl.org>

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Fri Jul 17 04:47:07 2026
(Merged from https://github.com/openssl/openssl/pull/31970)
2026-07-17 06:46:51 +02:00
Neil Horman
cb9a902175 Fix dsaparams decoding from DER files
The tests addded in commit d8a7e8e uncovered an odd error case.

https://github.com/openssl/openssl/actions/runs/29303845665/job/86993085732

Is failing when attempting to read in a der file converting from a
corresponding PEM file containing DSA parameters.

Interestingly The problem was only occuring when:
1) The input was a DER file
and
2) Blake2 was not configured

Doing some tracing of the decoder operation showed that this is occuring
because the OSSL_STORE lookup used to find the proper decoder uses a
"first successful decode wins" approach, after which the loading code
checks to see if the decoded type matches the expected key type.

When decoding PEM, this isn't a problem, as the PEM armoring gives the
decoder a hint as to why type of data the input file is.

But with DER, there is no such hint, and we're at the mercy of whichever
decoder happens to decode the data correctly first.  Normally it works
just fine, but when features are disabled or enabled, the order in which
the decoders are attempted may change, affecting the outcome.  In this
particular case, disabling blake2 caused the DHX decoder to be attempted
first, which decodes the input der file without issue.  That in turn
caused the subsequent EVP_PKEY_is_a check to fail (as we were expecting
a DSA key), and so the test fails.

Fortunately, the code that the dsaparam applet uses to do this decode
provides a keytype hint, which we can use to guide the decode process.
keep the old store lookup method around in case anyone doesn't pass a
uri that is a file path or provide a keytype, but if we do both those
things, we can use OSSL_DECODER_CTX_new_for_pkey to specifically tell
the decoder that we want to decode the input data as the expected type
(in this case a DSA key).

Fixes #31944

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Thu Jul 16 15:28:32 2026
(Merged from https://github.com/openssl/openssl/pull/31954)
2026-07-16 11:28:30 -04:00
Jakub Zelenka
96de7d164b rand: pre-fetch JITTER seed when jitter used
This fixes failing rand mfail test when jitter used

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:18:29 2026
(Merged from https://github.com/openssl/openssl/pull/31938)
2026-07-15 18:18:24 +02:00
Jakub Zelenka
385f12644c apps: cover the crl -gendelta, -key and -keyform options
The -gendelta, -key and -keyform options of the crl app were previously
untested. It adds a subtest that generates two CRLs with an incrementing
crlNumber and then uses -gendelta with -key to produce a delta CRL,
checking the result carries a Delta CRL Indicator. It also loads the
signing key from DER via -keyform DER, and checks that a mismatching
-keyform and a missing -key both make -gendelta fail.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:05:31 2026
(Merged from https://github.com/openssl/openssl/pull/31910)
2026-07-15 18:05:24 +02:00
Jakub Zelenka
e211f88c64 apps: test genpkey app cipher option
Add coverage for encrypting the generated private key with a cipher,
checking it can only be read back with the correct passphrase, and that
a cipher is rejected together with the -genparam option.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:03:37 2026
(Merged from https://github.com/openssl/openssl/pull/31893)
2026-07-15 18:03:32 +02:00
Jakub Zelenka
dca561d4cd Integrate mfail functionality to fuzz tests
Run the fuzz corpora under mfail in addition to the normal path, so the
existing inputs also exercise malloc-failure handling. The fuzz.pl harness
sizes the mfail runs to a time budget and, on a leak, bisects down to the
exact file and injection point. Adds a budgeted asan/ubsan CI job to run it.

Assisted-by: Claude:claude-opus-4-6

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:01:43 2026
(Merged from https://github.com/openssl/openssl/pull/30944)
2026-07-15 18:01:30 +02:00
Jakub Zelenka
c263ea553c Fix fuzz test to handle memory failures
It also fixes related memory leaks and removes extensive asserts that
should not be present in fuzzy tests.

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:01:42 2026
(Merged from https://github.com/openssl/openssl/pull/30944)
2026-07-15 18:01:30 +02:00
Jakub Zelenka
857afd02b2 test: add Windows unit tests setup and initial dgram test
This adds an initial setup for unit testing on Windows that allows
mocking of system functions using Detour library. This works only for
library functions and not object function like wrap so it is a bit
limited but it is still useful for BIO mocking.

An initial BIO bss_dgram test is added covering the Windows specific
parts.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Igor Ustinov <igus@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul 15 16:00:35 2026
(Merged from https://github.com/openssl/openssl/pull/31915)
2026-07-15 18:00:29 +02:00
Richard Levitte
380d6afcb3 keccak1600x4-avx512vl: fix undefined symbols on macOS
The one-shot SHAKE x4 wrappers call the incremental absorb and squeeze
routines through call_internal(), which on non-Win64 emitted a call to
the public global symbol by its bare name.  These calls textually
precede the callees' .globl declarations, so x86_64-xlate.pl never
prepends the platform's leading underscore to the referenced symbol.

On ELF (Linux) that is harmless since symbols carry no leading
underscore, but on Mach-O (macOS) the call references the un-decorated
SHA3_shake*_x4_inc_*_avx512vl while the defined symbol is
_SHA3_shake*_x4_inc_*_avx512vl, leaving four undefined externals and
breaking the darwin64-x86_64 link of libcrypto:

  SHA3_shake128_x4_inc_absorb_avx512vl
  SHA3_shake256_x4_inc_absorb_avx512vl
  SHA3_shake128_x4_inc_squeeze_avx512vl
  SHA3_shake256_x4_inc_squeeze_avx512vl

Call the local .L_<name> entry label instead -- the same address as the
public symbol and the pattern the finalize calls already use -- so the
reference resolves locally and these internal routines cannot be
interposed.  The Win64 path is unchanged.

Fixes: https://github.com/openssl/openssl/issues/31941
Fixes: a248ec771e ("ML-DSA: Add AVX512VL SHAKE x4 multi-buffer integration")
Assisted-by: Pi:z-ai/glm-5.2

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jul 14 12:33:50 2026
(Merged from https://github.com/openssl/openssl/pull/31942)
2026-07-14 11:40:18 +02:00
Neil Horman
ac946a80d5 ugment p_ossltest with encoder/decoder/store algs
Create dummy encoder/decoder and store algs in p_ossltest.

They do nothing, except return algorithms on query.  This allows our
unit test 30-test_evp_list_noncache.t to exercise the refcounting of
these objects when the provider requests no caching

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Jul 14 05:21:38 2026
(Merged from https://github.com/openssl/openssl/pull/31844)
2026-07-14 07:20:58 +02:00
Neil Horman
f454c8fd5d Fix refcounting for ENCODER/DECODER/STORE methods without caching
https://github.com/openssl/openssl/pull/31782
Fixed method refcounting for EVP objects when the provider they are
fetched from requests no-caching, but I neglected to add simmilar
refcounting fixes for DECODERS/ENCODERS and STORE objects, who follow a
different fetch path (these use inner_[decoder|encoder|loader]_fetch
rather than inner_evp_generic_fetch.

They got missed because the p_ossltest provider that we use to test
these paths don't provide these objects, so the path never got
exercised.

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Jul 14 05:21:36 2026
(Merged from https://github.com/openssl/openssl/pull/31844)
2026-07-14 07:20:58 +02:00
Marcel Cornu
626ff8fd93 .github: add AVX512VL workflow using Intel SDE
Add a new CI workflow that runs AVX512 specific tests under Intel SDE
v10.8, since GitHub Actions runners do not currently have AVX512
hardware.
SDE emulates AVX512 instructions and spoofs CPUID so the AVX512 code
paths can be exercised.

Two jobs are included: linux (ubuntu-latest) and windows (windows-2022).
Each job builds OpenSSL with no-shared and enable-fips, then runs the
following tests under `sde64 -icx` (Icelake Server):

- ml_dsa_internal_test: exercises AVX512VL ML-DSA sampling
- sha3_x4_internal_test: exercises AVX512VL SHAKE x4 functions
- openssl fipsinstall: runs the full FIPS KAT suite (including ML-DSA
  and SHA3 self-tests) against the FIPS provider under emulation

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Mon Jul 13 15:55:57 2026
(Merged from https://github.com/openssl/openssl/pull/31090)
2026-07-13 17:55:51 +02:00
Marcel Cornu
27caecd416 test: add SHAKE x4 internal cross-validation tests
Add a new `sha3_x4_internal_test` target and recipe to validate the
internal SHAKE x4 implementation against scalar SHA3 reference paths.

Cover SHAKE-128 and SHAKE-256 in one-shot and incremental modes, plus
multi-absorb and multi-squeeze cases across varied input and output
sizes. Tests are skipped when AVX512VL extensions are not available.

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Mon Jul 13 15:55:55 2026
(Merged from https://github.com/openssl/openssl/pull/31090)
2026-07-13 17:55:51 +02:00
Marcel Cornu
a248ec771e ML-DSA: Add AVX512VL SHAKE x4 multi-buffer integration
Changes:
- Adds new SHAKE x4 API to perform 4 SHAKE operations in parallel when AVX512VL is supported.
- Adds AVX512VL Keccak x4 assembly module (keccak1600x4-avx512vl).
- Adds internal SHA3 x4 APIs/context in sha3.h and wrappers in sha3_x4.c modules.
- Adds runtime dispatch for ML-DSA sample operations with an OSSL_ML_DSA_SAMPLE_OPS vtable.
  Callers obtain the correct implementation via ossl_ml_dsa_sample_ops(), which returns
  either the generic scalar ops functions, or the AVX512VL multi-buffer ops depending
  on the build and CPU capabilities.
- Adds x86-64 multi-buffer function implementation into ml_dsa_sample_hw_x86_64.inc,
  included in ml_dsa_sample.c when KECCAK1600_ASM and x86_64 are defined.

Co-authored-by: Tomasz Kantecki <tomasz.kantecki@intel.com>
Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Mon Jul 13 15:55:54 2026
(Merged from https://github.com/openssl/openssl/pull/31090)
2026-07-13 17:55:51 +02:00
knut st. osmundsen
6736bd2cb6 Fix nasm version check for sm3 & sm4 perlasm files
Make the check correctly handle versions such as '3.00rc8'.
It was incorrectly expecting major.minor.patch.

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
MergeDate: Mon Jul 13 15:48:03 2026
(Merged from https://github.com/openssl/openssl/pull/31420)
2026-07-13 17:46:52 +02:00
Mounir IDRASSI
95f95b59dd poly1305: reject no-key update and NULL key params
Poly1305 permits EVP_MAC_init(ctx, NULL, 0, ...) as part of staged
initialization. If no key has been installed, update still dispatched
into the uninitialized Poly1305 state, which can crash on POLY1305_ASM
builds.

Guard update with the same key_set check used by final and report no key set.

Also reject an explicit OSSL_MAC_PARAM_KEY whose data pointer is NULL before
calling Poly1305_Init(), even when the supplied size is POLY1305_KEY_SIZE.

Fixes #31332

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Mon Jul 13 15:44:48 2026
(Merged from https://github.com/openssl/openssl/pull/31382)
2026-07-13 17:43:51 +02:00
Jakub Zelenka
d6c49df039 apps: cover the x509 -sigopt and -vfyopt options
The -sigopt and -vfyopt options of the x509 app were previously
untested. It adds a subtest that signs a certificate from a CSR with
-sigopt rsa_padding_mode:pss and verifies the issued certificate uses
the rsassaPss signature algorithm, and that verifies an SM2 CSR whose
self-signature uses a non-default distinguishing id supplied via
-vfyopt. It also checks that an unknown -sigopt or -vfyopt makes the
command fail.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:41:57 2026
(Merged from https://github.com/openssl/openssl/pull/31908)
2026-07-13 17:41:52 +02:00
Billy Brumley
283f6bd6bf [test] check late AAD rejection across AEADs
A late AAD update (AAD supplied after the payload has started) must be
rejected, and reported the same way, for every AEAD. #31673 checked this
for ChaCha20-Poly1305 alone, so this change extends it to all AEADs.

test_evp_aead_late_aad covers both the encrypt and decrypt directions and
asserts ERR_LIB_PROV / PROV_R_UPDATE_CALL_OUT_OF_ORDER on the late update.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Mon Jul 13 15:40:39 2026
(Merged from https://github.com/openssl/openssl/pull/31906)
2026-07-13 17:40:37 +02:00
Jakub Zelenka
28071a8c01 apps: cover the req -pkeyopt option
The -pkeyopt option of the req app was previously untested. It adds a
subtest that generates an EC request with -pkeyopt
ec_paramgen_curve:P-384 and verifies the selected curve is used, and
that an unknown -pkeyopt value makes the command fail.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:36:42 2026
(Merged from https://github.com/openssl/openssl/pull/31905)
2026-07-13 17:36:38 +02:00
Jakub Zelenka
0321c2919c apps: test pkeyutl app -rev option
Add coverage for the -rev option of the pkeyutl app, checking that the
input buffer is reversed before the operation and that -rev is rejected
together with raw input.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:35:56 2026
(Merged from https://github.com/openssl/openssl/pull/31891)
2026-07-13 17:35:50 +02:00
Jakub Zelenka
d8a7e8eec7 apps: test dsaparam app DER output paths
Add coverage for the DER (ASN.1) output of the dsaparam app, exercising
both the parameter output (i2d_KeyParams_bio) and the -genkey private key
output (i2d_PrivateKey_bio).

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:32:33 2026
(Merged from https://github.com/openssl/openssl/pull/31888)
2026-07-13 17:32:28 +02:00
Jakub Zelenka
d1d74cf253 apps: test dsa app -modulus option
Add coverage for the -modulus option of the dsa app, checking the
public value is printed for both private and public key input.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:31:54 2026
(Merged from https://github.com/openssl/openssl/pull/31887)
2026-07-13 17:31:48 +02:00
Jakub Zelenka
59a8cf3d86 apps: add test coverage for dgst -list
Exercise the previously uncovered show_digests() path in dgst app by
adding a subtest that runs "openssl dgst -list". It checks the header
and that sha256 and sha512 are listed, without assuming the full set of
digests which depends on the build configuration.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:05:45 2026
(Merged from https://github.com/openssl/openssl/pull/31886)
2026-07-13 17:05:39 +02:00
Jakub Zelenka
2d3e267b2b x509: add ocsptest for the OCSP stapled-response verification path
Add test/ocsptest.c, exercising check_cert_ocsp_resp() in x509_vfy.c
through X509_verify_cert() with X509_V_FLAG_OCSP_RESP_CHECK and
responses attached via X509_STORE_CTX_set_ocsp_resp(). This path was
previously only covered indirectly through the TLS multi-stapling
tests in sslapitest.c.

The test builds signed OCSP responses at run time from a flat
root -> leaf PKI (the root is both the trust anchor and the authorized
responder), and covers the good, grace-period, non-successful status,
expired, no-response, and wrong-certificate cases, plus a mfail run
over the success path. The PKI is generated by the test-tools ocsptest
command.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:04:59 2026
(Merged from https://github.com/openssl/openssl/pull/31828)
2026-07-13 17:04:51 +02:00
David Foster
1de3ee397c Explain inconsistency in X25519 ladder copies
Fixes #31560

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:03:15 2026
(Merged from https://github.com/openssl/openssl/pull/31812)
2026-07-13 17:03:05 +02:00
Jakub Zelenka
dc70836ce1 apps: test rsa app -RSAPublicKey_in/-RSAPublicKey_out options
Cover the previously untested -RSAPublicKey_in and -RSAPublicKey_out
options of the rsa app, which select the PKCS#1 RSAPublicKey structure
rather than the SubjectPublicKeyInfo used by -pubin/-pubout. The new
subtest checks that the RSA PUBLIC KEY header is written, that the
encoding round-trips, and that it is interchangeable with the
SubjectPublicKeyInfo form.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:01:22 2026
(Merged from https://github.com/openssl/openssl/pull/31802)
2026-07-13 17:01:17 +02:00
Jakub Zelenka
2c47163573 apps: test ecparam app -param_enc option
Exercise the previously untested -param_enc option of the ecparam app
by round-tripping the secp384r1 fixtures between named_curve and
explicit encodings (compared byte for byte against the reference
files), and check that an invalid value is rejected.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:00:27 2026
(Merged from https://github.com/openssl/openssl/pull/31799)
2026-07-13 17:00:15 +02:00
Jakub Zelenka
804fc3ecd8 apps: test ec app -param_enc option
Exercise the previously untested -param_enc option of the ec app,
covering named_curve and explicit parameter encodings (compared
against checked-in reference encodings) as well as rejection of an
invalid value.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:00:25 2026
(Merged from https://github.com/openssl/openssl/pull/31799)
2026-07-13 17:00:15 +02:00
Jakub Zelenka
da37b2b656 apps: test pkey -ec_param_enc option
Exercise the previously untested -ec_param_enc option for pkey,
covering named_curve and explicit parameter encodings as well as
rejection of the option on a non-EC key.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 14:59:39 2026
(Merged from https://github.com/openssl/openssl/pull/31798)
2026-07-13 16:59:33 +02:00
Jakub Zelenka
cedff47f38 test: build the fake cipher provider as a loadable module
The fake cipher provider was only available in-process, linked into test
binaries via fake_cipher_start().  To exercise app success paths (e.g.
skeyutl -genkey) the openssl app needs to load it as a provider module the
same way it loads legacy.

Make test/fake_cipherprov.c dual-buildable: drop the testutil dependency so
the source links cleanly into a module, add an OSSL_provider_init entry point
under FAKE_CIPHER_AS_MODULE, and add a fake-cipher MODULES target in
test/build.info.  Also implement skeymgmt generate so opaque key generation
works, and cover the skeyutl -genkey success path in 20-test_skeyutl.t.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 14:58:53 2026
(Merged from https://github.com/openssl/openssl/pull/31781)
2026-07-13 16:58:43 +02:00
slontis
79373ca3bd FIPS: EC keygen - remove unnecessary self tests.
In FIPS mode EC keygen was doing 3 self tests.
ec_generate_key() was calling both ecdsa_keygen_pairwise_test() and
ecdsa_keygen_knownanswer_test(). The KAT did a key recomputation and
comparison with the generated key, as per Sp80056Ar3 section 5.6.2.1.4.
These tests covered both Keygen PCT for Key Agreement and Signatures.
ossl_ec_key_pairwise_check() was also being called from within ec_gen().
The advice from Atsec (lab) is that the sign/verify test within
ecdsa_keygen_pairwise_test() is sufficient according to the updated
rules in FIPS 140-3 IG 10.3.A Additional comment 1, Since the usage of
the generated key is unknown at the time of key generation.

Detected during testing of Jipher by Roshith Alankandy (Oracle).

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 14:47:00 2026
(Merged from https://github.com/openssl/openssl/pull/31761)
2026-07-13 16:46:54 +02:00
Timo Keller
6d9a698615 s390x: Fix montgomery_multiplication_vectorized
Introduce `reduce_twice_signed` that reduces from `(-2q,q)` to `[0,q)`.
Fix `montgomery_multiplication_vectorized` in `ml_dsa_ntt_vec128.c`
by calling `reduce_twice_signed` at the end of the computation ensuring
that the result is in `[0,q)` and not only in `(-2q,q)` or `(-q,q)`.
Do not call `reduce_once_signed` in `ossl_poly_ntt_mult_scalar_vec128`
and at the end of `ossl_ml_dsa_poly_ntt_inverse_vec128` anymore as it is
not necessary anymore after `reduce_twice_signed`.

Without this fix, keygen, sign or verify might fail or produce wrong
results.

Signed-off-by: Timo Keller <tkeller@linux.ibm.com>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
MergeDate: Mon Jul 13 14:45:11 2026
(Merged from https://github.com/openssl/openssl/pull/31744)
2026-07-13 16:45:07 +02:00
Jakub Zelenka
58f032a042 cms: fix AuthEnvelopedData authAttrs tags and verify them as AEAD AAD
The CMS_AuthEnvelopedData ASN.1 template used the implicit tags and the
X509_ALGOR type copied from CMS_AuthenticatedData. Per RFC 5083 the authAttrs
and unauthAttrs fields are [1] and [2] (not [2] and [3]) and are SET OF
Attribute, so use X509_ATTRIBUTE with the correct tags, matching the
STACK_OF(X509_ATTRIBUTE) members already declared in the structure.

With the tags fixed, authEnvelopedData carrying authAttrs now parses, so the
authenticated attributes must also be fed to the content cipher as the AEAD
associated data required by RFC 5083 section 2.1. Encode their DER (with the
universal SET OF tag) for both encryption and decryption; without this the GCM
tag fails to verify against compliant senders such as BouncyCastle.

RFC 5083 also requires that plaintext is not released until its integrity has
been verified. The AEAD tag is only checked once all the ciphertext has been
processed, so buffer the decrypted content and forward it to the output BIO
only after that check succeeds; a tampered message then leaks nothing to -out.

Add an interop test using a BouncyCastle-generated AES-128-GCM message with
authenticated and unauthenticated attributes, plus a tampered copy that must
fail the tag check and leave -out empty.

Closes #31635
Closes #26101
Closes #31629

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 14:41:34 2026
(Merged from https://github.com/openssl/openssl/pull/31695)
2026-07-13 16:41:28 +02:00
Neil Horman
f1be99832f Remove the rio_notifier run_once routine
We do this odd thing in rio_notifier.  when we initalize it, we call a
run_once routine to call WSAStartup(), create a lock and init a
refcount.  The purpose of those last two items is to track the refcount
so that we record how many times we init that rio notifier.  when the
refcount reaches zero, we tear down the windows socket api by calling
WSA cleanup, destroy the lock and refcount, and then re-initzlize the
run_once gate.

That last step is sketchy.  Even though our implementations of run_once
allow doing so, we should never be re-initing those gates, as its going
to be very prone to races, and they are, well, run_once, so we should
only run them once.

It would be nice to get rid of that behavior, which we can fortunately
do.

https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup

Indicates that WSAStartup is internally refcounted, so instead of just
calling it once and tracking when we need to correspondingly call
WSACleanup(), just call it every time we initalize an rio_notifier
object, and call WSACleanup when we tear it down.  The Winsock api will
take care of knowing when it actually needs to be cleaned up for us.  As
such we can eliminate the run_once routine, the refcount and the lock
entirely.

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon Jul 13 14:26:58 2026
(Merged from https://github.com/openssl/openssl/pull/31777)
2026-07-13 10:26:56 -04:00
Jakub Zelenka
e1386ecb2d test: drop no-cached-fetch mfail guards
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 09:43:51 2026
(Merged from https://github.com/openssl/openssl/pull/31780)
2026-07-13 11:43:40 +02:00
Jakub Zelenka
4b8fece0f1 mfail: add sampled and count-only modes to test driver
Sampled tests cap allocation-failure injection at a fixed number of
sampled points, running exhaustively when the allocation count is below
that.  Non-sampled tests fall back to counting only on non-cached-fetch
builds, where exhaustive injection is impractical.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 09:43:50 2026
(Merged from https://github.com/openssl/openssl/pull/31780)
2026-07-13 11:43:40 +02:00
Ondrej Moris
47ddf0095d Update pkcs11-provider submodule (5dcc876)
Signed-off-by: Ondrej Moris <omoris@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Igor Ustinov <igus@openssl.foundation>
MergeDate: Mon Jul 13 08:14:30 2026
(Merged from https://github.com/openssl/openssl/pull/31907)
2026-07-13 10:14:22 +02:00
Marc Gutman
d7e77b66ca Don't raise NOT_ENOUGH_DATA on a clean EOF at an object boundary
asn1_d2i_read_bio() reads one ASN.1 object at a time from a BIO.  Callers
commonly loop, decoding concatenated DER values until the call fails, and
rely on a failure with no queued error to recognise a clean end of input.
CPython's ssl module does this in _add_ca_certs() when loading the Windows
certificate store via SSLContext.load_verify_locations(cadata=...); it
re-raises any leftover ASN.1 error other than ASN1_R_HEADER_TOO_LONG as
fatal.

Commit 9eb6922c59 ("asn1: raise NOT_ENOUGH_DATA on header EOF") changed the
BIO_read() check from "i < 0" to "i <= 0", so a clean EOF (BIO_read()
returning 0, as an exhausted BIO_new_mem_buf does) on an object boundary now
raises ASN1_R_NOT_ENOUGH_DATA instead of failing with an empty error queue.
The rewrite in commit 35852da1d9 carried this behaviour forward.  As a
result Python 3 on Windows fails to initialise an SSLContext with:

    ssl.SSLError: [ASN1: NOT_ENOUGH_DATA] not enough data

Raise ASN1_R_NOT_ENOUGH_DATA only on an actual read error, on an EOF in the
middle of an object (some bytes already buffered), or on an EOF while still
inside an indefinite-length value awaiting its end-of-contents octets - all
of which are genuine truncation.  A clean EOF at a top-level object boundary
again fails without queuing an error, restoring the long-standing behaviour
that looping callers depend on.

Add regression tests covering the clean-EOF, truncated, indefinite-length
truncation and partial-header cases, and document the read behaviour in
ASN1_item_d2i_bio(3).

Fixes #31807

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Igor Ustinov <igus@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 08:05:03 2026
(Merged from https://github.com/openssl/openssl/pull/31818)
2026-07-13 10:04:34 +02:00
Bob Beck
914ba181ce Remove leftover _WIN32_WCE reference in ms/uplink.c
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 17:39:41 2026
(Merged from https://github.com/openssl/openssl/pull/31913)
2026-07-10 13:39:24 -04:00
Bob Beck
10b5f9f897 Drop Windows-on-Itanium (VC-WIN64I) support.
Similar to Windows CE, Windows Itanium has not had a
toolchain to work on it since VS 2010, and Windows
server 2008 was the last thing that ran on it.

This does *not* change the other (linux, HPUX) targets
which have modern toolchain support, and likely even still
run these days.

While never letting go seems noble when you won't share
the door you're floating on, the time has come.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 17:39:39 2026
(Merged from https://github.com/openssl/openssl/pull/31913)
2026-07-10 13:39:24 -04:00
Mounir IDRASSI
7f4ac80224 test: cover empty directoryName name constraints
Add NAME_CONSTRAINTS_check() coverage for empty directoryName
subtrees in both excluded and permitted constraints.

The tests assert the existing results in ordinary builds and catch
the NULL memcmp() argument when run under UBSan.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Fri Jul 10 15:51:03 2026
(Merged from https://github.com/openssl/openssl/pull/31814)
2026-07-10 17:50:55 +02:00
Mounir IDRASSI
fce540139a x509: avoid NULL memcmp argument in nc_dn()
An empty directoryName constraint has canon_enc == NULL and
canon_enclen == 0. nc_dn() must not pass that pointer to
memcmp(), even with a zero length.

Return X509_V_OK before comparing an empty base Name. This preserves
current match semantics and avoids UBSan-visible undefined behaviour.

Fixes #31687
Fixes #31688

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Fri Jul 10 15:51:01 2026
(Merged from https://github.com/openssl/openssl/pull/31814)
2026-07-10 17:50:55 +02:00
Naveed Khan
b1393a0446 pkcs12: free PKCS7 elements on error in PKCS12_unpack_authsafes
Fixes: b536880c45 "Add library context and property query support into the PKCS12 API"

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jul 10 15:48:37 2026
(Merged from https://github.com/openssl/openssl/pull/31862)
2026-07-10 17:48:31 +02:00
Jakub Zelenka
171e4e7eb6 rand: add mfail tests for generation and seeding
Add memory-failure injection coverage to rand_test for the full
RAND_bytes_ex/RAND_priv_bytes_ex stack on a fresh library context, the
SEED-SRC entropy acquisition and the CTR-DRBG operations with a
TEST-RAND parent.  The cipher fetches used by the DRBG setup are warmed
up outside the injection window so that the injection targets the RAND
machinery itself.

Assisted-by: Claude:claude-fable-5

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul 10 15:47:16 2026
(Merged from https://github.com/openssl/openssl/pull/31885)
2026-07-10 17:47:09 +02:00
Jakub Zelenka
24d208262a test-rng: handle nonce length query in generate mode
The DRBG instantiation probes the parent nonce callback with a NULL
output buffer to obtain the nonce length before requesting the actual
nonce.  The generate mode branch of test_rng_nonce() wrote the bytes
without checking the output pointer, crashing when TEST-RAND with
generate=1 is used as a DRBG parent.  The entropy-buffer branch already
handles a NULL output correctly.

Assisted-by: Claude:claude-fable-5

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul 10 15:47:15 2026
(Merged from https://github.com/openssl/openssl/pull/31885)
2026-07-10 17:47:09 +02:00
Tomas Mraz
3bf2aba5f5 Document the effect of SSL_VERIFY_FAIL_IF_NO_PEER_CERT on post-handshake auth
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Fri Jul 10 15:45:39 2026
(Merged from https://github.com/openssl/openssl/pull/31876)
2026-07-10 17:45:28 +02:00
Daniel Kubec
4f17865ba4 NULL-pointer subtraction UB in tls_collect_extensions()
Fixed invalid-pointer-pair in the existing branch by ensuring thisex != NULL
before subtraction.

Fixes #31689

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Fri Jul 10 15:40:21 2026
(Merged from https://github.com/openssl/openssl/pull/31875)
2026-07-10 17:40:09 +02:00
Bob Beck
a40f6f8bd6 Make the examples in SYTLE and DOCUMENTATON compliant.
Specifically bring them closer to the suggested naming conventions
and make them clang-format compliant.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Fri Jul 10 15:37:20 2026
(Merged from https://github.com/openssl/openssl/pull/29295)
2026-07-10 11:37:03 -04:00
Bob Beck
c17828595f Change the Doxygen doc requirement for non public functions
To be at the prototype site in the internal header file.

The major reason *Why* we would like to have Doxygen style comments
describing what internals do is so that they work with modern IDE's
since most common ones support them.

It's wonderful to be looking at an internal function, thinking "wtf is this",
and be able to hover over it and - boink - up comes the docs. This
typically only works (or works better) when the Doxygen comment is
at the prototype site, not if it is at the implementation site.

This also reinforces the requirement that "yes you do this for shared
functions but you don't need to for statics".

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Fri Jul 10 15:37:18 2026
(Merged from https://github.com/openssl/openssl/pull/29295)
2026-07-10 11:37:03 -04:00
Bob Beck
b3020646af Modernize and update STYLE.MD, add DOCUMENTATION.MD
So this repatriates DOCUMENTATION.MD from the web page to the
code base, and links both STYLE.MD and DOCUMENTATION.MD from
CONTRIBUTING.MD

It does a large rototilling of STYLE.MD to address many of the
outstanding concerns noted when I started this before clang-format
last year, and brings us roughly in line with the things that are
addressed in similar style guides for other projects.

Most of the changed or updated reccomendations reflect what we
currently have been doing, or have expressed as a desire to
move to in the future.

Most larger "OpenSSL-isms" I've tried to explicitly call out
to make this a more cohesive and useful guide for a new contributor

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Fri Jul 10 15:37:16 2026
(Merged from https://github.com/openssl/openssl/pull/29295)
2026-07-10 11:37:03 -04:00
Bob Beck
d8e49b85d0 Add a STYLE.md file and link it from CONTRIBUTING.md
This is effectively, the current coding style policy web page
changed to accomodate clang-format.  This is more or less the
same file I have had in the various clang-format sample PR's since
September.

It does include an additional sections on Integers and on
Return Values that are not in the original coding style
policy

It is changed from the September version in that it does not
have mention of keeping include files self contained. I believe
that is achievable and desirable, but I think should be done
as a separate change from this.

There were a number of issues brought up in discussion of this
file in the clang-format PR's. I recorded those in 818, 819,
820, 821, 822, 823, 824, 825, and 826, which we can
link in there to the appropriate section of the document.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Fri Jul 10 15:37:13 2026
(Merged from https://github.com/openssl/openssl/pull/29295)
2026-07-10 11:37:03 -04:00
Jakub Zelenka
9b182491fc quic: fix intermittent idle-test failure in tserver test
The thread-assisted idle test advances fake time in 10ms steps while the
connection is kept alive solely by the background assist thread sending
keepalive PINGs. The test stepped fake time without checking that a due
keepalive had actually been sent, so whether it went out before the
server's idle deadline lapsed depended on thread scheduling - hence the
intermittent failure.

Now, before each step, check the event timeout (next_deadline minus
fake-now): while a keepalive is still due to be sent it stays at zero, so we
wake the assist thread and re-check without advancing until it goes positive
(or the existing real-time watchdog fires). Only then do we step fake time.

The negotiated 30s idle timeout and 60s idle duration are unchanged, so the
keepalive is still required and still tested; only the race is removed.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Fri Jul 10 15:33:45 2026
(Merged from https://github.com/openssl/openssl/pull/31746)
2026-07-10 17:33:40 +02:00
Tomas Mraz
1768a5a1be Avoid undefined behavior adding or subtracting two BN_zero() values
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul 10 14:54:48 2026
(Merged from https://github.com/openssl/openssl/pull/31916)
2026-07-10 16:54:46 +02:00
Igor Ustinov
68c0861075 Fix a bug in BN_ucmp() when comparing constant-time BIGNUMs of different lengths
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 12:08:43 2026
(Merged from https://github.com/openssl/openssl/pull/31717)
2026-07-10 08:08:36 -04:00
Mounir IDRASSI
09d12ef1d7 Allow MinGW-w64 builds to use BCryptGenRandom
MinGW-w64 has provided bcrypt headers and import libraries since
version 2.0, but OpenSSL only enabled the BCryptGenRandom seeding
path for supported MSVC builds. Enable the existing direct
BCryptGenRandom flow for MinGW-w64 when targeting Windows Vista or
newer, and link MinGW builds with bcrypt alongside the other Windows
import libraries.

Use __MINGW64_VERSION_MAJOR to detect MinGW-w64 because it is defined
by both the 32-bit and 64-bit MinGW-w64 toolchains.

Builds targeting older Windows versions keep the CryptoAPI fallback
because USE_BCRYPTGENRANDOM remains disabled when _WIN32_WINNT is
below 0x0600.

Fixes #13878

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 12:05:09 2026
(Merged from https://github.com/openssl/openssl/pull/13882)
2026-07-10 08:05:02 -04:00
Bob Beck
b72ee09a45 Drop missed unneded GNUC>=2 check
Spotted by idrassi on review. thanks!

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 11:47:21 2026
(Merged from https://github.com/openssl/openssl/pull/31677)
2026-07-10 07:47:13 -04:00
Bob Beck
aa2b1432b3 Simplify printf-attribute guards in bio.h.in and test/testutil/output.h.
Now that C99 is the base level, and we are no longer supporting old
GCC's, The ossl_bio__printf__ / ossl_test__printf__ indirection only existed
to pick the gnu_printf attribute over the printf attribute for MinGW's MS-CRT printf, but
MinGW is already excluded by the outer guard, so we can use the modern attribute
everywhere this code runs.

Spotted by idrassi on review, thanks!.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 11:47:19 2026
(Merged from https://github.com/openssl/openssl/pull/31677)
2026-07-10 07:47:13 -04:00
Bob Beck
a7241e862e We no longer need to test for GCC versions this old
The minimum gcc to compile our code appears to be version 9, and
we are now C99.

All these older checks become a tautology on anything that will
build a modern OpenSSL tree, so clean this up.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 11:47:17 2026
(Merged from https://github.com/openssl/openssl/pull/31677)
2026-07-10 07:47:13 -04:00
Bob Beck
e06fe98769 Drop Watcom C compiler support.
The only Watcom-specific code in the tree was a <tchar.h> _vsntprintf
mapping in crypto/cryptlib.c. There is no Watcom entry in Configurations/,
no CI job builds with Watcom, and the tree has had no other Watcom-aware
code in many years. The _vsntprintf symbol is supplied by <tchar.h>
on every supported Windows toolchain (MSVC, MinGW), so the conditional
fallback is dead.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 11:47:15 2026
(Merged from https://github.com/openssl/openssl/pull/31677)
2026-07-10 07:46:53 -04:00
Viktor Dukhovni
9d59af025a Improve TLS handling of EC point formats
Decouple the ec_point_formats extension from TLS 1.2 X.509
selection and acceptance.  Remove tls1_check_pkey_comp() and its
callers in tls1_check_cert_param() and tls1_check_chain(): TLS 1.3
disregards the extension already, and we can decode any point form
a peer might send, so refusing a compressed peer cert in TLS 1.2
because we didn't advertise compressed buys nothing.

The RFC 4492/8422 section 5.1.2 requirement that the peer's list
contain "uncompressed" used to be enforced in a final hook on the
client side only.  Move it to the two points where the negotiated
ciphersuite is known: the client's ServerHello parse hook, and the
server's ServerHello construct hook.  Both sites fire the alert
only when an ECC TLS 1.2 ciphersuite has been negotiated, so a
missing "uncompressed" is ignored under TLS 1.3 or a non-ECC
cipher.  The client- and server-side parse hooks now share one
function.

Drop the always-NULL ext.ecpointformats fields on SSL_CTX and SSL;
our own list is built directly inside the constructors.  The
peer's list continues to be stored verbatim, and is also exposed
through the SSL_get0_ec_point_formats() accessor (now documented).
New tests verify the four corners (ECC vs non-ECC ciphersuite, TLS
1.2 vs 1.3) plus that a compressed point form EC cert is usable on
both sides without any opt-in.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
MergeDate: Fri Jul 10 09:21:30 2026
(Merged from https://github.com/openssl/openssl/pull/30940)
2026-07-10 11:21:28 +02:00
Viktor Dukhovni
d172868e53 EC: make the group the single source of the point conversion form
The point conversion form (compressed, uncompressed, or hybrid)
was kept both on the key and on the group, and the two could
disagree -- a key imported as compressed could re-encode as
uncompressed. The group is now the single source of truth:
encoding, parameter output, and the legacy lookup all read it from
the group, and decoding (PEM, DER, or raw parameters) records it
there, so the form round-trips faithfully.

Generated keys are always uncompressed; the point-format option at
key generation is now a documented no-op (it had had no effect for
several releases), and the unused form field on the keygen context
is dropped.  Imported keys still keep their form, and the
deprecated EC_KEY_get_conv_form()/EC_KEY_set_conv_form() still
work.

EVP_PKEY_fromdata() and openssl pkey -text now report the form a
loaded EC key actually has, and re-encoding via PEM or DER
preserves it.

Docs drop a stale note about a compile-time macro for compressed
points on binary curves, and the EC tests now exercise both the
affine and the compressed/hybrid binary formats unconditionally
(fixing a latent bug in the compressed/hybrid form tests that were
never exercised by CI).

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
MergeDate: Fri Jul 10 09:21:29 2026
(Merged from https://github.com/openssl/openssl/pull/30940)
2026-07-10 11:21:28 +02:00
Jakub Zelenka
234845aaab Add BIO bio_sock2 test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:25 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
207c40c97a Add BIO bio_sock test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:24 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
bd07dda47d Add BIO bss_socket test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:22 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
b05333b7e9 Add BIO bss_dgram test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:21 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
b69282a759 Add BIO bss_acpt test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:20 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
90afdb14ed Add BIO bss_conn test
Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:19 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
bcbecdcaa5 Add BIO bio_addr test
Assisted-by: Claude:claude-opus-4-7

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:18 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
82ccc1747f Add BIO bss_fd test
Assisted-by: Claude:claude-opus-4-7

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:17 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
ac858acc91 Add mkwraps script for generting wraps and expectations
This is a helper script that can be used to provide a boilerplate code.

Assisted-by: Claude:claude-opus-4-7

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:15 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
acd7679800 Add unit testing cmocka based framework
This adds the unit testing framework that extends the build so it can
be enabled and tests are built. It is executed as part of the test
using a recipe which executes all unit tests.

The documentation is added with more info about writing the unit tests.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:14 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
bc79a23e6c Deprecate unit-test configure option and SSL_test_functions
The unit-test configure option exists only to expose the
SSL_test_functions() API allowing to overwrite ssl_init_wbio_buffer.
Instead of renaming it, deprecate the option and the SSL_test_functions()
function so both can be removed in OpenSSL 5.0.

Assisted-by: Claude:claude-fable-5

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:13 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Jakub Zelenka
6b6fc64711 Add WRAP build.info variable
This is used for adding per target --wrap ld flags for each listed
function.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jul  9 17:39:12 2026
(Merged from https://github.com/openssl/openssl/pull/30788)
2026-07-09 19:38:28 +02:00
Nikola Pajkovsky
38c7ace6c1 crypto/x509/x509_lu.c: check X509_OBJECT_up_ref_count() in x509_object_dup()
the return value of X509_OBJECT_up_ref_count() was ignored. If the
reference count increment fails, x509_object_dup() still returned a
duplicate X509_OBJECT whose ->data aliases the source X509/X509_CRL
without a reference actually having been taken. Freeing that duplicate
later drops a reference it never held, leading to a premature free and
use-after-free of the shared object.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  8 18:20:10 2026
(Merged from https://github.com/openssl/openssl/pull/31811)
2026-07-08 20:20:01 +02:00
Mounir IDRASSI
a4ee6965a0 Reject AES-XTS operations without an IV
Commit 774525b38b moved AES-XTS to an implementation-specific cipher
function but did not carry over the generic iv_set guard. This allowed
AES-XTS operations initialized with a NULL IV to proceed.

Restore the missing iv_set check before processing input and add an
evp_extra_test regression covering both a valid-IV control and the
missing-IV failure case.

Fixes #31755

Reviewed-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 18:16:55 2026
(Merged from https://github.com/openssl/openssl/pull/31756)
2026-07-08 20:16:06 +02:00
Billy Brumley
a17cd7691a [test] exercise AEAD tag read rejection when actually present during decryption
Set a verify tag while decrypting (which must succeed) before
attempting the read, so the test asserts that a tag cannot be read
back while decrypting even when one is _actually_ present.

This isolates direction logic from tag present logic.

Follow-up to #31734

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 18:06:40 2026
(Merged from https://github.com/openssl/openssl/pull/31826)
2026-07-08 20:06:30 +02:00
Dimitri Papadopoulos
0cb923d4ba Fix doubled semicolons as statement terminations
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 18:03:29 2026
(Merged from https://github.com/openssl/openssl/pull/31877)
2026-07-08 20:03:06 +02:00
Jakub Zelenka
ea902d80b3 apps: cover the unencrypted key bag path in the pkcs12 test recipe
The NID_keyBag branch of dump_certs_pkeys_bag() was not exercised.
Export a file with -keypbe NONE and dump it, checking the key bag is
reported and its private key is output.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul  8 18:02:22 2026
(Merged from https://github.com/openssl/openssl/pull/31665)
2026-07-08 20:02:18 +02:00
Matt Caswell
b24c43f9b8 Add regression test for remove_session_cb under lock
Install a remove_session_cb that calls SSL_CTX_flush_sessions_ex().
If the callback is invoked while ctx->lock is held, the nested
flush call deadlocks immediately.

The test covers the SSL_CTX_add_session() eviction path (adding a
second session to a size == 1 cache evicts the first, firing the
callback) and the SSL_CTX_flush_sessions_ex() path (SSL_CTX_free()
flushes the remaining session via flush_sessions_ex()).

Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 17:58:48 2026
(Merged from https://github.com/openssl/openssl/pull/31540)
2026-07-08 19:58:40 +02:00
Matt Caswell
4be956b9cd Fix remove_session_cb called while holding ctx->lock
SSL_CTX_add_session() held ctx->lock while calling remove_session_lock()
with lck = 0, which still fired the remove_session_cb callback.
SSL_CTX_flush_sessions_ex() had the same problem: it called
remove_session_cb for each expired session while holding the lock.
Any callback that re-entered an OpenSSL API requiring the same lock
would deadlock.

Refactor remove_session_lock() into remove_session_locked() (caller
holds the lock) which returns the removed SSL_SESSION * instead of
calling the callback and freeing it internally.

SSL_CTX_remove_session() manages its own locking and invokes the
callback unconditionally after releasing the lock (preserving the
existing behaviour where the callback fires even when the session is
not in the internal cache, to allow external caches to be notified).

SSL_CTX_add_session() collects evicted sessions in a temporary
singly-linked list (via the now-NULL next pointer) and processes them
after CRYPTO_THREAD_unlock().

SSL_CTX_flush_sessions_ex() already deferred SSL_SESSION_free() to
after the lock via a STACK_OF(SSL_SESSION). The callback is now also
deferred: sessions are collected on the stack under the lock, then
the lock is released before iterating the stack to fire callbacks
and free each session.

Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 17:58:47 2026
(Merged from https://github.com/openssl/openssl/pull/31540)
2026-07-08 19:58:40 +02:00
Urval
4d32206641 test: add all-alias BIGNUM coverage in file_sum
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 17:56:40 2026
(Merged from https://github.com/openssl/openssl/pull/30893)
2026-07-08 19:56:39 +02:00
Steven WdV
4e2e6f4174 Allow getentropy for Emscripten
Usually Emscripten emulates `/dev/urandom`, but in some cases,
like with `-sNODERAWFS`, it doesn't. This means that on non-Unix platforms,
where `/dev/urandom` does not exist on the host, OpenSSL will fail to seed
its PRNG. This fixes that by instead using the POSIX function it
implements, like which was already done for WASI.

See https://github.com/emscripten-core/emscripten/issues/9628#issuecomment-4892658766 for more context.

CLA: trivial

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul  8 17:50:39 2026
(Merged from https://github.com/openssl/openssl/pull/31882)

(cherry picked from commit dc219a0408)
2026-07-08 19:50:54 +02:00
Neil Horman
11889aa905 Suppress function pointer type validation in clang ubsan
We've been concerned about ubsan errors comming with more recent
versions of clang.  specifically versions of clang later than 17
generate hundreds of function pointer type validation errors, i.e.
assigning a function of type void (*)(TYPE *) to a function pointer of
type void (*)(void *).

Fixing these requires the creation of lots of thunk function that get
littered through the code base, and are generally unpleasant to carry.
A better fix requires siginficant code refactoring, and potentially
large changes to our ABI, which we can't support until the next major
release.

So, for now, just suppress those ubsan errors, so we can more properly
deal with the issue when we are able.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Wed Jul  8 16:01:12 2026
(Merged from https://github.com/openssl/openssl/pull/31837)
2026-07-08 12:01:04 -04:00
Jakub Zelenka
76e33ae38f property: replace property_memfail with in-tree mfail tests
The standalone property_memfail.c program is superseded by memory-failure
tests added directly to property_test.c using the MFAIL harness.  They
cover the same property store API surface under allocation failure
injection: ossl_method_store_new, ossl_method_store_add,
ossl_method_store_cache_set and the providerless ossl_method_store_cache_get
lookup, plus the method == NULL cache_set branch.

Unlike the old NO_CHECK-only program, the new tests run as checked mfail
tests, verifying both clean error propagation and the absence of reference
leaks on every failure path.  The old program also relied on a stale,
pre-lockless STORED_ALGORITHMS layout to poke the cache directly, which no
longer matches property.c.

Drop property_memfail.c along with its wiring in test/build.info and the
90-test_memfail.t recipe.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jul  8 13:05:16 2026
(Merged from https://github.com/openssl/openssl/pull/31880)
2026-07-08 15:05:01 +02:00
Tomas Mraz
801d701196 coveralls.yml: Disable the allocfail-tests
They are failing and thus the coveralls output is not produced.

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Wed Jul  8 12:20:03 2026
(Merged from https://github.com/openssl/openssl/pull/31878)
2026-07-08 14:19:57 +02:00
Mounir IDRASSI
f2924392d3 BIO_vprintf: fix off-by-one at 512-byte buffer boundary
BIO_vprintf() first formats into a 512-byte stack buffer. Since
vsnprintf() returns the required length excluding the NUL, a return
value of 512 means truncation. The old strict greater-than check
therefore wrote the truncated buffer for exactly 512-byte output.

Use >= for the realloc path and add boundary coverage for 511-, 512-
and 513-byte outputs.

Fixes: a29d157fdb "Replace homebrewed implementation of *printf*() functions with libc"

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 11:24:31 2026
(Merged from https://github.com/openssl/openssl/pull/31842)
2026-07-08 13:24:19 +02:00
Frederik Wedel-Heinen
d9671f4526 Remove unused source files poly1305_ieee754.c and poly1305_base2_44.c
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 11:16:22 2026
(Merged from https://github.com/openssl/openssl/pull/31737)
2026-07-08 13:15:52 +02:00
Milan Broz
f167d0d2e9 README.md: update web links to man pages
Add missing OpenSSL 4.0, remove EOL branches.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 11:09:16 2026
(Merged from https://github.com/openssl/openssl/pull/31839)
2026-07-08 13:08:35 +02:00
Orgad Shaneh
69cafbc498 util/mkinstallvars.pl: Suppress more debug logs
Commit aa4b47483f "Fix util/mkinstallvars.pl to treat LIBDIR
and libdir correctly" added more logs while bc44134c32 "Configure:
Remove extensive debug output by default" was under review, so those
were missed.

Complements: bc44134c32 "Configure: Remove extensive debug output by default"

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jul  8 11:03:11 2026
(Merged from https://github.com/openssl/openssl/pull/31843)
2026-07-08 12:57:18 +02:00
Dimitri Papadopoulos
1860496d86 Fix typos
Found by typos[1].

[1] https://github.com/crate-ci/typos

CLA: trivial

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:46:01 2026
(Merged from https://github.com/openssl/openssl/pull/31858)
2026-07-08 12:45:09 +02:00
Joe Orton
51584371a2 doc/man3/ASN1_INTEGER_get_int64.pod: fix a typo
CLA: trivial
Fixes: 6c5b6cb035 "ASN1 INTEGER refactor."

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:18:11 2026
(Merged from https://github.com/openssl/openssl/pull/31815)
2026-07-08 12:17:43 +02:00
Dimitri Papadopoulos
917ebfca5c Eliminate unnecessary whitespace before a quoted newline
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:22 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:10:54 +02:00
Dimitri Papadopoulos
cddeed0734 Move const qualifier after static
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:20 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:10:36 +02:00
Dimitri Papadopoulos
7812b20ad5 Add parentheses around sizeof arguments
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:18 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:10:14 +02:00
Dimitri Papadopoulos
74e781dfec Eliminate unnecessary type casts of int constants
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:16 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:09:47 +02:00
Dimitri Papadopoulos
ae6de18171 Eliminate repeated semicolons at the end of statements
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:15 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:09:16 +02:00
Dimitri Papadopoulos
518d66e44d Remove parentheses around return arguments
Since return is an operator and not a function, parentheses
are not required.

Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:13 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:08:25 +02:00
Dimitri Papadopoulos
df5f836f64 Eliminate/fix repeated word usage
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 10:11:11 2026
(Merged from https://github.com/openssl/openssl/pull/31860)
2026-07-08 12:07:53 +02:00
olszomal
8c7e3f217c apps/ocsp.c: guard index_changed() with OPENSSL_NO_POSIX_IO, not HTTP_DAEMON
Replace #ifdef HTTP_DAEMON with #ifndef OPENSSL_NO_POSIX_IO for code
that only requires POSIX {,f}stat(), improving portability.

Retain syslog() call only when HTTP_DAEMON is defined, use
BIO_printf(bio_err) otherwise.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 09:47:43 2026
(Merged from https://github.com/openssl/openssl/pull/28172)
2026-07-08 11:42:37 +02:00
olszomal
d2a9af2144 apps: adjust stat usage to account for uplink
Call stat() instead of fstat() when the FILE pointer provided
by BIO_get_fp() is unavailable (as it may be the case in case of UPLINK
builds).

Signed-off-by: olszomal <Malgorzata.Olszowka@stunnel.org>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 09:47:42 2026
(Merged from https://github.com/openssl/openssl/pull/28172)
2026-07-08 11:28:33 +02:00
olszomal
b5b34d32cb BIO: avoid returning internal FILE * with UPLINK-enabled builds on Windows
On Windows with UPLINK enabled, BIO_get_fp() may return a FILE * pointer
incompatible with the C runtime.  Ensure that it returns NULL instead,
preventing undefined behavior in applications.  Update the documentation
to include the missing return type for BIO_[gs]et_fp() and remove
the mention that BIO_get_fp() never returns 0, as it does so now
when NULL fp is returned.

Signed-off-by: olszomal <Malgorzata.Olszowka@stunnel.org>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 09:47:40 2026
(Merged from https://github.com/openssl/openssl/pull/28172)
2026-07-08 11:28:03 +02:00
Ingo Franzki
a21fdfc89a Fix crash in EVP_MD_CTX_copy_ex on inconsistent context
EVP_MD_CTX_copy_ex() might crash on an NULL pointer access when an
inconsistent context is copied. This happens when a context is copied
where digest is set but algctx is NULL, i.e. due to an incomplete
initialization.

The copyctx shortcut for cases where the in and out contexts use the
exact same digest call the copyctx function attempting to copy
the algctx, but it does not check if algctx is NULL on the in or out
contexts.

Fix this by only taking the copyctx shortcut if algctx is non-NULL on
both, in and out. Otherwise use the full copy path which will only
duplicate the algctx if it is non-NULL.

Closes: https://github.com/openssl/openssl/issues/31831

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/31867)
2026-07-08 14:17:31 +10:00
Jakub Zelenka
46040a2988 quic: do not hard fail mfail test for old fips providers
This is because ML-KEM change from #31432 is not backported there.

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Jul  7 16:36:07 2026
(Merged from https://github.com/openssl/openssl/pull/31870)
2026-07-07 12:36:02 -04:00
Nikola Pajkovsky
64f09bd826 crypto/x509/x509_lu.c: fix memory leak in obj_ht_foreach_object()
when sk_X509_OBJECT_push() fails after x509_object_dup() has already
allocated the duplicate, the dup is neither stored on the destination
stack nor freed: the error path only pop_free()s the stack the dup was
never pushed onto, so it is leaked.

Set env ASAN_OPTIONS in test explicitly to detect_leaks=1 to force
ASAN to fail the test. Otherwise, the test reports ok even with valid
leak.

Fixes: 08cecb4448 "Add X509_STORE_get1_objects"
Fixes: https://github.com/openssl/openssl/issues/31771
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jul  7 07:42:17 2026
(Merged from https://github.com/openssl/openssl/pull/31784)
2026-07-07 09:41:59 +02:00
Neil Horman
a89400969d Fix new statem_clnt_test when dtls is disabled
The new statem client tests added in comimt c36a9b4 assume that if
OPENSSL_NO_DTLS is not defined, that we have DTLS support, but we have
this odd setup in which we can have DTLS enabled, but DTLS1_2 disabled,
in which case the needed support isn't present, and the test fails.

why we have it setup that way, I'm not sure, but we should only run the
dtls tests if both DTLS and DTLS1_2 support is available.

Fixes #31851

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
MergeDate: Mon Jul  6 09:42:44 2026
(Merged from https://github.com/openssl/openssl/pull/31582)
2026-07-06 10:42:17 +01:00
Jakub Zelenka
f31510e953 quic: add mfail test for handshake multi-packet processing
This tests handshake level phase using mfail covering SSL_do_handshake.
It is a test for #31323.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sat Jul  4 16:57:38 2026
(Merged from https://github.com/openssl/openssl/pull/31324)
2026-07-04 12:57:13 -04:00
Mounir IDRASSI
c65777dd3c Add stack test for thunked sorted lookup
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sat Jul  4 16:53:24 2026
(Merged from https://github.com/openssl/openssl/pull/30857)
2026-07-04 12:53:19 -04:00
Neil Horman
562d2a137a Remove CRYPTO_GET_REF
This function should never have existed.  Its a TOCTOU waiting to
happen.  Now that we've eliminated all internal uses, and given that its
an internal function, send it to a nice farm upstate, where it can run
and play with all the other functions that shouldn't have been.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Sat Jul  4 16:47:16 2026
(Merged from https://github.com/openssl/openssl/pull/31750)
2026-07-04 12:47:07 -04:00
Neil Horman
16be8273ad Replace use of CRYPTO_GET_REF in bio_lib
BIO_free_all makes use of CRYPTO_GET_REF to determine if there is
another user of a BIO chain at some artibrary point within the chain.

But CRYPTO_GET_REF is begging for a TOCTOU error, and so we're
deprecating it.

replace the use of GET_REF with an internal version of BIO_free that
returns the value of the resultant ref count, and use that instead, so
we are TOCTOU free

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Sat Jul  4 16:47:13 2026
(Merged from https://github.com/openssl/openssl/pull/31750)
2026-07-04 12:47:07 -04:00
Neil Horman
70fa179635 eliminate use of CRYPTO_GET_REF in sslapitest
CRYPTO_GET_REF is almost by definition a TOCTOU race, and we shouldn't
use it.

As part of the effort to deprecate it, eliminate its use from
sslapitest.

Avoid the use-after-free possibility by getting a session with
SSL_get1_session (which increments the refcount) and freeing it after
we're done with it.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Sat Jul  4 16:47:10 2026
(Merged from https://github.com/openssl/openssl/pull/31750)
2026-07-04 12:47:07 -04:00
Jakub Zelenka
f908737d58 apps: cover x509 DER key/cert input formats
The -keyform, -CAform and -CAkeyform options were not covered. Add a
test that self-signs a CSR with a DER-encoded key and signs a CSR with
a DER-encoded CA cert and CA key.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Fri Jul  3 19:40:27 2026
(Merged from https://github.com/openssl/openssl/pull/31733)
2026-07-03 21:40:22 +02:00
Jakub Zelenka
7e2879e035 apps: test dsa app PVK output
Cover the previously untested PVK code paths of the dsa app: round-trip
the test key through the PVK encoding (mirroring the existing rsa PVK
test, and skipped unless rc4, legacy and pvkkdf are enabled), and check
that requesting PVK output for a public key input is rejected.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Fri Jul  3 19:30:48 2026
(Merged from https://github.com/openssl/openssl/pull/31801)
2026-07-03 21:30:41 +02:00
Frederik Wedel-Heinen
3cd2f29124 Removes two unused macros: MAX_RESEED_INTERVAL and MAX_RESEED_TIME_INTERVAL.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul  3 19:29:48 2026
(Merged from https://github.com/openssl/openssl/pull/31745)
2026-07-03 21:29:45 +02:00
Frederik Wedel-Heinen
be16738154 Remove internal-only DRBG_STATUS enum
Changed internal prov_drbg_st member variable from DRBG_STATUS
to int to reflect how it was actually used.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Fri Jul  3 19:29:47 2026
(Merged from https://github.com/openssl/openssl/pull/31745)
2026-07-03 21:28:43 +02:00
Jakub Zelenka
dd943486d7 apps: cover crl signature verification
The CRL signature verification path was not exercised. Add a test that
verifies a CRL signature against its issuer certificate supplied via
-CAfile, -CAstore and -CApath.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Fri Jul  3 19:26:15 2026
(Merged from https://github.com/openssl/openssl/pull/31736)
2026-07-03 21:26:10 +02:00
Jakub Zelenka
c30329c854 apps: cover the req -set_serial option
The OPT_SET_SERIAL case in req_main() was not covered. Add a test that
generates a self-signed certificate with an explicit -set_serial value
and checks it, plus the error path when -set_serial is given twice.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Fri Jul  3 19:25:05 2026
(Merged from https://github.com/openssl/openssl/pull/31730)
2026-07-03 21:24:58 +02:00
Jakub Zelenka
4b873a1d21 x509: add delta CRL success test
Exercise the previously uncovered X509_V_FLAG_USE_DELTAS path in
get_delta_sk(): a current delta CRL revoking kLeaf must be honored.
The base and delta CRLs are generated by `ossl-test-tools crltest delta`.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jul  3 19:22:29 2026
(Merged from https://github.com/openssl/openssl/pull/31714)
2026-07-03 21:22:21 +02:00
Jakub Zelenka
a8db32eed7 apps: cover the CRL printing path in the pkcs7 test recipe
The crls != NULL block of pkcs7 -print_certs was not exercised.  Build
a PKCS#7 structure containing a CRL with crl2pkcs7 and check the CRL is
both printed and output in PEM form.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
MergeDate: Fri Jul  3 19:21:11 2026
(Merged from https://github.com/openssl/openssl/pull/31666)
2026-07-03 21:21:04 +02:00
Niels Provos
e59165a1e3 crypto/x509: replace O(N^2) RFC 3779 canonicalisation merge with linear sweep
ASIdentifierChoice_canonize and IPAddressOrRanges_canonize previously
merged adjacent entries with an in-place loop that called
sk_..._delete() after each merge, making the merge O(N^2) due to the
per-merge stack shift.

Replace the merge with a single linear sweep using a write index
distinct from the read cursor: mergeable entries fold into the
previous output's upper bound in O(1), non-mergeable entries are slid
forward into the write slot, and the source slot is set to NULL so the
ASN.1 free machinery cannot double-free on a subsequent abort.
Canonicalisation is now O(N log N) overall, bounded by the existing
sort.

Mixed-state-on-error safety is provided by the caller's normal
teardown path: OPENSSL_sk_pop unlinks without freeing, OPENSSL_sk_set
replaces without freeing the displaced value, and
ossl_asn1_item_embed_free no-ops on NULL slots, so returning early on
an inner failure leaves the stack in a state that the choice's normal
free path handles cleanly.

New regression tests in test/v3ext.c at N=8192 cover the all-merge,
no-merge, interleaved (slide-forward), range-merge,
overlap-mid-sweep, and inverted-range-mid-sweep paths; the
mixed-state teardown invariant is exercised under ASan + UBSan.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Fri Jul  3 19:20:01 2026
(Merged from https://github.com/openssl/openssl/pull/31147)
2026-07-03 21:19:51 +02:00
Jakub Zelenka
ff6b868ddd ci: run full cross-compile tests on PRs with 'extended tests' label
Previously the cross-compile workflow only ran the EVP tests on pull
requests, with the full test suite done only for push events.  Allow the
full suite to run on a pull request when it has the 'extended tests'
label which is already used for extended tests.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Fri Jul  3 14:39:38 2026
(Merged from https://github.com/openssl/openssl/pull/31705)
2026-07-03 16:39:32 +02:00
Neil Horman
cf82f5f78f Add test to exercise non-caching code paths
Use openssl list, which uses EVP_*_do_all_provided on non-caching
algorithms.  The do_all_provided path callbacks expect the algorithms
that are looked up to be saveable via up_ref, so this, when run under
asan, makes for a good test to ensure we don't trigger any use after
free situations when not caching algs.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jul  2 14:24:17 2026
(Merged from https://github.com/openssl/openssl/pull/31782)
2026-07-02 10:24:10 -04:00
Neil Horman
a66d74c8c1 add support to p_ossltest for non-cacheable fetches
Add the ability to direct p_ossltest to request no caching so that we
can test the provider driver non-cache code path.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jul  2 14:24:15 2026
(Merged from https://github.com/openssl/openssl/pull/31782)
2026-07-02 10:24:10 -04:00
Neil Horman
8c8a80b00b Extend refcounting on evp objects to provider requesed no-caching
We recently removed reference counting for EVP objects, but kept the
refcounting when we build with no-cached-fetch.

There is a corner case in which providers in builds that do caching may
still request non-caching by setting *no_cache = 1 in their query
operations.

OQS tripped over this here:
https://github.com/open-quantum-safe/oqs-provider/pull/787

When a provider requests no caching, we need to treat those algorithms
as though we are running in a no-cached-fetch build and still do ref
counting on them.

Teach our algorithms implementation to understand when a provider is
requesting non-caching, mark them as such and ref count only those.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jul  2 14:24:13 2026
(Merged from https://github.com/openssl/openssl/pull/31782)
2026-07-02 10:24:10 -04:00
Evy Garden
a3b7e09114 Add -n option to openssl-rand to not output the trailing newline
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Thu Jul  2 10:59:26 2026
(Merged from https://github.com/openssl/openssl/pull/31795)
2026-07-02 12:59:24 +02:00
Eugene Syromiatnikov
7c9b263005 crypto/pem/pem_info.c: avoid switching on PEM_INFO_NONE
Coverity complains that the switch statements in PEM_X509_INFO_read_bio_ex()
switches on PEM_INFO_NONE, while the enclosing condition
(itype != PEM_INFO_NONE) explicitly rules it out.  Pacify it by changing
the switch case to default (not removing it to avoid triggering
-Werror=switch).

Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1695453
Complements: 0e8f2844ed "fix function pointer type mismatch in PEM_X509_INFO_read_bio_ex"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jul  2 07:26:24 2026
(Merged from https://github.com/openssl/openssl/pull/31792)
2026-07-02 09:26:18 +02:00
Eugene Syromiatnikov
862844ddf9 fuzz/provider.c: check evp##_up_ref return value in collect_##evp
Coverity has reported an unchecked result of an evp##_up_ref call
that is checked elsewhere.  Rewrite the collect routine to try to do
the up_ref first, and then call free if push doesn't succeed.

Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1695451
Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1695454
Fixes: f3b988dc29 "Add provider fuzzer"

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jul  2 07:26:22 2026
(Merged from https://github.com/openssl/openssl/pull/31792)
2026-07-02 09:26:18 +02:00
Eugene Syromiatnikov
a5b0c2ef9a test/evp_kdf_test.c: add checks or EVP_KDF_CTX_{,get0_,get1_}kdf()
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jul  2 07:24:24 2026
(Merged from https://github.com/openssl/openssl/pull/28954)
2026-07-02 09:24:15 +02:00
Leon Timmermans
b71c5cfeda Add EVP_KDF_CTX_get0_kdf and EVP_KDF_CTX_get1_kdf, deprecate EVP_KDF_CTX_kdf
Resolves: https://github.com/openssl/openssl/issues/28327

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jul  2 07:24:22 2026
(Merged from https://github.com/openssl/openssl/pull/28954)
2026-07-02 09:24:15 +02:00
Jakub Zelenka
7520345190 quic: add mfail test for a read with key update
This adds test for #31268 with using SSL_read for QUIC client and
forcing key update.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
MergeDate: Thu Jul  2 07:21:14 2026
(Merged from https://github.com/openssl/openssl/pull/31272)
2026-07-02 09:21:08 +02:00
Neil Horman
8a072a3dab use evp_asym_cipher_free in evp_asym_cipher_from_algorithm
evp_asym_cipher_from_algorithm, in its error path frees the allocated
cipher with EVP_ASM_CIPHER_free, but thats a no-op now, and we actually want to
free it to avoid leaks, so we should use evp_asym_cipher_free (the internal
function that acutally does free the alg) instead.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695449

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 15:32:25 2026
(Merged from https://github.com/openssl/openssl/pull/31748)
2026-07-01 11:32:12 -04:00
Neil Horman
4d50403e51 use evp_signature_free in evp_signature_from_algorithm
evp_signature_from_algorithm, in its error path frees the allocated sig
with EVP_SIGNATURE_free, but thats a no-op now, and we actually want to
free it to avoid leaks, so we should use evp_signature_free (the internal
function that acutally does free the alg) instead.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695450

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 15:32:23 2026
(Merged from https://github.com/openssl/openssl/pull/31748)
2026-07-01 11:32:12 -04:00
Neil Horman
4c48ed7319 use evp_keymgmt_free in keymgmt_from_algorithm
keymgmt_from_algorithm, in its error path frees the allocated keymgmt
with EVP_KEYMGMT_free, but thats a no-op now, and we actually want to
free it to avoid leaks, so we should use evp_keymgmt_free (the internal
function that acutally does free the alg) instead.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695452

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 15:32:21 2026
(Merged from https://github.com/openssl/openssl/pull/31748)
2026-07-01 11:32:12 -04:00
Neil Horman
e4551d81c3 use evp_keyexch_free in evp_keyexch_from_algorithm
evp_keyexch_from_algorithm, in its error path frees the allocated kem
with EVP_KEM_free, but thats a no-op now, and we actually want to
free it to avoid leaks, so we should use evp_keyexch_free (the internal
function that acutally does free the alg) instead.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695455

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 15:32:18 2026
(Merged from https://github.com/openssl/openssl/pull/31748)
2026-07-01 11:30:51 -04:00
Neil Horman
8225d82f04 use evp_kem_free in evp_kem_from_algorithm
evp_kem_from_algorithm, in its error path frees the allocated kem
with EVP_KEM_free, but thats a no-op now, and we actually want to
free it to avoid leaks, so we should use evp_kem_free (the internal
function that acutally does free the alg) instead.

Fixes https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1695456

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 15:32:16 2026
(Merged from https://github.com/openssl/openssl/pull/31748)
2026-07-01 11:30:51 -04:00
Michał Trojnara
5d61a36a94 s_client: skip TCP shutdown drain for datagram protocols
The shutdown-side drain uses a TCP half-close and a fixed 500 ms
select() timeout to let peers consume buffered alerts before close.
Running it for DTLS/QUIC datagram connections causes an unnecessary
delay after the connection has otherwise completed.

Limit this workaround to non-DTLS, non-QUIC connections.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  1 13:35:53 2026
(Merged from https://github.com/openssl/openssl/pull/31558)
2026-07-01 15:35:10 +02:00
Mounir IDRASSI
2229aad774 apps/s_server.c: fix SSL object leak on rpk_enable() failure
In www_body() and rev_body(), con = SSL_new(ctx) is called before
rpk_enable(con), but ownership of con is transferred to ssl_bio only
later by BIO_set_ssl(..., BIO_CLOSE). If rpk_enable() fails, the code
jumps to err: before that transfer without freeing con, leaking the SSL
object.

Add SSL_free(con) before goto err in both rpk_enable() failure paths,
matching the adjacent SSL_set_session_id_context() and BIO_new_socket()
error paths. sv_body() is unaffected because its err: block already
frees con.

The global rpk_files is not leaked. Its lifetime is managed
by s_server_main(), which frees it in the end cleanup block.

Resolves: https://github.com/openssl/openssl/issues/31769

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  1 12:04:13 2026
(Merged from https://github.com/openssl/openssl/pull/31789)
2026-07-01 14:03:34 +02:00
Mounir IDRASSI
10c0927bb3 Suppress MSVC C4996 in applink.c
applink.c deliberately stores legacy CRT function pointers because
ms/uplink.h expects the old fopen and _open signatures. Keep the
table entries unchanged and suppress MSVC warning C4996 locally
around OPENSSL_Applink() instead of switching to fopen_s or
_sopen_s.

Fixes #8241

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  1 09:17:39 2026
(Merged from https://github.com/openssl/openssl/pull/31765)
2026-07-01 11:17:36 +02:00
Milan Broz
8a57600f23 Use more recent default for _WIN32_WINNT
After the windows.h include optimization introduced in
commit 1eaf29ef6c, the _WIN32_WINNT default was changed, causing
performance regressions.

Currently, _WIN32_WINNT is defined as 0x0501, which means WinXP.

This causes the code to be compiled with WinXP-compatible code, notably
 - without USE_RWLOCK
 - using legacy thread implementation
 - legacy RNG seeding (no BCryptGenRandom)

This patch increases the requirement to 0x600 (Windows Vista).

Note that code running on WinXP cannot currently be compiled with
any default configuration, as supported compilers generate executables
for Windows Vista and above.

If we provide some way to support WinXP, it can be done by
redefining _WIN32_WINNT.

Resolves: https://github.com/openssl/project/issues/2010
Fixes: 1eaf29ef6c "Remove direct includes of windows.h where possible"

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 09:14:18 2026
(Merged from https://github.com/openssl/openssl/pull/31774)
2026-07-01 11:14:10 +02:00
Milan Broz
635ffe8bb9 Fix use of BCryptGenRandom
Current path for Windows RNG (for Vista and above) should
use BCryptGenRandom() function but the symbol is not included
in platform_symbols.

The issue was hidden before commit 1eaf29ef6c reordered
Windows header inclusion.

Moreover, a cast to ULONG is required for strict warnings build.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Wed Jul  1 09:14:17 2026
(Merged from https://github.com/openssl/openssl/pull/31774)
2026-07-01 11:14:10 +02:00
Ingo Franzki
e9351bcce6 s390x: Fix AES-XTS hardware acceleration in IBM z17
For the re-init case where only the IV is specified, but no key, the 'nap'
field must also be initialized.

Instead of setting the s390 specific fields in a special case block, call
ctx->hw->init() also in this case. It performs the necessary setup already
(when the KM function code was once set already).

Adjust the cipher_hw_aes_xts_s390x_initkey() function so that it can also
be called with a NULL key. It then only performs the IV setup as well as
setting up the 'nap'.

Closes: https://github.com/openssl/openssl/issues/31766
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Wed Jul  1 09:12:26 2026
(Merged from https://github.com/openssl/openssl/pull/31775)
2026-07-01 11:12:22 +02:00
Pauli
1be08a7791 demo: fix fips-version Makefile so it loads the FIPS provider correctly
Fixes #31760

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/31762)
2026-07-01 17:36:27 +10:00
Ingo Franzki
f0ca416976 s390x: Fix return code handling in HMAC_Init_ex()
When running on the s390x platform HMAC_Init_ex() calls s390x_HMAC_init()
to optionally allow hardware acceleration of the HMAC operation. In case
the hardware acceleration is not available, s390x_HMAC_init() returns -1
to indicate that. In this case the software path is continued.

The problem is that rv was set to -1 by s390x_HMAC_init() and stays at
this until the end of the function. In case the software path detects an
error it goes to the 'err' label which just returns rv as is, and thus
HMAC_Init_ex() now returns -1 instead of 0 (rv was initialized to 0 at
declaration).

The wrong return value might then be propagated through all layers, i.e.
to EVP_MAC_init() which also returns -1 in this case. However, EVP_MAC_init()
is defined as returning 1 on success, or 0 on error, i.e. a boolean kind of
return value.

Typically, callers will do something like 'if (!EVP_MAC_init(s....))' to
check for errors. A return value of -1 is non-zero, and thus it is treated
as successful return.

Fix this by setting rv back to 0 when s390x_HMAC_init() returned -1.

Fixes: 0499de5add "s390x: Add hardware acceleration for HMAC"
Resolves: https://github.com/openssl/openssl/issues/31706
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Tue Jun 30 20:49:52 2026
(Merged from https://github.com/openssl/openssl/pull/31723)
2026-06-30 22:48:43 +02:00
Frederik Wedel-Heinen
4402bc95fa Removes some stale SSLv3 support around the code and updated documentation to reflect removal.
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 11:04:18 2026
(Merged from https://github.com/openssl/openssl/pull/30824)
2026-06-30 13:04:17 +02:00
Bob Beck
ed25946495 Clean up the cpu id stuff by hoisting the append into a helper
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 11:02:52 2026
(Merged from https://github.com/openssl/openssl/pull/31646)
2026-06-30 13:02:49 +02:00
Jakub Zelenka
c5ae170e85 property: add cache provider-order regression test
When two providers cache the same nid and property query, the first one
to do so must own the providerless cache entry, so that a NULL-provider
lookup keeps resolving to that provider. This covers commit 9d476175d7.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Tue Jun 30 11:01:57 2026
(Merged from https://github.com/openssl/openssl/pull/31738)
2026-06-30 13:01:49 +02:00
Daniel Kubec
a06203b3cb TEST: Add DTLS 1.2 coverage for Session ID verification
The DTLS 1.2 tests exercise the same verification logic and confirm that the
behavior matches the TLS 1.2 implementation. The tests pass as expected and
provide additional coverage for DTLS 1.2 without requiring any functional
changes.

Fixes #31250

Reviewed-by: Igor Ustinov <igus@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jun 30 11:00:55 2026
(Merged from https://github.com/openssl/openssl/pull/31389)
2026-06-30 13:00:49 +02:00
Bob Beck
5a55913f10 Don't attempt to check the security level on what signed our own certificate.
What matters to us is that the key *we* are using matches our desired
security level, as we may sign things with that key. As far as who
signed us, this could be signed by something we don't recognize at all,
and it is up to the peer to decide if the thing signing us matters to
it (i.e. if it recognizes the algorithm, decides it's strong enough,
or it even verifies the signature, as it might already trusts our key
due to pinning, TOFU, Prayer and Clean Living, or whatever.)

Obviously, we still check the security level on any signatures *we*
recieve to verify *from* a peer.

Fixes: https://github.com/openssl/openssl/issues/31195

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 10:47:09 2026
(Merged from https://github.com/openssl/openssl/pull/31271)
2026-06-30 12:47:06 +02:00
Bob Beck
c25e1c4b78 SSL_OP_SECOP is dead code
Nothing set the "vfy" parameters in any of these functions to anything but 0.

Remove the parameter and stage things related to SSL_OP_SECOP to go away in the
future.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 10:47:07 2026
(Merged from https://github.com/openssl/openssl/pull/31271)
2026-06-30 12:47:03 +02:00
Bob Beck
bca4e46568 Clarify the comment in asn1.h.in for ASN1_VALUE
I've been down this road a few times and nhorman@ just hit it.

While technically true, most of our opaque pointers have internal
defninitions. Stop people going down the garden path by explaining
what this is

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 09:51:37 2026
(Merged from https://github.com/openssl/openssl/pull/31708)
2026-06-30 11:51:30 +02:00
Jakub Zelenka
f9dff99361 apps: cover the smime multiple -signer parsing path
The signerfile != NULL block in smime_main(), reached when more than one
-signer is given (including the case where a preceding -inkey leaves
keyfile != NULL), was not exercised: the existing multi-signer tests run
through the cms command, and the smime app was only ever run with a
single signer.  Add a two-signer test, with an explicit -inkey, to the
pkcs7 test set so it runs through smime when signing.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Tue Jun 30 08:57:47 2026
(Merged from https://github.com/openssl/openssl/pull/31675)
2026-06-30 10:57:34 +02:00
Jakub Zelenka
801c432b18 quic: add mfail test for RCIDM
This tests memory failures in remote connection ID manager code.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Tue Jun 30 08:56:45 2026
(Merged from https://github.com/openssl/openssl/pull/31602)
2026-06-30 10:56:41 +02:00
Jakub Zelenka
1a80366668 quic: add mfail test for multi-packet RXE
Add a record layer test that executes qrx_process_pkt() under mfail
on a freshly created qrx whose rx_free freelist is empty. This
deterministically lands the qrx_ensure_free_rxe() call for the first
packet of a multi-packet datagram among the enumerated injection points
which is the precondition for triggering assert failure in
qrx_validate_hdr_early(). The test reuses rx_script_5's coalesced
Initial+Handshake+1-RTT datagram and only provides the Initial secret,
since the bug fires before any decryption is attempted.

Assisted-by: Claude:claude-opus-4-7

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Tue Jun 30 08:56:00 2026
(Merged from https://github.com/openssl/openssl/pull/31331)
2026-06-30 10:55:57 +02:00
Jakub Zelenka
c36a9b463e statem: add direct tests for tls_construct_client_hello
Add a new test which calls tls_construct_client_hello() directly,
creating an SSL_CONNECTION enough to invoke the construct function
without making a full handshake, then verifies the produced
ClientHello structurally and by round-tripping it through the
server-side tls_process_client_hello().

The covered branches include TLS 1.3 (with and without middlebox
compat), TLS 1.2, DTLS, session resumption, HelloRetryRequest, the DTLS
cookie and client_random reuse paths, the deterministic error branches
(WPACKET overflow and no usable ciphers), and the ECH wrapper path
(happy path with server-side decryption, the TLS 1.2 version error, and
OOM). Out-of-memory branches are exercised with the mfail tests.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Tue Jun 30 08:54:48 2026
(Merged from https://github.com/openssl/openssl/pull/31618)
2026-06-30 10:54:38 +02:00
Jakub Zelenka
7d4475bdf2 statem: fail handshake if there is memory failure in negotiate_dhe
Previously this just resulted in the skip of the group but such failure
should result in a proper error. This is not a big issue but it impacts
mfail tests so it would be good to fail.

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Tue Jun 30 08:54:47 2026
(Merged from https://github.com/openssl/openssl/pull/31618)
2026-06-30 10:54:38 +02:00
Neil Horman
f5a5e89044 ensure writes are syncronized on windows in CRYPTO_THREAD_run_once
We've tried to fix this properly using InitOnceExecuteOnce, but it
results in an ABI breakage, so we're doing it this way.

on windows, CRYPTO_THREAD_run_once, on weakly memory ordered systems,
may complete the write of the run once variable lock before some of the
writes made by the init callback routine complete.  The result is that
on a heavily multithreaded application, other therads may see the data
that was meant to be in an initalized state, as in some erroneous
in-between state, leading to errors.

Fix it by inserting a full memory barrier after we return from the init
callback, and prior to setting the run once variable to ONCE_DONE.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 08:51:16 2026
(Merged from https://github.com/openssl/openssl/pull/31713)
2026-06-30 10:51:14 +02:00
Mounir IDRASSI
b06d2b2c92 test: run RIO notifier smoke test everywhere
The RIO notifier smoke test is currently limited to
Windows targets in both the build metadata and the
test recipe.
The test exercises the notifier abstraction and can
run on other platforms as well, so this removes the
Windows-only guards.

The test remains conditional on QUIC being enabled.

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Tue Jun 30 08:49:54 2026
(Merged from https://github.com/openssl/openssl/pull/31494)
2026-06-30 10:49:50 +02:00
Andrew Dinh
e6220f6e31 Fix OP_READ_FAIL_WAIT macro definition
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:52 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Andrew Dinh
7f2003289a Port script_9
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:51 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Andrew Dinh
783baebb17 Port script_8
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:50 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Andrew Dinh
0f41f011f8 Port script_7
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:48 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Andrew Dinh
1ca326f0e7 Port script_6
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:47 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Andrew Dinh
6bb3799400 Port script_5
Also fixes a bug in the OP_STREAM_RESET macro

Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 30 07:54:46 2026
(Merged from https://github.com/openssl/openssl/pull/31707)
2026-06-30 09:54:33 +02:00
Billy Brumley
ea655177e0 [test] check tag abuse for AEAD ciphers
With AEAD ciphers, a tag is an input for decryption (the value to verify)
and an output of encryption (the generated value). Therefore:
- supplying a tag value while encrypting must fail
- reading a tag while decrypting must fail
- error codes should be consistent across all AEADs

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Tue Jun 30 07:47:03 2026
(Merged from https://github.com/openssl/openssl/pull/31734)
2026-06-30 09:47:01 +02:00
Pauli
b00f7b6c30 demo: add program that shows how to query the FIPS provider version
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Simo Sorce <simo@redhat.com>
(Merged from https://github.com/openssl/openssl/pull/31654)
2026-06-29 08:03:09 +10:00
Nikola Pajkovsky
f32f8682ea providers/fips/fipsprov.c, test/p_test.c: remove c_gettable_params static global
c_gettable_params is never read anywhere in the files;  it was dead
storage.  Remove it.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 28 17:51:55 2026
(Merged from https://github.com/openssl/openssl/pull/31508)
2026-06-28 19:50:37 +02:00
Nikola Pajkovsky
f3447c3bc2 providers/baseprov.c: remove static globals
c_gettable_params is never read anywhere in the file;  it was dead
storage.  c_get_params is only consumed once, inside the same call
to ossl_default_provider_init(), to seed the provider context
via ossl_prov_ctx_set0_core_get_params().  It can therefore be a local
variable rather than file-scope state.

Drop the unused c_gettable_params static together with its dispatch
case, and scope c_get_params inside the init function.  The behavior
of the base provider is unchanged for single-threaded callers;
the concurrent-load race goes away because the shared mutable state
is gone.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 28 17:51:54 2026
(Merged from https://github.com/openssl/openssl/pull/31508)
2026-06-28 19:49:47 +02:00
Matt Van Horn
57f4bd9ab8 providers/defltprov.c: remove static globals from provider_init
The default provider stored two function pointers from the core
dispatch table (c_gettable_params, c_get_params) in file-scope statics,
written by ossl_default_provider_init() without any synchronization.
When OSSL_PROVIDER_load() is invoked from multiple threads concurrently,
TSAN reports a data race on both writes[1].

c_gettable_params is never read anywhere in the file; it was dead
storage.  c_get_params is only consumed once, inside the same call
to ossl_default_provider_init(), to seed the provider context
via ossl_prov_ctx_set0_core_get_params().  It can therefore be a local
variable rather than file-scope state.

Drop the unused c_gettable_params static together with its dispatch
case, and scope c_get_params inside the init function.  The behavior
of the default provider is unchanged for single-threaded callers;
the concurrent-load race goes away because the shared mutable state
is gone.

[1] https://github.com/openssl/openssl/issues/28935

CLA: trivial
Resolves: https://github.com/openssl/openssl/issues/28935

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 28 17:51:52 2026
(Merged from https://github.com/openssl/openssl/pull/31508)
2026-06-28 19:48:08 +02:00
Jakub Zelenka
fc73636888 test/recipes/15-test_pkey.t: extend tests for openssl pkey -text and -text_pub
This slightly improves openssl pkey text coverage.

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Sun Jun 28 17:42:46 2026
(Merged from https://github.com/openssl/openssl/pull/31521)
2026-06-28 19:41:43 +02:00
Eugene Syromiatnikov
ab612a9baf test/asn1_string_test.c: allocate tmpstring properly in asn1_string_new_not_owned_test
Since tmpstring's ownership is transferred to tmp in ASN1_STRING_set0(),
it should be allocated using OPENSSL_strdup() and not strdup()
(as it will be freed with OPENSSL_free() in ASN1_STRING_clear_free()).
Also, don't try to free tmpstring on error, as at no point there is a jump
to err when tmpstring is allocated and not owned by tmp.

Reported by Coverity, issue 1695274.

Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1695274
Fixes: 68c0321e90 "Provide ASN1_STRING_new_not_owned()"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sun Jun 28 16:22:28 2026
(Merged from https://github.com/openssl/openssl/pull/31667)
2026-06-28 18:22:20 +02:00
Simo Sorce
e60d940b29 Expand AES mode macro into explicit functions
This removes the PROV_CIPHER_HW_aes_mode macro and replaces it with explicitly
written function definitions for each AES mode (ECB, CBC, CFB128, CFB8, CFB1,
OFB128, CTR).

Expanding macro-generated functions improves overall code readability, allows
code navigation tools to properly index the function signatures, and provides
clearer stack traces during debugging.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:06:05 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
48a3219050 Prefix internal AES-GCM functions with ossl_
The `aes_gcm_hw_initkey` and `generic_aes_gcm_cipher_update` functions are
shared across multiple hardware-specific provider implementations but lacked
the internal `ossl_` prefix. They have been renamed to
`ossl_aes_gcm_hw_initkey` and `ossl_generic_aes_gcm_cipher_update`
respectively to follow OpenSSL naming conventions and prevent potential
namespace collisions.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:06:03 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
f7e4eb281d Consolidate SPARC T4 AES implementations
Move SPARC T4-specific AES hardware implementations (GCM, CCM, and XTS) from
individual mode-specific files into a single unified file
(cipher_aes_hw_t4.c). This consolidates the architecture-specific logic to
improve code organization and maintainability.

Additionally, this change removes the unused `keybits` parameter from several
SPARC T4 hardware initialization routines to clean up the internal API.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:06:01 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
b0bda138a6 Consolidate s390x AES hardware implementations
Move the s390x hardware-accelerated AES mode implementations (GCM, CCM, and
XTS) from their respective files into a single `cipher_aes_hw_s390x.c` file.
Centralizing the platform-specific logic simplifies the code structure and
improves maintainability.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:58 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
10dcad1311 Extract Zvkned key length check to helper
A new helper function, zvkned_key_schedule_supported, is introduced to
centralize the verification of 128-bit and 256-bit key lengths.

This replaces multiple duplicated, hardcoded checks across the RISC-V AES
implementations to improve code readability and maintainability. It also
ensures consistent check handling for XTS mode by correctly evaluating half
the key length.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:56 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
aa23e0cd7a Consolidate RISC-V 64 AES hardware code
Merge the RISC-V 64 hardware-accelerated AES mode implementations (GCM, CCM,
and XTS) into a single file (`cipher_aes_hw_rv64i.c`). This removes the need
for separate files for GCM and CCM, and extracts RV64-specific XTS code from
the generic XTS hardware file, improving code organization.

Additionally, remove the unused `keybits` parameter from the RV64 AES hardware
retrieval functions.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:54 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
f537454de0 Consolidate RV32I AES hardware implementations
Move the RISC-V 32-bit hardware-accelerated AES implementations for GCM, CCM,
and XTS modes into a single file (`cipher_aes_hw_rv32i.c`). This removes the
need for separate files (`cipher_aes_gcm_hw_rv32i.c` and
`cipher_aes_ccm_hw_rv32i.c`) and simplifies the build process. Additionally,
unused `keybits` parameters are removed from the provider hardware
initialization functions to clean up the code.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:52 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
d1004c62ac Consolidate ARMv8 AES hardware implementations
Move the ARMv8-specific hardware implementations for AES GCM into a single
consolidated file (`cipher_aes_hw_armv8.c`). This groups architecture-specific
optimizations together to improve code organization and maintainability.

Additionally, remove the unused `keybits` parameter from the ARMv8 provider
functions to simplify the function signatures.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:50 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
16234b9073 Consolidate AESNI hardware implementations
Move the AES-NI specific hardware implementations for GCM, CCM, and XTS modes
from individual mode files into a single consolidated file
(`cipher_aes_hw_aesni.c`). This groups architecture-specific optimizations
together, improving code organization and maintainability.

As part of this refactoring, the unused `keybits` parameter was removed from
several AES-NI provider functions, and necessary XTS initialization and
context copy functions were exported for shared use.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:48 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
774525b38b Migrate s390x AES-XTS to standard HW interface
Move the s390x-specific AES-XTS implementation from `cipher_aes_xts_s390x.inc`
to `cipher_aes_xts_hw.c`, adapting it to use the standard `PROV_CIPHER_HW`
dispatch structure.

This refactoring removes standalone initialization wrappers and integrates the
s390x hardware backend more cleanly with the generic AES-XTS provider code. It
also reduces code duplication by relying on the generic layer for common
validations (such as the maximum blocks per data unit limit) before invoking
the hardware-specific stream cipher.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:46 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
5339c5219f Refactor AES XTS hardware key initialization
Replace complex AES XTS initialization and hardware selection macros
(`XTS_SET_KEY_FN`, `PROV_CIPHER_HW_declare_xts`, and
`PROV_CIPHER_HW_select_xts`) with standard C functions.

Architecture-specific initializers, particularly for RISC-V, are consolidated
to evaluate CPU capabilities within dedicated initialization functions rather
than relying on macro expansion. This refactoring improves overall code
readability, maintainability, and simplifies debugging by eliminating opaque
multi-statement macros.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:44 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
e9cf01be98 Convert AES CCM .inc files to separate .c files
The hardware-specific AES CCM implementations were previously included
directly as `.inc` files into `cipher_aes_ccm_hw.c`. This commit renames them
to standalone `.c` files and updates the build configuration, improving
modularity by treating them as separate compilation units.

Additionally, the `AES_HW_CCM_SET_KEY_FN` macro is replaced with a new
`ossl_cipher_set_ccm_aes_initkey` helper function. This reduces code
duplication, removes unsafe macro logic, and introduces proper error handling
during provider key initialization.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:42 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
62663738b0 Refactor AES hardware cipher implementations
Replace architecture-specific `.inc` files with standalone `.c` files for AES
ciphers and consolidate CFB mode logic into these new modules.

This eliminates the direct inclusion of source files and compiles each
hardware implementation as a separate translation unit.

This refactoring simplifies code organization and remove macro
complexity that makes it hard to understand what is implemented and
where enhancing maintainability.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:40 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
e1c0726f48 Replace GCM_HW_SET_KEY_CTR_FN with a function
The `GCM_HW_SET_KEY_CTR_FN` macro has been removed and replaced with a proper
function, `aes_gcm_hw_initkey`, for AES GCM hardware implementations. For ARIA
GCM, the macro expansion was manually inlined.

This refactoring eliminates a multi-line macro to improve debuggability and
type safety. Crucially, the new function checks the return value of the
underlying key setup routines, ensuring that key initialization failures are
now correctly caught and propagated instead of being ignored.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:38 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Simo Sorce
87efbd9528 Untangle rats nest of .inc files for AES_GCM
These files have no reason not to be just regular .c files.
Additionally apply formatting fixes which were not done on .inc files

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
MergeDate: Sat Jun 27 09:05:35 2026
(Merged from https://github.com/openssl/openssl/pull/31472)
2026-06-27 11:04:36 +02:00
Norbert Pocs
5a47730f01 crypto/LPdir_wince.c: remove dead source file
After removal of Win CE support in commit c60fddbbcf "Drop Windows CE
support.", this file is no longer used.  Remove it.

Complements: c60fddbbcf "Drop Windows CE support."
Reported-by: Nikola Pajkovsky <nikolap@openssl.org>
Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jun 26 17:36:16 2026
(Merged from https://github.com/openssl/openssl/pull/31718)
2026-06-26 19:35:50 +02:00
Andrew Dinh
353248330e Update CI to validate erroring on non-existent test selection
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jun 26 16:40:25 2026
(Merged from https://github.com/openssl/openssl/pull/31639)
2026-06-26 18:38:44 +02:00
Andrew Dinh
f0d8e14c0e test/run_tests.pl: return error if running a non-existent test
Resolves: https://github.com/openssl/openssl/issues/15510
Assisted-by: Claude:claude-sonnet-4-6

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jun 26 16:40:23 2026
(Merged from https://github.com/openssl/openssl/pull/31639)
2026-06-26 18:38:15 +02:00
dannyward630
1111694d86 doc/man7/EVP_KDF-SNMPKDF.pod: fix password parameter documentation
Document the SNMPKDF "pass" parameter with OSSL_KDF_PARAM_PASSWORD,
matching the implementation and other KDF documentation.  Also, fix
the nearby grammar.

Resolves: https://github.com/openssl/openssl/issues/31543
Fixes: 1b035166bd "Add SNMPKDF implementation"
CLA: trivial

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Fri Jun 26 16:29:54 2026
(Merged from https://github.com/openssl/openssl/pull/31592)
2026-06-26 18:28:51 +02:00
007bsd
8be7309f34 crypto/x509/v3_ncons.c: fix scheme buffer leak in nc_uri() for schemeless URIs
OSSL_parse_url() allocates a 1-byte empty-string buffer for the scheme
even when the URI has no scheme.  The empty-scheme error branch freed
uri_copy and jumped to end: which only frees host, leaving scheme
unfreed.  Add OPENSSL_free(scheme) before the goto.

Assisted-by: Claude:claude-sonnet-4-6
CLA: trivial
Fixes: e599893a9f "x509: allow SAN URIs to contain userinfo"

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jun 26 15:26:09 2026
(Merged from https://github.com/openssl/openssl/pull/31678)
2026-06-26 17:25:26 +02:00
007bsd
1f5a44a66d crypto/x509/pcy_cache.c: fix ext_pcons leak in policy_cache_new()
Two early-return paths in policy_cache_new() bypass the just_cleanup:
label and leak the POLICY_CONSTRAINTS object ext_pcons: (1) when
certificatePolicies is absent but policyConstraints is present, and
(2) when policy_cache_create() returns <= 0.  Free ext_pcons before
each early return.

Assisted-by: Claude:claude-sonnet-4-6
CLA: trivial
Fixes: 4acc3e907d "Initial support for certificate policy checking and evaluation."

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Jun 26 15:26:07 2026
(Merged from https://github.com/openssl/openssl/pull/31678)
2026-06-26 17:24:19 +02:00
Neil Horman
1f1ce7cad3 Fix up property test
Because the duplicate test expects the cache get operation to take
a reference count (which we no longer do), we need to not count it down
before checking the resulting ref count

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:17 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
4a8052bb8b delay method store free in context_deinit_objs
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:15 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
2d71463446 Makle STORE_LOADER not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:13 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
7933e2ca6e make OSSL_DECODER no do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:11 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
2480844a11 Make OSSL_ENCODER not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:09 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
7dfc6344d8 make EVP_RAND not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:07 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
47e9e36946 Make EVP_KEYEXCH not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:05 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
32f23d770e Make EVP_KEYMGMT not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:04 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
a3ba2f0575 Make EVP_ASYM_CIPHER not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:02 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
d3cb703b35 Make EVP_SIGNATURE not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:00 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
4971f4830c make EVP_KEM not do refcounting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:57 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
e2f82554ee Make EVP_KDF not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:55 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
e8bc71e666 Make EVP_MAC not do refcounting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:53 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
ae23b9ae02 Make SKEYMGMT not do ref counting
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:51 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:43 -04:00
Neil Horman
d031b650a1 Make EVP_CIPHERS not need to take reference counts
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:49 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:05 -04:00
Neil Horman
6d94352026 Make EVP_MD's not need to take reference counts
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:47 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:05 -04:00
Neil Horman
b34958b877 Don't take reference counts on cache lookups
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:25:45 2026
(Merged from https://github.com/openssl/openssl/pull/31143)
2026-06-25 17:25:05 -04:00
Jakub Zelenka
dbeea0f418 apps: cover the kdf -cipher option in the test recipe
The -cipher option was not covered.  Add KRB5KDF test cases that
exercise it, both via -cipher and the equivalent -kdfopt cipher: form.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 17:01:33 2026
(Merged from https://github.com/openssl/openssl/pull/31651)
2026-06-25 19:01:21 +02:00
Jakub Zelenka
259a14a27f apps: fix Ed25519 typo in pkeyutl recipe subtest names
Two subtest descriptions read "Ed2559" instead of "Ed25519".

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 17:00:37 2026
(Merged from https://github.com/openssl/openssl/pull/31644)
2026-06-25 19:00:28 +02:00
Jakub Zelenka
ff1dcf6a75 apps: cover pkeyutl oneshot buffer path with empty file input
The non-mmap buffer fallback in do_raw_keyop() for oneshot (only_nomd)
keys was never exercised on Unix, since any file with non-zero size
takes the mmap path and returns before reaching it. Signing and
verifying an empty file gives filesize 0, which skips the mmap block
(guarded by filesize > 0) and falls through to the buffer switch,
covering both the SIGN and VERIFY arms.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 17:00:36 2026
(Merged from https://github.com/openssl/openssl/pull/31644)
2026-06-25 19:00:28 +02:00
rootvector2
f9e7cb8cd4 lms: free previous encoded public key in ossl_lms_pubkey_decode
ossl_lms_pubkey_decode() only freed pkey->encoded when the new public key
had a different length, so re-decoding a same-length key on the documented
repeated-call path overwrote the old buffer without freeing it. Always free
the existing buffer first.

Also clear pkey->encodedlen on the error path so a failed decode leaves the
key in a consistent state instead of keeping a stale length.

CLA: trivial

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 16:58:46 2026
(Merged from https://github.com/openssl/openssl/pull/31345)
2026-06-25 18:58:41 +02:00
Tomas Mraz
fe44705758 25-test_verify_store.t: Add missing capture for bare run()
We want to add the printed out pubkey and not
just 1. Also add a comment clarifying intention of this
exercise.

Fixes 77c979faf4

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Thu Jun 25 16:44:51 2026
(Merged from https://github.com/openssl/openssl/pull/31700)
2026-06-25 18:43:40 +02:00
dannyward630
da7eadb593 Mention removed ERR macros in changelog
Update the existing 4.0.0 changelog entry for the ERR state cleanup to list the removed ERR_FLAG_MARK, ERR_FLAG_CLEAR, and ERR_NUM_ERRORS macros.

Fixes #31056

CLA: trivial

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 16:37:57 2026
(Merged from https://github.com/openssl/openssl/pull/31598)
2026-06-25 18:37:50 +02:00
Nikola Pajkovsky
c392d3052f x_all.c: avoid mismatched d2i/i2d function pointer casts
the d2i_*/i2d_* fp and bio wrappers for RSA_PUBKEY, the DSA and EC key
types, and the EVP_PKEY Private/PUBKEY converters passed their
type-specific functions to ASN1_{d2i,i2d}_{fp,bio}, which invoke them
through the generic d2i_of_void / i2d_of_void / void *(*)(void) pointer
types.

Add file-local thunks with the exact generic signatures that forward to
the concrete functions, and pass those instead of cast pointers. This
removes the mismatched calls while keeping the public API unchanged.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:13:01 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
ad47ffd79a avoid d2i_of_void asn1 callbacks in GENERAL_NAME_dup
use IMPLEMENT_ASN1_DUP_FUNCTION(GENERAL_NAME) so duplication goes
through ASN1_item_dup() instead of calling ASN1_dup() with cast
i2d/d2i function pointers. This avoids UBSan function type errors
while preserving the public GENERAL_NAME_dup() API.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:59 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
f6efce32a0 avoid mismatched d2i callbacks in PEM readers
decode PEM payloads through the generated typed d2i_* functions in the
PEM read macros instead of routing them through the d2i_of_void
callback path. This avoids UBSan function type mismatch reports while
preserving the public PEM reader APIs.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:57 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
ba15a13ffe decode_der2key: wrap key-free callbacks to avoid function pointer casts
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:55 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
0e8f2844ed fix function pointer type mismatch in PEM_X509_INFO_read_bio_ex
PEM_X509_INFO_read_bio_ex stored d2i_X509, d2i_X509_AUX, d2i_X509_CRL
or d2i_AutoPrivateKey -- each with a distinct, type-specific signature
returning X509*, X509_CRL* or EVP_PKEY* -- in a single d2i_of_void*
variable and dispatched through it:

    d2i = (D2I_OF(void))d2i_X509;
    ...
    d2i(pp, &p, len)

Replace the function-pointer dispatch with an enum tag
(pem_info_type) and a switch that calls each typed d2i_* directly
with the correctly type.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:53 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
b3003ff1ec fix function pointer type mismatch in OCSP_REQUEST/RESPONSE bio macros
d2i_OCSP_REQUEST/d2i_OCSP_RESPONSE are declared with type-specific
signatures returning OCSP_REQUEST*/OCSP_RESPONSE*, but the
d2i_OCSP_{REQUEST,RESPONSE}_bio macros routed them through
ASN1_d2i_bio_of -> ASN1_d2i_bio, which calls them via a
d2i_of_void* pointer:

    void *(*)(void **, const unsigned char **, long)

The analogous i2d_OCSP_{REQUEST,RESPONSE}_bio macros did the same
through ASN1_i2d_bio_of -> ASN1_i2d_bio with i2d_of_void*.

Rewrite the macros to dispatch through
ASN1_item_d2i_bio/ASN1_item_i2d_bio with ASN1_ITEM_rptr(OCSP_*)
directly. This eliminates the function-pointer cast entirely; both old
and new paths bottom out in the same ASN1_item_d2i_ex / ASN1_item_i2d
call, so behavior is identical.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:50 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
a1e4bd14e5 preserve stack thunks across sk_TYPE_dup
ensure typed stack duplicates keep their compare, copy, and free thunks so
later operations do not call typed callbacks through erased void * function
pointer signatures.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:48 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Nikola Pajkovsky
30db55ac33 util: set thunks for sk_${nametype}_new(_reserve)
call OPENSSL_sk_set_thunks for sk_${nametype}_new and
sk_${nametype}_new_reserve, and wrap the long generated stack
constructor and deep-copy macros across multiple lines so the nested
thunk setup is easier to read and maintain.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:46 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
2026-06-25 08:12:29 -04:00
Bob Beck
c60fddbbcf Drop Windows CE support.
Windows CE has been out of mainstream support since 2018
and will not have a modern toolchain capable of compiling
a modern OpenSSL.

The vc_wince_info Perl helper, the crypto/LPdir_wince.c
directory backend, and a long tail of _WIN32_WCE
 / OPENSSL_SYS_WINCE guards across the Windows code paths
get removed.

Spotted by idrassi.

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 07:27:18 2026
(Merged from https://github.com/openssl/openssl/pull/31601)
2026-06-25 09:26:55 +02:00
Jakub Zelenka
bb68815067 apps: cover the pkcs8 -inform/-outform DER options
Only PEM input/output was exercised.  Add a subtest that round trips a
key through DER, for both unencrypted and encrypted PKCS#8.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jun 25 07:24:30 2026
(Merged from https://github.com/openssl/openssl/pull/31653)
2026-06-25 09:24:26 +02:00
Eugene Syromiatnikov
7d810b0df2 CONTRIBUTING.md: tweak wording with regards to ML tooling usage
ML tools do not satisfy the authorship requirement, so they are merely
used, and not "create" on their own.

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
MergeDate: Thu Jun 25 07:22:26 2026
(Merged from https://github.com/openssl/openssl/pull/31643)
2026-06-25 09:22:23 +02:00
Eugene Syromiatnikov
a51f1834c0 crypto/ctype.c: fix off-by-one OOB in ossl_toascii()/ossl_fromascii()
Incorrect check for the upper bound allowed the value of 256 to slip
through, which could lead to OOB read one element beyound the end
of the os_toascii/os_toebcdic arrays.  Fix that by changing
the comparison with 256 from strictly great to great-or-equal.

Found by cppcheck.

Fixes: a1df06b363 "This has been added to avoid the situation where some host ctype.h functions return true for characters > 127.  I.e. they are allowing extended ASCII characters through which then cause problems.  E.g. marking superscript '2' as a number then causes the common (ch - '0') conversion to number to fail miserably.  Likewise letters with diacritical marks can also cause problems."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Thu Jun 25 07:19:30 2026
(Merged from https://github.com/openssl/openssl/pull/31661)
2026-06-25 09:19:25 +02:00
Eugene Syromiatnikov
ea7dbd4fee rec_layer_s3.c: prevent max_early_data overflow in ossl_early_data_count_ok()
Apply change similar to the one made in d41a922519 "tls_common.c: prevent
max_early_data overflow in rlayer_early_data_count_ok()"
to ossl_early_data_count_ok(), that has similar logic in it
(as rlayer_early_data_count_ok() has been copied
from ossl_early_data_count_ok() in 9dd90232d5 "Move early data counting
out of the SSL object and into the record layer").

Complements: d41a922519 "tls_common.c: prevent max_early_data overflow in rlayer_early_data_count_ok()"
Fixes: 70ef40a05e "Check max_early_data against the amount of early data we actually receive"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Thu Jun 25 07:13:07 2026
(Merged from https://github.com/openssl/openssl/pull/31628)
2026-06-25 09:12:50 +02:00
Jakub Zelenka
df3a538aff apps: add error-path test recipe for skeyutl
Cover the help, option-parsing and error paths of the skeyutl command.
The successful -genkey path is not exercised as no built-in provider
implements opaque symmetric key generation yet.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jun 25 07:10:05 2026
(Merged from https://github.com/openssl/openssl/pull/31648)
2026-06-25 09:09:58 +02:00
Jakub Zelenka
5fb218a35c quic: add mfail tests for QUIC SRTM
This cover various function for SRTM.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 07:06:31 2026
(Merged from https://github.com/openssl/openssl/pull/31593)
2026-06-25 09:06:27 +02:00
Dmitry Misharov
93a2b9be5e remove make-release.yml, it will be executed on OpenSSL Jenkins instance
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Thu Jun 25 07:04:01 2026
(Merged from https://github.com/openssl/openssl/pull/31674)
2026-06-25 09:03:57 +02:00
Daniel Kubec
fc972e592e AEAD: reject late AAD in ChaCha20-Poly1305 after plaintext update
Align behavior with AES GCM, which already rejects this misuse with a hard
error, by tracking whether plaintext processing has started and returning an
error if AAD is supplied afterwards.

Fixes #31188

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Thu Jun 25 07:01:44 2026
(Merged from https://github.com/openssl/openssl/pull/31673)
2026-06-25 09:01:39 +02:00
Nikola Pajkovsky
d681e8b6bf crypto/armcap.c: reformat MIDR CPU-model conditionals for readability
break long chain of MIDR_IS_CPU_MODEL() alternatives packed onto a
single line, which was effectively unreadable and impossible to review
or diff one model at a time.

move the OPENSSL_armcap_P feature-flag test to the front of the
expression so the guard is obvious before the model list. This is a
formatting-only change.

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Thu Jun 25 06:10:45 2026
(Merged from https://github.com/openssl/openssl/pull/31664)
2026-06-25 08:10:38 +02:00
Jakub Zelenka
26516294b5 apps: cover the ec -conv_form option in the test recipe
The -conv_form option was not covered.  Add a subtest that checks a
valid form changes the public key encoding and that an invalid form
is rejected.  The DER encodings are also compared against committed
reference files, as they are deterministic for testec-p256.pem.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Thu Jun 25 06:08:38 2026
(Merged from https://github.com/openssl/openssl/pull/31652)
2026-06-25 08:08:32 +02:00
Viktor Dukhovni
2fabd5d274 Once initialised, ML-DSA keys should be immutable
ML-DSA keys should become immutable once key material has been added.
This is already the case for at least ML-KEM keys, and should generally
be the case across all key types.

- Added the requisite check in the key management provider ml_dsa_import()
  function.
- Also, consolidated the ML-KEM checks in ml_kem_import().  These were
  previously partly in ml_kem_key_fromdata().

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jun 25 02:03:35 2026
(Merged from https://github.com/openssl/openssl/pull/30421)
2026-06-25 12:03:26 +10:00
Kirill Ermoshin
8d7bec32e6 Remove aliases for IANA-GOST2012-GOST8912-GOST8912
"gost2012_256/512" sigalgs aliases of IANA-GOST2012-GOST8912-GOST8912 equals
to sigalgs of LEAGACY-GOST2012-GOST8912-GOST8912 so we can't distinguish
between them for the legacy algorithm

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jun 24 15:07:04 2026
(Merged from https://github.com/openssl/openssl/pull/31562)
2026-06-24 17:06:49 +02:00
Kirill Ermoshin
3e4955cce9 Fix typo of 512 gost sigalg name from bcff020
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jun 24 15:07:02 2026
(Merged from https://github.com/openssl/openssl/pull/31562)
2026-06-24 17:06:49 +02:00
Eugene Syromiatnikov
029d629db2 include/internal/hashtable.h: avoid OOB read in ossl_ht_strcase()
Avoid accessing src[len] by swapping the check order and bound check
the iterator variable before the access.

Found by cppcheck.

Fixes: cc4ea5e000 "Introduce new internal hashtable implementation"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jun 24 13:09:25 2026
(Merged from https://github.com/openssl/openssl/pull/31663)
2026-06-24 15:09:20 +02:00
Tomas Mraz
c80ce10841 Always ignore the contents of the legacy record version
As per RFC8446 this value must be ignored.

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Wed Jun 24 13:06:55 2026
(Merged from https://github.com/openssl/openssl/pull/31662)
2026-06-24 15:06:43 +02:00
Bob Beck
1a65972ad0 Add documentation for NAME_CONSTRAINTS_check
We document which names and name constraints will be evaluated
as well as the limits that will be placed on the evauluation on
a per certificate basis.

We call out in the BUGS section that the RFC 5280 requires a byte
per byte match of name constraints unless the higher level protocol
has defines a different matching method for wildcards. This
"deferall of specification" and corresponding lack of specification
by upper level protocols means that across implementations encountering
the default behaviour is to be expected, and that therefore relying
on excluded names to constrain signers in a PKI from signing wildcards
is ill advised.

This is then cross referenced in the documentation for X509_verify_cert
and the maximum possible comparisons which can be forces in a certificate
validtion noted in the BUGS section of X509_verify_cert.

Fixes: https://github.com/openssl/openssl/issues/30706

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Wed Jun 24 13:03:54 2026
(Merged from https://github.com/openssl/openssl/pull/31334)
2026-06-24 15:03:52 +02:00
Mounir IDRASSI
54aef373f3 Reject HelloRequest in TLS 1.3
TLS 1.3 reserves handshake message type 0 and must not silently
ignore HelloRequest records. The legacy client-side HelloRequest skip
path in tls_get_message_header() could run before the TLS 1.3 state
machine had a chance to reject the message, so a zero-length
HelloRequest injected after ClientHello was discarded instead of
triggering unexpected_message.

Restrict the skip to cases where TLS 1.3 is no longer possible.
Before ServerHello selects a version, s->version is the configured
maximum; after ServerHello or during renegotiation, it is the
negotiated version. Skip only when that value is below TLS 1.3,
preserving the existing TLS 1.2-and-below behavior.

Add TLSProxy regression tests covering rejection while TLS 1.3 is
possible and the preserved TLS 1.2 skip after ServerHello.

Fixes #31531

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jun 24 13:01:12 2026
(Merged from https://github.com/openssl/openssl/pull/31577)
2026-06-24 15:01:06 +02:00
Bernd Edlinger
25b37961f7 Prevent integer overflow in ASN1_mbstring_ncopy
This prevents a theoretically possible integer overflow
in OPENSSL_malloc(outlen + 1) at the end of ASN1_mbstring_ncopy,
when outlen is exactly INT_MAX.
That affects conversions from MBSTRING_ASC to MBSTRING_UTF8
and MBSTRING_UTF8 to MBSTRING_ASC,
because a terminating zero has to be added to the result.
And also conversions MBSTRING_BMP to MBSTRING_UTF8
in cases when UTF8 characters 0x800..0xFFFF are encoded
as 3-byte UTF8-characters and the resulting UTF8-string
is exactly INT_MAX in size.

Fixes: 97f6b621f7 ("Reject oversized inputs in ASN1_mbstring_ncopy()")

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Jun 24 12:49:08 2026
(Merged from https://github.com/openssl/openssl/pull/31527)
2026-06-24 14:49:06 +02:00
Billy Brumley
a933605a62 [test] various zero-length message positive and negative tests for AEAD ciphers
A zero-length AEAD message driven through the one-shot EVP_Cipher() interface
must agree with the streaming EVP_CipherFinal_ex() path. This checks:
- an empty message yields the same tag via both interfaces
- the true tag passes verification on decrypt
- the modified tag fails verification on decrypt

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Wed Jun 24 12:47:11 2026
(Merged from https://github.com/openssl/openssl/pull/31555)
2026-06-24 14:47:06 +02:00
Alicja Kario
1cfec91eb6 test/evp_extra_test.c: add test case for CVE-2026-42770
Signed-off-by: Alicja Kario <hkario@redhat.com>

Reviewed-by: Igor Ustinov <igus@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Wed Jun 24 11:56:27 2026
(Merged from https://github.com/openssl/openssl/pull/31548)
2026-06-24 13:43:14 +02:00
dannyward630
773400d366 crypto/ec/curve448/eddsa.c: document Ed448 property query parameter
Document the propq argument in the Ed448 key generation, signing,
and verification helper comments.

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jun 24 11:00:00 2026
(Merged from https://github.com/openssl/openssl/pull/31599)
2026-06-24 12:59:40 +02:00
Mounir IDRASSI
b44fd71741 pkcs7: Fix negative index handling in PKCS7_get_issuer_and_serial()
Reject negative indices before looking up the recipient info stack
entry.  This makes negative out-of-range indices match the existing
behavior for too-large positive indices and avoids dereferencing
a NULL recipient info.

Add a regression test for the negative index case.

Resolves: https://github.com/openssl/openssl/issues/30910

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
MergeDate: Wed Jun 24 09:10:22 2026
(Merged from https://github.com/openssl/openssl/pull/30914)
2026-06-24 11:09:49 +02:00
Randall S. Becker
77c979faf4 Fix unqualified reference to openssl in 25-test_verify_store.t
This problem resulted in the wrong location of openssl being used
for one step in subtest 7.  The error condition is hidden if openssl
appears in the PATH.

Resolves: https://github.com/openssl/openssl/issues/31496
Fixes: 3638ffc380 "Refactor cache_objects() loop and object type handling"
Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Wed Jun 24 08:47:58 2026
(Merged from https://github.com/openssl/openssl/pull/31647)
2026-06-24 10:46:31 +02:00
Haiyang Huang
24137d12a2 quic: reject ACK of an unsent packet number
ossl_ackm_on_rx_ack_frame() stored ack_ranges[0].end into
largest_acked_pkt[pkt_space] without checking it against the highest
packet number actually sent in that space. Because largest_acked_pkt
only ever increases and drives loss detection, an ACK acknowledging a
packet number that was never sent (up to 2**62 - 1) pins the value and
causes every in-flight and subsequently-sent packet to be declared lost,
permanently corrupting loss detection for the connection.

RFC 9000 s. 13.1 recommends treating an acknowledgment for a packet the
endpoint did not send as a connection error of type PROTOCOL_VIOLATION,
where it can be detected.

Reject any ACK whose largest acknowledged packet number exceeds the
highest packet number sent in that space; the bound, highest_sent, is
already tracked. The depacketiser raises PROTOCOL_VIOLATION when the ACK
manager rejects the frame.

Update the QUIC tests for the new behaviour: cases 7 and 8 now assert
rejection, case 14 covers the 2**62 - 1 boundary, two pre-existing
fixtures that acknowledged one packet past the highest sent are
corrected, and the "fictional PN" script now expects a PROTOCOL_VIOLATION
close.

Fixes: fa4e92a70a "QUIC ACK Manager, Statistics Manager and Congestion Control API"
Assisted-by: Claude:claude-opus-4.6

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jun 23 16:36:27 2026
(Merged from https://github.com/openssl/openssl/pull/31582)
2026-06-23 18:36:04 +02:00
Carlo Deutschmann
a226dc3520 Avoid NULL dereference if RSA_PSS_PARAMS_dup() fails in ossl_rsa_dup()
RSA_PSS_PARAMS_dup() can return NULL on failure (e.g. memory
allocation failure). The subsequent code dereferenced dupkey->pss
unconditionally when checking dupkey->pss->maskGenAlgorithm, which
would result in a NULL pointer dereference.

Check the return value and jump to the error handling instead, which
properly frees the partially constructed key.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jun 23 16:32:24 2026
(Merged from https://github.com/openssl/openssl/pull/31619)
2026-06-23 18:32:17 +02:00
Eugene Syromiatnikov
67bddd0f33 apps/lib/s_cb.c: actualise signature_tls13_scheme_list
Update signature_tls13_scheme_list array in accordance with the current
state of the "TLS SignatureScheme" table at [1];  leave TLS 1.2 GOST
definitions be for now.

Note: these are used only for debugging output when -security_debug
option is provided to s_client/s_server commands.

[1] https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-signaturescheme

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Jun 23 16:30:02 2026
(Merged from https://github.com/openssl/openssl/pull/31248)
2026-06-23 18:29:44 +02:00
Eugene Syromiatnikov
4a08aa1346 Add TLS 1.3 SignatureScheme definitions for SLH-DSA
In accordance with [1].

[1] https://datatracker.ietf.org/doc/html/draft-reddy-tls-slhdsa-02

Resolves: https://github.com/openssl/project/issues/1945
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Jun 23 16:30:01 2026
(Merged from https://github.com/openssl/openssl/pull/31248)
2026-06-23 18:29:43 +02:00
Eugene Syromiatnikov
31274b3d30 ssl/t1_trce.c: use macros from tlssigalgs.h, reorder accordingly
The macro definitions for the SignatureScheme values and names
are available "include/internal/tlssigalgs.h" (contrary to what comment
says), use them and also order the items in the order they are present
in the header file.

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Tue Jun 23 16:29:59 2026
(Merged from https://github.com/openssl/openssl/pull/31248)
2026-06-23 18:29:43 +02:00
007bsd
8d0f837db8 Fix key2ms_newctx() pointer type mismatch in MSBLOB/PVK key encoder
key2ms_newctx() returned struct key2ms_ctx_st *, but is registered
as OSSL_FUNC_ENCODER_NEWCTX and called through OSSL_FUNC_encoder_newctx_fn
(void *(*)(void *)), which is a case of undefined behavior, flagged
by -fsanitize=function.  Same class as [1], missed there.

Give it the correct signature and add the self-check forward
declaration, as key2ms_freectx() already has.

[1] https://github.com/openssl/openssl/pull/31078

CLA: trivial
Fixes: 0cc0164d19 "PROV: Add MSBLOB and PVK encoders"

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Jun 23 14:45:54 2026
(Merged from https://github.com/openssl/openssl/pull/31189)
2026-06-23 16:43:49 +02:00
Jakub Zelenka
8ccf576564 quic: add mfail test for QUIC SRT generator
This slightly improves its coverage.

Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jun 23 14:01:21 2026
(Merged from https://github.com/openssl/openssl/pull/31589)
2026-06-23 16:01:15 +02:00
Jakub Zelenka
43ce59231e Add mfail test for SSL_new() with ctx QUIC client method
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Tue Jun 23 13:16:52 2026
(Merged from https://github.com/openssl/openssl/pull/31249)
2026-06-23 15:16:45 +02:00
Alexandr Nedvedicky
7045b8fde5 This change should allow us to move QUIC test scripts from
quic_multistream test to radix without dealing with conflict+rebase.

the idea is there will be one PR for each script, so more people
will be able to submit those PRs without rsiking a conflicts around
the scripts array. This should allow for smoot reciew/git push
flow.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Tue Jun 23 12:21:25 2026
(Merged from https://github.com/openssl/openssl/pull/31547)
2026-06-23 08:21:23 -04:00
Frederik Wedel-Heinen
60a174cd6c ssl/record: remove remnants of SSLv2-specific code
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Tue Jun 23 07:09:07 2026
(Merged from https://github.com/openssl/openssl/pull/31627)
2026-06-23 09:08:35 +02:00
Bob Beck
bf41baa2bf doc/man3/ASN1_aux_cb.pod: correct return code documentation for the callbacks
Attempt to make the documentation match the code.

Not attempting to change what the code does at this point, it's
all very random, and since it's been there, it is effectively established
public API now.

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jun 22 11:56:58 2026
(Merged from https://github.com/openssl/openssl/pull/31549)
2026-06-22 13:54:39 +02:00
Jon Ericson
f23329efa0 CONTRIBUTING.md: add the AI declaration policy
References: https://github.com/openssl/general-policies/pull/85

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jun 22 10:36:52 2026
(Merged from https://github.com/openssl/openssl/pull/31604)
2026-06-22 12:35:38 +02:00
Abel Tom
206ec55fec crypto/pkcs7/pk7_lib.c: fix return value in PKCS7_set_digest()
Return 0 when the passed object to PKCS7_set_digest() is not of type PKCS7
digest.

Fixes: c5a5546389 "Add support for digested data PKCS#7 type."
Resolves: https://github.com/openssl/openssl/issues/31551

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Mon Jun 22 08:17:32 2026
(Merged from https://github.com/openssl/openssl/pull/31559)
2026-06-22 10:16:13 +02:00
Bob Beck
b593fb151e Fix OSSL_ATOMICS_LOCKLESS detection for Windows toolchains
The check referenced USE_INTERLOCKEDOR64, but the macro defined above
for MSVC (with the right architecture/version) and 64-bit MinGW is
OSSL_USE_INTERLOCKEDOR64.  As a result, OSSL_ATOMICS_LOCKLESS was
never defined on Windows, even though those toolchains do provide
lockless atomics.

Reported-by: Mounir IDRASSI <mounir.idrassi@idrix.fr>
Fixes: 26c5742393 "Use the actually correct define for solaris and gcc"

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jun 22 07:22:31 2026
(Merged from https://github.com/openssl/openssl/pull/31600)
2026-06-22 09:14:04 +02:00
Abel Tom
d41a922519 tls_common.c: prevent max_early_data overflow in rlayer_early_data_count_ok()
Make the local max_early_data variable uint64_t so an overflow
cannot occur if the max_early_data field in the record layer struct
has the maximum value: UNT32_MAX (0xFFFFFFFF).

Resolves: https://github.com/openssl/openssl/issues/31533

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
MergeDate: Sun Jun 21 23:50:02 2026
(Merged from https://github.com/openssl/openssl/pull/31538)
2026-06-22 01:48:56 +02:00
Nikola Pajkovsky
39f46844c6 asn1: centralize aux const-callback dispatch to avoid function pointer cast
Replace the per-call-site `(ASN1_aux_const_cb *)aux->asn1_cb` cast in
ASN1_item_ex_i2d() and asn1_item_print_ctx() with a shared helper,
ossl_asn1_aux_const_cb(), which invokes the legacy non-const callback
through its real type. This avoids the UBSAN function-pointer-type
mismatch while preserving backward compatibility.

Fixes: https://github.com/openssl/project/issues/1970
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sun Jun 21 23:38:12 2026
(Merged from https://github.com/openssl/openssl/pull/31541)
2026-06-22 01:37:13 +02:00
Carlo Deutschmann
7a5476687e Fix spelling mistakes in documentation
Correct a number of typos found in the man pages:
 * doc/man3/SSL_CTX_set1_curves.pod:        attenion   -> attention
 * doc/man3/CMS_EncryptedData_decrypt.pod:  decypted   -> decrypted
 * doc/man3/X509_get_default_cert_file.pod: delimeter  -> delimiter
 * doc/man3/SSL_CTX_set_msg_callback.pod:   diagostic  -> diagnostic
 * doc/man7/openssl-core_dispatch.h.pod:    dipatch    -> dispatch
 * doc/man3/BIO_s_datagram.pod:             hecause    -> because
 * doc/man3/ASN1_aux_cb.pod:                auxiliarly -> auxiliary

CLA: trivial
Fixes: 3d9d1ce529 "Add documentation for newly added ASN1 functions"
Fixes: 408622b73a "BIO_s_dgram: add documentation and hazard warnings"
Fixes: e2f6960fc5 "CMS: Export CMS_EnvelopedData and add CMS_EnvelopedData_decrypt()"
Fixes: 9efd7e9e98 "Fix group tuple handling in DEFAULT expansion"
Fixes: bfcf1356f9 "Update the msg_callback documentation"
Fixes: 606e0426a1 "Add support for loading root CAs from Windows crypto API"
Fixes: 329b2a2cde "DOCS: add openssl-core_numbers.h(7)"

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 21 22:50:14 2026
(Merged from https://github.com/openssl/openssl/pull/31596)
2026-06-22 00:47:34 +02:00
Shmael13
b298b44466 demos/http3: fix missing NUL terminator on h3ssl->url
In the HTTP/3 demo server's :path handler, when the path value does not
begin with '/', the value is copied into the fixed-size url[MAXURL]
buffer with memcpy(h3ssl->url, vvalue.base, len) and no terminator is
written. len is capped at MAXURL, so a :path value of MAXURL or more
bytes fills the entire buffer, overwriting the zeroes from the preceding
memset and leaving url without a NUL terminator. The buffer is later
used as a C string by strcat() and strcmp() when building the file name,
resulting in a heap out-of-bounds read and a possible overflow of the
filename[PATH_MAX] buffer. This is reachable from a client-supplied
:path header.

Cap the length at MAXURL - 1 so that the trailing byte zeroed by the
memset always remains, guaranteeing url is NUL-terminated in every
branch. The '/'-prefixed branches are unaffected as they already write
an explicit terminator within the smaller bound.

Fixes #31516

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sun Jun 21 16:19:08 2026
(Merged from https://github.com/openssl/openssl/pull/31520)
2026-06-21 12:19:00 -04:00
Jakub Zelenka
bb3d8b9c52 apps: test pkeyutl -derive peer key setup
This tests currently uncovered setup_peer function and some failure
scenarios in it.

Assisted-by: Claude:claude-opus-4-8

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sun Jun 21 16:04:59 2026
(Merged from https://github.com/openssl/openssl/pull/31518)
2026-06-21 12:04:53 -04:00
sunnyqeen
66c36af077 Fix unix Makefile template to avoid command line too long error on windows
On cygwin/msys systems that run on Windows, command line length is limited. using response file instead of putting objects on the command line will avoid this error

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sun Jun 21 15:56:08 2026
(Merged from https://github.com/openssl/openssl/pull/23077)
2026-06-21 11:55:57 -04:00
Ingo Franzki
1a1d088d2a s390x: Don't ignore errors from s390x_mod_exp_hw() and s390x_crt()
Currently errors from s390x_mod_exp_hw() and s390x_crt() are silently
ignored and the software path is used as fallback.

Change this to only take the software path if s390x_mod_exp_hw() and
s390x_crt() returns 0 to indicate that it does not support the RSA
acceleration. In case of errors, return them to the caller. Errors could
be memory allocation failures or errors during BIGNUM calls. Those should
not be ignored, but reported as failure.

Note that it can happen that the ioctl's fail, but this is not to be
reported as error. Those are situations where for example no suitable
crypto adapter is available, or the file descriptor has been closed
by a sandbox. Those situations disable the RSA acceleration for further
RSA requests, but the current operation should still be performed via the
software fallback. For cases where the RSA key size is too large for
acceleration, the operation must also be performed via the software
fallback, and not reported as an error.

This also fixes failures of the test_rsa_pkcs1_mfail test case that found
the memory allocation failures that got ignored.

Resolves: https://github.com/openssl/openssl/issues/31480
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 21 14:19:54 2026
(Merged from https://github.com/openssl/openssl/pull/31482)
2026-06-21 16:19:38 +02:00
Ingo Franzki
036db3a8ef s390x: Don't ignore errors from s390x_HMAC_init()
Currently errors from s390x_HMAC_init() are silently ignored and the software
path is used as fallback.

Change this to only take the software path if s390x_HMAC_init() returns -1
to indicate that it does not support the HMAC acceleration. In case of
errors, return them to the caller. Errors could be memory allocation
failures or errors during digest operations. Those should not be ignored,
but reported as failure.

This also fixes failures of the test_rsa_pkcs1_mfail test case that found
the memory allocation failures that got ignored.

References: https://github.com/openssl/openssl/issues/31480
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sun Jun 21 14:19:53 2026
(Merged from https://github.com/openssl/openssl/pull/31482)
2026-06-21 16:19:12 +02:00
Loganaden Velvindron
4d9e2a5797 ssl/quic/quic_ackm.c: fix use after free for apkt in ackm_on_pkts_acked()
Store in_flight flag in a local variable for later use, as apkt->on_acked()
may free apkt.

Fixes: 427a02ad0a "QUIC ACKM: Don't record non-inflight packets in CC"
Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Sun Jun 21 13:55:08 2026
(Merged from https://github.com/openssl/openssl/pull/31447)
2026-06-21 15:55:04 +02:00
Tomas Mraz
1eaf29ef6c Remove direct includes of windows.h where possible
It should be included via e_os.h instead.

Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Sat Jun 20 11:00:42 2026
(Merged from https://github.com/openssl/openssl/pull/31587)
2026-06-20 07:00:32 -04:00
655 changed files with 32730 additions and 8314 deletions

View file

@ -1375,6 +1375,7 @@ StatementMacros:
- "static_ASN1_SEQUENCE_END_cb"
- "static_ASN1_SEQUENCE_END_name"
- "static_ASN1_SEQUENCE_END_ref"
- "PROV_CIPHER_HW_aes_mode"
- "PROV_CIPHER_HW_aria_mode"
- "PROV_CIPHER_HW_camellia_mode"
- "PROV_CIPHER_HW_des_mode"

167
.github/workflows/avx512-sde.yml vendored Normal file
View file

@ -0,0 +1,167 @@
# Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
# Copyright (c) 2026 Intel Corporation. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
# Run AVX512-specific tests under Intel SDE.
#
# GitHub Actions runners currently do not have AVX512 hardware.
# Intel SDE emulates AVX512 instructions and spoofs CPUID,
# so AVX512 code paths are exercised.
#
# To update Intel SDE: find the new mirror ID and file date from
# https://www.intel.com/content/www/us/en/download/684897
# and update the three env vars below.
name: AVX512 tests via Intel SDE
on:
schedule:
- cron: '30 02 * * *'
workflow_dispatch:
permissions:
contents: read
env:
SDE_VERSION: 10.8.0
SDE_DATE: 2026-03-15
SDE_MIRROR_ID: 915934
jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: install NASM
run: sudo apt-get install -y nasm
- name: install Intel SDE
run: |
SDE_URL="https://downloadmirror.intel.com/${SDE_MIRROR_ID}/sde-external-${SDE_VERSION}-${SDE_DATE}-lin.tar.xz"
SDE_SHA256="50b320cd226acef7a491f5b321fc1be3c3c7984f9e27a456e64894b5b0979dd3"
curl -fsSL -o /tmp/sde.tar.xz "$SDE_URL"
echo "$SDE_SHA256 /tmp/sde.tar.xz" | sha256sum -c -
mkdir /tmp/sde
tar -xf /tmp/sde.tar.xz -C /tmp/sde/
sudo mv /tmp/sde/sde-external-${SDE_VERSION}-${SDE_DATE}-lin /opt/sde
echo "/opt/sde" >> "$GITHUB_PATH"
- name: config
run: |
./config --banner=Configured --strict-warnings no-shared enable-fips
- name: build
run: make -j4
- name: show CPU and OpenSSL build info
run: |
cat /proc/cpuinfo | grep -m1 "model name"
sde64 -icx -- ./apps/openssl version -c
- name: ml_dsa_internal_test (AVX512 via SDE)
run: sde64 -icx -- ./test/ml_dsa_internal_test
- name: sha3_x4_internal_test (AVX512 via SDE)
run: sde64 -icx -- ./test/sha3_x4_internal_test
- name: fipsinstall (FIPS KAT via SDE)
run: sde64 -icx -- ./apps/openssl fipsinstall -module ./providers/fips.so -out /tmp/fipsmodule.cnf -provider_name fips
windows:
runs-on: windows-2022
env:
VCVARS: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: install nasm
if: github.repository == 'openssl/openssl'
run: |
$installer = "nasm-3.01-installer-x64.exe"
Invoke-WebRequest -Uri "https://openssl-library.org/ci-deps/$installer" -OutFile $installer
$expected = (Get-Content "$env:GITHUB_WORKSPACE\.github\ci-deps.json" -Raw | ConvertFrom-Json).$installer
$actual = (Get-FileHash $installer -Algorithm SHA256).Hash
if ($actual -ne $expected) { throw "SHA256 mismatch for $installer (expected $expected, got $actual)" }
Start-Process -FilePath ".\$installer" -ArgumentList '/S' -Wait
"C:\Program Files\NASM" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install nasm (forks)
if: github.repository != 'openssl/openssl'
run: |
$installer = "nasm-3.01-installer-x64.exe"
Invoke-WebRequest -Uri "https://www.nasm.us/pub/nasm/releasebuilds/3.01/win64/$installer" -OutFile $installer
Start-Process -FilePath ".\$installer" -ArgumentList '/S' -Wait
"C:\Program Files\NASM" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install jom
if: github.repository == 'openssl/openssl'
run: |
mkdir C:\jom
Invoke-WebRequest -Uri "https://openssl-library.org/ci-deps/jom-1.1.7.exe" -OutFile C:\jom\jom.exe
$expected = (Get-Content "$env:GITHUB_WORKSPACE\.github\ci-deps.json" -Raw | ConvertFrom-Json).'jom-1.1.7.exe'
$actual = (Get-FileHash C:\jom\jom.exe -Algorithm SHA256).Hash
if ($actual -ne $expected) { throw "SHA256 mismatch for jom.exe (expected $expected, got $actual)" }
"C:\jom" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install jom (forks)
if: github.repository != 'openssl/openssl'
run: |
mkdir C:\jom
Invoke-WebRequest -Uri "https://download.qt.io/official_releases/jom/jom_1_1_7.zip" -OutFile C:\jom\jom.zip
Expand-Archive -Path C:\jom\jom.zip -DestinationPath C:\jom
"C:\jom" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install Intel SDE
run: |
$url = "https://downloadmirror.intel.com/$env:SDE_MIRROR_ID/sde-external-$env:SDE_VERSION-$env:SDE_DATE-win.tar.xz"
$expected = "176F87C80EB42BB91B73E1428F4A0FD067DF322F901F9B4359B20B86B92C2BAE"
curl.exe -fsSL -o sde-win.tar.xz $url
$actual = (Get-FileHash sde-win.tar.xz -Algorithm SHA256).Hash
if ($actual -ne $expected) { throw "SDE SHA256 mismatch: got $actual" }
& "C:\Program Files\7-Zip\7z.exe" x sde-win.tar.xz -so | & "C:\Program Files\7-Zip\7z.exe" x -si -ttar -o"C:\sde"
$sdeRoot = "C:\sde\sde-external-$env:SDE_VERSION-$env:SDE_DATE-win"
if (-not (Test-Path "$sdeRoot\sde.exe")) { throw "sde.exe not found in $sdeRoot" }
"$sdeRoot" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: prepare build directory
run: mkdir _build
- name: config
working-directory: _build
shell: cmd
run: |
call "%VCVARS%"
perl ..\Configure --banner=Configured --strict-warnings no-shared enable-fips no-makedepend
- name: build
working-directory: _build
shell: cmd
run: |
call "%VCVARS%"
jom /j4 /S
- name: show CPU and OpenSSL build info
working-directory: _build
run: sde -icx -- apps\openssl.exe version -c
- name: ml_dsa_internal_test (AVX512 via SDE)
working-directory: _build
shell: cmd
run: sde -icx -- test\ml_dsa_internal_test.exe
- name: sha3_x4_internal_test (AVX512 via SDE)
working-directory: _build
shell: cmd
run: sde -icx -- test\sha3_x4_internal_test.exe
- name: fipsinstall (FIPS KAT via SDE)
working-directory: _build
shell: cmd
run: sde -icx -- apps\openssl.exe fipsinstall -module providers\fips.dll -out fipsmodule.cnf -provider_name fips

125
.github/workflows/ci-doc-changes.yml vendored Normal file
View file

@ -0,0 +1,125 @@
# Copyright 2021-2026 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
name: Documentation and Installability CI
on: [pull_request, push]
permissions:
contents: read
env:
OSSL_RUN_CI_TESTS: 1
jobs:
check_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: config
run: ./config --strict-warnings --banner=Configured enable-fips && perl configdata.pm --dump
- name: make build_generated
run: make -s build_generated
- name: make doc-nits
run: make doc-nits
- name: make help
run: make help
- name: make md-nits
run: |
sudo gem install mdl
make md-nits
# out-of-source-and-install checks multiple things at the same time:
# - That building, testing and installing works from an out-of-source
# build tree
# - That building, testing and installing works with a read-only source
# tree
out-of-readonly-source-and-install-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
path: ./source
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
working-directory: ./source
- name: make source read-only
run: chmod -R a-w ./source
- name: create build and install directories
run: |
mkdir ./build
mkdir ./install
- name: config
run: |
../source/config --banner=Configured enable-demos enable-h3demo enable-fips enable-lms enable-quic enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
perl configdata.pm --dump
working-directory: ./build
- name: make
run: make -s -j4
working-directory: ./build
- name: get cpu info
run: |
cat /proc/cpuinfo
./util/opensslwrap.sh version -c
working-directory: ./build
- name: make test
run: ../source/.github/workflows/make-test
working-directory: ./build
- name: save artifacts
if: success() || failure()
uses: actions/upload-artifact@v5
with:
name: "ci@out-of-readonly-source-and-install-ubuntu"
path: build/artifacts.tar.gz
- name: make install
run: make install
working-directory: ./build
out-of-readonly-source-and-install-macos:
runs-on: macos-15
steps:
- uses: actions/checkout@v6
with:
path: ./source
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
working-directory: ./source
- name: make source read-only
run: chmod -R a-w ./source
- name: create build and install directories
run: |
mkdir ./build
mkdir ./install
- name: config
run: |
../source/config --banner=Configured enable-fips enable-lms enable-demos enable-h3demo enable-quic enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
perl configdata.pm --dump
working-directory: ./build
- name: make
run: make -s -j4
working-directory: ./build
- name: get cpu info
run: |
sysctl machdep.cpu
./util/opensslwrap.sh version -c
working-directory: ./build
- name: make test
run: ../source/.github/workflows/make-test
working-directory: ./build
- name: save artifacts
if: success() || failure()
uses: actions/upload-artifact@v5
with:
name: "ci@out-of-readonly-source-and-install-macos-15"
path: build/artifacts.tar.gz
- name: make install
run: make install
working-directory: ./build

View file

@ -7,7 +7,25 @@
name: GitHub CI
on: [pull_request, push]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
# for some reason, this does not work:
# variables:
@ -45,25 +63,6 @@ jobs:
- name: git diff
run: git diff --exit-code
check_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: config
run: ./config --strict-warnings --banner=Configured enable-fips && perl configdata.pm --dump
- name: make build_generated
run: make -s build_generated
- name: make doc-nits
run: make doc-nits
- name: make help
run: make help
- name: make md-nits
run: |
sudo gem install mdl
make md-nits
# This checks that we use ANSI C language syntax and semantics.
# We are not as strict with libraries, but rather adapt to what's
# expected to be available in a certain version of each platform.
@ -88,12 +87,14 @@ jobs:
run: git submodule update --init --depth 1 fuzz/corpora
- name: localegen
run: sudo locale-gen tr_TR.UTF-8
- name: cmocka
run: sudo apt-get -y install libcmocka-dev
- name: fipsvendor
# Make one fips build use a customized FIPS vendor
run: echo "FIPS_VENDOR=CI" >> VERSION.dat
- name: config
# enable-quic is on by default, but we leave it here to check we're testing the explicit enable somewhere
run: CC=gcc ./config --strict-warnings --banner=Configured enable-demos enable-h3demo enable-ec_explicit_curves enable-sslkeylog enable-fips enable-quic enable-lms && perl configdata.pm --dump
run: CC=gcc ./config --strict-warnings --banner=Configured enable-demos enable-h3demo enable-ec_explicit_curves enable-sslkeylog enable-fips enable-quic enable-lms enable-unit-tests && perl configdata.pm --dump
- name: make
run: make -s -j4
- name: get cpu info
@ -460,6 +461,40 @@ jobs:
path: artifacts.tar.gz
if-no-files-found: ignore
fuzz_tests_mfail:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
- name: Adjust ASLR for sanitizer
run: sudo sysctl -w vm.mmap_rnd_bits=28
- name: config
run: |
./config --strict-warnings --banner=Configured --debug \
-DPEDANTIC -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION \
enable-asan enable-ec_explicit_curves enable-ubsan \
enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 \
enable-weak-ssl-ciphers enable-nextprotoneg
perl configdata.pm --dump
- name: make
run: make -s -j4
- name: make test (fuzz with mfail)
env:
OSSL_FUZZ_TEST_BUDGET: 1200
OSSL_FUZZ_TEST_JOBS: 4
run: .github/workflows/make-test OPENSSL_TEST_RAND_ORDER=0 TESTS="test_fuzz*"
- name: save artifacts
if: success() || failure()
uses: actions/upload-artifact@v5
with:
name: "ci@fuzz_tests_mfail"
path: artifacts.tar.gz
if-no-files-found: ignore
memory_sanitizer:
runs-on: ubuntu-latest
steps:
@ -629,95 +664,6 @@ jobs:
name: "ci@legacy"
path: artifacts.tar.gz
# out-of-source-and-install checks multiple things at the same time:
# - That building, testing and installing works from an out-of-source
# build tree
# - That building, testing and installing works with a read-only source
# tree
out-of-readonly-source-and-install-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
path: ./source
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
working-directory: ./source
- name: make source read-only
run: chmod -R a-w ./source
- name: create build and install directories
run: |
mkdir ./build
mkdir ./install
- name: config
run: |
../source/config --banner=Configured enable-demos enable-h3demo enable-fips enable-lms enable-quic enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
perl configdata.pm --dump
working-directory: ./build
- name: make
run: make -s -j4
working-directory: ./build
- name: get cpu info
run: |
cat /proc/cpuinfo
./util/opensslwrap.sh version -c
working-directory: ./build
- name: make test
run: ../source/.github/workflows/make-test
working-directory: ./build
- name: save artifacts
if: success() || failure()
uses: actions/upload-artifact@v5
with:
name: "ci@out-of-readonly-source-and-install-ubuntu"
path: build/artifacts.tar.gz
- name: make install
run: make install
working-directory: ./build
out-of-readonly-source-and-install-macos:
runs-on: macos-15
steps:
- uses: actions/checkout@v6
with:
path: ./source
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
working-directory: ./source
- name: make source read-only
run: chmod -R a-w ./source
- name: create build and install directories
run: |
mkdir ./build
mkdir ./install
- name: config
run: |
../source/config --banner=Configured enable-fips enable-lms enable-demos enable-h3demo enable-quic enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
perl configdata.pm --dump
working-directory: ./build
- name: make
run: make -s -j4
working-directory: ./build
- name: get cpu info
run: |
sysctl machdep.cpu
./util/opensslwrap.sh version -c
working-directory: ./build
- name: make test
run: ../source/.github/workflows/make-test
working-directory: ./build
- name: save artifacts
if: success() || failure()
uses: actions/upload-artifact@v5
with:
name: "ci@out-of-readonly-source-and-install-macos-15"
path: build/artifacts.tar.gz
- name: make install
run: make install
working-directory: ./build
external-tests-misc:
runs-on: ubuntu-latest
steps:
@ -729,10 +675,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -yq install bison gettext keyutils ldap-utils libldap2-dev libkeyutils-dev python3 python3-paste python3-pyrad slapd tcsh python3-virtualenv virtualenv python3-kdcproxy gdb libtls-dev wget gpg
- name: install cpanm and Test2::V0 for gost_engine testing
uses: perl-actions/install-with-cpanm@10d60f00b4073f484fc29d45bfbe2f776397ab3d # v1.7
with:
install: Test2::V0
- name: setup hostname workaround
run: sudo hostname localhost
- name: config
@ -746,8 +688,9 @@ jobs:
run: |
cat /proc/cpuinfo
./util/opensslwrap.sh version -c
- name: test external gost-engine
run: make test TESTS="test_external_gost_engine"
- name: test failure when selecting non-existing test case
run: |
! make test TESTS="test_external_gost_engine"
- name: test external krb5
run: make test TESTS="test_external_krb5"
- name: test external tlsfuzzer

View file

@ -47,10 +47,10 @@ jobs:
MATRIX=$(cat << EOF
[{
"branch": "master",
"extra_config": "enable-fips enable-tfo enable-lms enable-crypto-mdebug enable-allocfail-tests"
"extra_config": "enable-fips enable-tfo enable-lms enable-crypto-mdebug enable-unit-tests"
}, {
"branch": "openssl-4.0",
"extra_config": "enable-fips enable-tfo enable-lms enable-crypto-mdebug enable-allocfail-tests"
"extra_config": "enable-fips enable-tfo enable-lms enable-crypto-mdebug"
},{
"branch": "openssl-3.6",
"extra_config": "no-afalgeng enable-fips enable-tfo enable-lms"
@ -93,7 +93,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -yq install lcov
sudo apt-get -yq install bison gettext keyutils ldap-utils libldap2-dev libkeyutils-dev python3 python3-paste python3-pyrad slapd tcsh python3-virtualenv virtualenv python3-kdcproxy
sudo apt-get -yq install bison gettext keyutils ldap-utils libcmocka-dev libldap2-dev libkeyutils-dev python3 python3-paste python3-pyrad slapd tcsh python3-virtualenv virtualenv python3-kdcproxy
- name: install Test2::V0 for gost_engine testing
uses: perl-actions/install-with-cpanm@10d60f00b4073f484fc29d45bfbe2f776397ab3d #v1.7
with:

View file

@ -7,13 +7,35 @@
name: Cross Compile
on: [pull_request, push]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read
jobs:
cross-compilation:
# Run the full test suite on push, and on pull requests labelled with
# 'extended tests'. Other pull requests only run the EVP tests.
env:
EXTENDED: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'extended tests') }}
strategy:
fail-fast: false
matrix:
@ -211,19 +233,19 @@ jobs:
cat /proc/cpuinfo
QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }} ./util/opensslwrap.sh version -c
- name: make all tests
if: github.event_name == 'push' && matrix.platform.tests == ''
if: env.EXTENDED == 'true' && matrix.platform.tests == ''
run: |
.github/workflows/make-test \
TESTS="-test_afalg" \
QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
- name: make some tests
if: github.event_name == 'push' && matrix.platform.tests != 'none' && matrix.platform.tests != ''
if: env.EXTENDED == 'true' && matrix.platform.tests != 'none' && matrix.platform.tests != ''
run: |
.github/workflows/make-test \
TESTS="${{ matrix.platform.tests }} -test_afalg" \
QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
- name: make evp tests
if: github.event_name == 'pull_request' && matrix.platform.tests != 'none'
if: env.EXTENDED != 'true' && matrix.platform.tests != 'none'
run: |
.github/workflows/make-test \
TESTS="test_evp*" \

View file

@ -6,7 +6,16 @@
# https://www.openssl.org/source/license.html
name: FIPS Check and ABIDIFF
on: [pull_request]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read

View file

@ -1,48 +0,0 @@
# Copyright 2021-2026 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
name: "Make release"
on:
push:
tags:
- "openssl-*"
permissions: {}
jobs:
release:
runs-on: "releaser"
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
fetch-depth: 1
ref: ${{ github.ref_name }}
github-server-url: "https://github.openssl.org/"
repository: "openssl/openssl"
token: ${{ secrets.GHE_TOKEN }}
path: ${{ github.ref_name }}
persist-credentials: false
- name: "Prepare assets"
env:
SIGNING_KEY_UID: ${{ vars.signing_key_uid }}
run: |
cd "$GITHUB_REF_NAME"
./util/mktar.sh
mkdir -p assets && mv "$GITHUB_REF_NAME.tar.gz" assets/ && cd assets
openssl sha1 -r "$GITHUB_REF_NAME.tar.gz" > "$GITHUB_REF_NAME.tar.gz.sha1"
openssl sha256 -r "$GITHUB_REF_NAME.tar.gz" > "$GITHUB_REF_NAME.tar.gz.sha256"
gpg -u "$SIGNING_KEY_UID" -o "$GITHUB_REF_NAME.tar.gz.asc" -sba "$GITHUB_REF_NAME.tar.gz"
- name: "Create release"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
VERSION=$(echo "$GITHUB_REF_NAME" | cut -d "-" -f 2-)
PRE_RELEASE=$([[ "$GITHUB_REF_NAME" =~ alpha|beta ]] && echo "-p" || echo "")
NOTES=$(curl -s "https://api.openssl.org/release-metadata/news/?version=$VERSION&capture_title=False")
gh release create "$GITHUB_REF_NAME" $PRE_RELEASE -t "OpenSSL $VERSION" -d --notes "$NOTES" -R "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME/assets/"*

View file

@ -7,7 +7,25 @@
# Jobs run per pull request submission
name: Perl-minimal-checker CI
on: [pull_request, push]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read

View file

@ -10,7 +10,16 @@
name: Provider compatibility for PRs
on: [pull_request]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read

View file

@ -10,6 +10,14 @@ name: Cross Compile for RISC-V Extensions
on:
pull_request:
types: [opened, reopened, edited, synchronize]
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
schedule:
- cron: '35 02 * * *'

View file

@ -7,7 +7,25 @@
# Jobs run per pull request submission
name: Run-checker CI
on: [pull_request, push]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read

View file

@ -7,7 +7,16 @@
name: Coding style validation
on: [pull_request]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
jobs:
check-style:

View file

@ -7,7 +7,26 @@
name: Windows GitHub CI
on: [pull_request, push]
on:
pull_request:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
push:
paths-ignore:
- 'doc/**'
- '*.md'
- '*.pod'
- 'README*'
- 'funding.json'
- 'LICENSE.txt'
- 'VERSION.dat'
permissions:
contents: read
@ -190,6 +209,59 @@ jobs:
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake test VERBOSE_FAILURE=yes HARNESS_JOBS=4
unit-tests:
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: checkout fuzz/corpora submodule
run: git submodule update --init --depth 1 fuzz/corpora
- name: install jom
if: github.repository == 'openssl/openssl'
run: |
mkdir C:\jom
Invoke-WebRequest -Uri "https://openssl-library.org/ci-deps/jom-1.1.7.exe" -OutFile C:\jom\jom.exe
$expected = (Get-Content "$env:GITHUB_WORKSPACE\.github\ci-deps.json" -Raw | ConvertFrom-Json).'jom-1.1.7.exe'
$actual = (Get-FileHash C:\jom\jom.exe -Algorithm SHA256).Hash
if ($actual -ne $expected) { throw "SHA256 mismatch for jom.exe (expected $expected, got $actual)" }
"C:\jom" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install jom (forks)
if: github.repository != 'openssl/openssl'
run: |
mkdir C:\jom
Invoke-WebRequest -Uri "https://download.qt.io/official_releases/jom/jom_1_1_7.zip" -OutFile C:\jom\jom.zip
Expand-Archive -Path C:\jom\jom.zip -DestinationPath C:\jom
"C:\jom" | Out-File -FilePath "$env:GITHUB_PATH" -Append
- name: install cmocka and detours via vcpkg
shell: pwsh
run: |
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install cmocka:x64-windows-static-md detours:x64-windows-static-md
"VCPKG_INST=$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: prepare the build directory
run: mkdir _build
- name: config
working-directory: _build
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
perl ..\Configure VC-WIN64A --banner=Configured --strict-warnings no-makedepend no-asm enable-unit-tests ^
--with-cmocka-include=%VCPKG_INST%\include --with-cmocka-lib=%VCPKG_INST%\lib ^
--with-detours-include=%VCPKG_INST%\include --with-detours-lib=%VCPKG_INST%\lib
perl configdata.pm --dump
- name: build
working-directory: _build
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
jom /j4 /S
- name: test
working-directory: _build
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
jom test VERBOSE=1 TESTS=test_unit
minimal:
runs-on: windows-2022
steps:

View file

@ -31,6 +31,58 @@ OpenSSL Releases
### Changes between 4.0 and 4.1 [xx XXX xxxx]
* Fixed TLS 1.3 external PSK connections being wrongly rejected when
the client sets a non-empty session ID context.
*Viktor Dukhovni*
* Fixed a TLS 1.3 server with no session ID context to accept external PSK
connections and to stop issuing unusable session tickets.
*Viktor Dukhovni*
* Added AVX512 optimized SHAKE x4 operations for ML-DSA on `x86_64`.
*Marcel Cornu and Tomasz Kantecki*
* EC key point format simplification.
The point conversion form (compressed, uncompressed, or hybrid)
is now a single value on the `EC_GROUP` and round-trips
unchanged through import and export of `EC_KEY` objects.
Freshly generated keys have their public point encoded in
uncompressed form. A `point-format` supplied at key generation
time via `OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT` is
validated (an invalid value is rejected) but otherwise ignored
on the generated key. EC parameter generation continues to
honour the requested form on the group's generator; imported
keys keep their form.
The `ec_point_formats` extension no longer affects TLS 1.2
X.509 certificate selection or acceptance. OpenSSL now
accepts an EC certificate in any point form it can decode,
and sends any EC certificate it has regardless of point form.
TLS 1.3 disregards the extension entirely.
The RFC 4492/8422 section 5.1.2 requirement that the peer's
point-format list contain "uncompressed" is now enforced on
both sides (previously client-only), and only when an ECC
TLS 1.2 ciphersuite is negotiated -- a missing "uncompressed"
is ignored under TLS 1.3 or with a non-ECC cipher.
*Viktor Dukhovni*
* Added unit tests setup activated via `enable-unit-tests` option. This works
only on platforms with ld `--wrap` support (Linux, BSD).
*Jakub Zelenka*
* Deprecated the `enable-unit-test` configure option and the
`SSL_test_functions()` function. Both will be removed in OpenSSL 5.0.
*Jakub Zelenka*
* Added -testmode option for `s_time` app.
*Jakub Zelenka*
@ -41,7 +93,7 @@ OpenSSL Releases
*Adriano Sela Aviles*
* SubjectPublicKeyInfo blobs whose AlgorithmIdentifier uses id-RSAES-OAEP
(NID_rsaesOaep, 1.2.840.113549.1.1.7) with a plain RSAPublicKey body
(`NID_rsaesOaep`, 1.2.840.113549.1.1.7) with a plain RSAPublicKey body
are now decoded as RSA keys. This is required for interoperability
with TPM 1.2 Endorsement Key certificates per TCG Credential Profiles
V1.2 section 3.2.7. The OAEP AlgorithmIdentifier parameters are not
@ -64,6 +116,17 @@ OpenSSL Releases
*Jakub Zelenka*
* Windows-on-Itanium (VC-WIN64I) support was dropped - the Itanium
architecture has been discontinued and the platform is no longer
supported or tested.
*Bob Beck*
* Windows CE support was dropped - Windows CE has been unsupported since
2018 and does not have a modern C99 toolchain.
*Bob Beck*
* Improved DTLS handshake robustness under UDP reordering by buffering and
replaying early ChangeCipherSpec (CCS) records at the expected state.
@ -78,6 +141,14 @@ OpenSSL Releases
*Bob Beck*
* `ASN1_STRING_set()` and `ASN1_STRING_length()` have been
deprecated. The replacement functions `ASN1_STRING_set_data()` or
`ASN1_STRING_set_string()`, and `ASN1_STRING_length_ex()` should be
used in their place. This prepares the ASN1_STRING type to support
modern size_t length values in the future.
*Bob Beck*
* `EVP_CIPHER_CTX_get_num()` and `EVP_CIPHER_CTX_set_num()' have been deprecated.
Refer to ossl-migration-guide(7) for more info.
@ -119,6 +190,12 @@ OpenSSL Releases
*Bob Beck*
* Fixed X.509 verification of certificate chains that use DSA signatures
with SHA-384 or SHA-512 by registering `dsa_with_SHA384` and
`dsa_with_SHA512` in the signature-algorithm cross-reference table.
*John Claus*
* Added AVX2 optimized ML-DSA NTT operations on `x86_64`.
*Marcel Cornu and Tomasz Kantecki*
@ -194,6 +271,11 @@ OpenSSL Releases
*Timo Keller*
* Added `EVP_KDF_CTX_get0_kdf()` and `EVP_KDF_CTX_get1_kdf()` functions
as a replacement for the now deprecated `EVP_KDF_CTX_kdf()`.
*Leon Timmermans*
* Add `FIPS_mode()` as a convenience define to
`EVP_default_properties_is_fips_enabled(NULL)`, which is
shorthand to check whether the `fips=yes` property is currently enabled
@ -1268,7 +1350,9 @@ OpenSSL 4.0
*Tomáš Mráz*
* Removed deprecated functions `ERR_get_state()`, `ERR_remove_state()`
and `ERR_remove_thread_state()`. The `ERR_STATE` object is now always opaque.
and `ERR_remove_thread_state()`, as well as the `ERR_FLAG_MARK`,
`ERR_FLAG_CLEAR` and `ERR_NUM_ERRORS` macros. The `ERR_STATE` object is now
always opaque.
<!-- https://github.com/openssl/openssl/pull/30005 -->
*Tomáš Mráz*
@ -4091,7 +4175,7 @@ breaking changes, and mappings for the large list of deprecated functions.
* Fixed a bug in the function `OCSP_basic_verify` that verifies the signer
certificate on an OCSP response. The bug caused the function in the case
where the (non-default) flag OCSP_NOCHECKS is used to return a postivie
where the (non-default) flag OCSP_NOCHECKS is used to return a positive
response (meaning a successful verification) even in the case where the
response signing certificate fails to verify.
@ -19889,7 +19973,7 @@ s-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
The new configuration file reading functions are:
NCONF_new, NCONF_free, NCONF_load, NCONF_load_fp, NCONF_load_bio,
NCONF_get_section, NCONF_get_string, NCONF_get_numbre
NCONF_get_section, NCONF_get_string, NCONF_get_number
NCONF_default, NCONF_WIN32

View file

@ -80,7 +80,37 @@ guidelines:
git push -f [<repository> [<branch>]]
```
2. All source files should start with the following text (with
2. Similarly, if a non-trivial portion of a contribution was created
using an AI tool, you must declare which agent and model were used.
This is done by adding `Assisted-by: {agent}:{model}` below the commit
message:
```
One-line summary of change with AI-generated portions
Assisted-by: Claude:claude-sonnet-4-6
```
Multiple Assisted-by trailers can be included if multiple tools were used:
```
Assisted-by: Claude:claude-sonnet-4-6
Assisted-by: ChatGPT:gpt-4o
Assisted-by: GitHub Copilot:gpt-4.1
```
You will need to have signed a v1.1 or later CLA in order to
include AI-generated content in your contribution. CLAs signed
after June 2026 will have the requisite clauses.
Consult the [OpenSSL AI Code and Documentation Contribution
Policy] if an AI model assisted with the creation of your
contribution.
[OpenSSL AI Code and Documentation Contribution
Policy]: <https://openssl-library.org/policies/general/ai-policy/>
3. All source files should start with the following text (with
appropriate comment characters at the start of each line and the
year(s) updated):
@ -93,12 +123,14 @@ guidelines:
https://www.openssl.org/source/license.html
```
3. Patches should be as current as possible; expect to have to rebase
4. Patches should be as current as possible; expect to have to rebase
often. We do not accept merge commits, you will have to remove them
(usually by rebasing) before it will be acceptable.
4. Code provided should follow our [coding style] and [documentation policy]
and compile without warnings.
5. Code provided should follow our [coding style](STYLE.md) and
[documentation policy](DOCUMENTATION.md) and compile without warnings when
using a --strict-warnings configuration.
Consistent formatting is enforced by using `clang-format` with configuration
stored in [.clang-format](.clang-format). OpenSSL uses `WebKit` style.
You can configure git pre-commit to automatically reformat your code with
@ -112,19 +144,16 @@ guidelines:
Clean builds via GitHub Actions are required. They are started automatically
whenever a PR is created or updated by committers.
[coding style]: https://openssl-library.org/policies/technical/coding-style/
[documentation policy]: https://openssl-library.org/policies/technical/documentation-policy/
5. When at all possible, code contributions should include tests. These can
6. When at all possible, code contributions should include tests. These can
either be added to an existing test, or completely new. Please see
[test/README.md](test/README.md) for information on the test framework.
6. New features or changed functionality must include
7. New features or changed functionality must include
documentation. Please look at the `.pod` files in `doc/man[1357]` for
examples of our style. Run `make doc-nits` to make sure that your
documentation changes are clean.
7. For user visible changes (API changes, behaviour changes, ...),
8. For user visible changes (API changes, behaviour changes, ...),
consider adding a note in [CHANGES.md](CHANGES.md).
This could be a summarising description of the change, and could
explain the grander details.
@ -135,10 +164,10 @@ guidelines:
with a specific release without having to sift through the higher
noise ratio in git-log.
8. Guidelines on how to integrate error output of new crypto library modules
9. Guidelines on how to integrate error output of new crypto library modules
can be found in [crypto/err/README.md](crypto/err/README.md).
9. Once your Pull Request gets to the stage of being reviewed fixup commits
10. Once your Pull Request gets to the stage of being reviewed fixup commits
should be used where possible. Fixup commits are squashed when the PR is
finally merged. Fixup commits are done in the following way:
@ -161,11 +190,11 @@ guidelines:
git log
```
10. If a Pull Request addresses an [issue](https://github.com/openssl/openssl/issues/)
11. If a Pull Request addresses an [issue](https://github.com/openssl/openssl/issues/)
the commit should include the line:
```
Fixes #XXXXX
Fixes: LINK
```
where XXXXX is the issue number.
where LINK is the https link to the issue in github.

View file

@ -61,70 +61,6 @@ sub vc_win32_info {
return $vc_win32_info;
}
my $vc_wince_info = {};
sub vc_wince_info {
unless (%$vc_wince_info) {
# sanity check
$die->('%OSVERSION% is not defined') if (!defined(env('OSVERSION')));
$die->('%PLATFORM% is not defined') if (!defined(env('PLATFORM')));
$die->('%TARGETCPU% is not defined') if (!defined(env('TARGETCPU')));
#
# Idea behind this is to mimic flags set by eVC++ IDE...
#
my $wcevers = env('OSVERSION'); # WCENNN
my $wcevernum;
my $wceverdotnum;
if ($wcevers =~ /^WCE([1-9])([0-9]{2})$/) {
$wcevernum = "$1$2";
$wceverdotnum = "$1.$2";
} else {
$die->('%OSVERSION% value is insane');
$wcevernum = "{unknown}";
$wceverdotnum = "{unknown}";
}
my $wcecdefs = "-D_WIN32_WCE=$wcevernum -DUNDER_CE=$wcevernum"; # -D_WIN32_WCE=NNN
my $wcelflag = "/subsystem:windowsce,$wceverdotnum"; # ...,N.NN
my $wceplatf = env('PLATFORM');
$wceplatf =~ tr/a-z0-9 /A-Z0-9_/;
$wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
my $wcetgt = env('TARGETCPU'); # just shorter name...
SWITCH: for($wcetgt) {
/^X86/ && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
$wcelflag.=" /machine:X86"; last; };
/^ARMV4[IT]/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
$wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
$wcecdefs.=" -QRarch4T -QRinterwork-return";
$wcelflag.=" /machine:THUMB"; last; };
/^ARM/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
$wcelflag.=" /machine:ARM"; last; };
/^MIPSIV/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
$wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
$wcelflag.=" /machine:MIPSFPU"; last; };
/^MIPS16/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
$wcecdefs.=" -DMIPSII -QMmips16";
$wcelflag.=" /machine:MIPS16"; last; };
/^MIPSII/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
$wcecdefs.=" -QMmips2";
$wcelflag.=" /machine:MIPS"; last; };
/^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
$wcelflag.=" /machine:MIPS"; last; };
/^SH[0-9]/ && do { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_ -DSHx";
$wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
$wcelflag.=" /machine:$wcetgt"; last; };
{ $wcecdefs.=" -D$wcetgt -D_${wcetgt}_";
$wcelflag.=" /machine:$wcetgt"; last; };
}
$vc_wince_info = { cppflags => $wcecdefs,
lflags => $wcelflag };
}
return $vc_wince_info;
}
# Helper functions for the VMS configs
my $vms_info = {};
sub vms_info {
@ -970,7 +906,6 @@ my %targets = (
perlasm_scheme => 'void',
},
"linux64-sparcv9" => {
# GCC 3.1 is a requirement
inherit_from => [ "linux-generic64" ],
cflags => add("-m64 -mcpu=ultrasparc"),
cxxflags => add("-m64 -mcpu=ultrasparc"),
@ -1499,7 +1434,7 @@ my %targets = (
#### Visual C targets
#
# Win64 targets, WIN64I denotes IA-64/Itanium and WIN64A - AMD64
# Win64 target, WIN64A denotes AMD64
#
# Note about /wd4090, disable warning C4090. This warning returns false
# positives in some situations. Disabling it altogether masks both
@ -1607,17 +1542,6 @@ my %targets = (
}),
bn_ops => add("SIXTY_FOUR_BIT"),
},
"VC-WIN64I" => {
inherit_from => [ "VC-WIN64-common" ],
AS => "ias",
ASFLAGS => "-d debug",
asoutflag => "-o ",
sys_id => "WIN64I",
uplink_arch => 'ia64',
asm_arch => 'ia64',
perlasm_scheme => "ias",
multilib => "-ia64",
},
"VC-WIN64A" => {
inherit_from => [ "VC-WIN64-common" ],
AS => sub { vc_win64a_info()->{AS} },
@ -1645,53 +1569,6 @@ my %targets = (
# some installation path heuristics in windows-makefile.tmpl...
build_scheme => add("VC-WOW", { separator => undef }),
},
"VC-CE" => {
inherit_from => [ "VC-common" ],
CFLAGS => add(picker(debug => "/Od",
release => "/O1i")),
CPPDEFINES => picker(debug => [ "DEBUG", "_DEBUG" ]),
LDFLAGS => add("/nologo /opt:ref"),
cflags =>
combine('/GF /Gy',
sub { vc_wince_info()->{cflags}; },
sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
? ($disabled{shared} ? " /MT" : ($disabled{"static-vcruntime"} ? " /MD" : ""))
: " /MC"; }),
cppflags => sub { vc_wince_info()->{cppflags}; },
lib_defines => add("NO_CHMOD", "OPENSSL_SMALL_FOOTPRINT"),
lib_cppflags => sub { vc_wince_info()->{cppflags}; },
includes =>
add(combine(sub { defined(env('WCECOMPAT'))
? '$(WCECOMPAT)/include' : (); },
sub { defined(env('PORTSDK_LIBPATH'))
? '$(PORTSDK_LIBPATH)/../../include'
: (); })),
lflags => add(combine(sub { vc_wince_info()->{lflags}; },
sub { defined(env('PORTSDK_LIBPATH'))
? "/entry:mainCRTstartup" : (); })),
sys_id => "WINCE",
bn_ops => add("BN_LLONG"),
ex_libs => add(sub {
my @ex_libs = ();
push @ex_libs, 'ws2.lib' unless $disabled{sock};
push @ex_libs, 'crypt32.lib';
if (defined(env('WCECOMPAT'))) {
my $x = '$(WCECOMPAT)/lib';
if (-f "$x/env('TARGETCPU')/wcecompatex.lib") {
$x .= '/$(TARGETCPU)/wcecompatex.lib';
} else {
$x .= '/wcecompatex.lib';
}
push @ex_libs, $x;
}
push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
if (defined(env('PORTSDK_LIBPATH')));
push @ex_libs, '/nodefaultlib coredll.lib corelibc.lib'
if (env('TARGETCPU') =~ /^X86|^ARMV4[IT]/);
return join(" ", @ex_libs);
}),
},
#### MinGW
"mingw-common" => {
inherit_from => [ 'BASE_unix' ],
@ -1703,7 +1580,7 @@ my %targets = (
cppflags => combine("-DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN",
threads("-D_MT")),
lib_cppflags => "-DL_ENDIAN",
ex_libs => add("-lws2_32 -lgdi32 -lcrypt32"),
ex_libs => add("-lws2_32 -lgdi32 -lcrypt32 -lbcrypt"),
thread_scheme => "winthreads",
dso_scheme => "win32",
shared_target => "mingw-shared",

View file

@ -11,6 +11,7 @@
our $makedepcmd = platform->makedepcmd();
sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
sub run_on_windows { $^O =~ /^(?:cygwin|msys|MSWin32)/ }
# Shared AIX support is special. We put libcrypto[64].so.ver into
# libcrypto.a and use libcrypto_a.a as static one, unless using
@ -503,6 +504,9 @@ BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
'$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
CMOCKA_LIBS={- $config{cmocka_libs} // '' -}
DETOURS_LIBS={- $config{detours_libs} // '' -}
# CPPFLAGS_Q is used for one thing only: to build up buildinf.h
CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
$cppflags2 =~ s|([\\"])|\\$1|g;
@ -656,8 +660,8 @@ clean: libclean ## Clean the workspace, keep the configuration
-o -path './python-ecdsa' \
-o -path './tlsfuzzer' \
-o -path './tlslite-ng' \
-o -path './wycheproof' \
-prune \) \
-o -path './wycheproof' \) \
-prune \
-o \! -type d \
\( -name '*{- platform->depext() -}' \
-o -name '*{- platform->objext() -}' \
@ -1579,12 +1583,24 @@ EOF
my $section = $1;
my $name = uc basename($args{src}, ".$section");
my $pod = $gen0;
return <<"EOF";
if ($config{manpage_format} eq "mdoc") {
return <<"EOF";
$args{src}: $pod
pod2mdoc -n $name -s $section\$(MANSUFFIX) \\
-d \$(RELEASE_DATE) \\
$pod >\$\@
EOF
} elsif ($config{manpage_format} eq "roff") {
return <<"EOF";
$args{src}: $pod
pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\
--date=\$(RELEASE_DATE) --release=\$(VERSION) \\
$pod >\$\@
EOF
} else {
die "Unhandled manpage format: $config{manpage_format}";
}
} elsif (platform->isdef($args{src})) {
#
# Linker script-ish generator
@ -1895,13 +1911,27 @@ $import: $full
EOF
}
}
$recipe .= <<"EOF";
if (!run_on_windows()) {
$recipe .= <<"EOF";
$full: $fulldeps
\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
-o $full$shared_def \\
$fullobjs \\
$linklibs \$(LIB_EX_LIBS)
EOF
} else {
$recipe .= <<"EOF";
$full: $fulldeps
\$(file >\$@.lst, \\
$fullobjs \\
)
\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
-o $full$shared_def \\
@\$@.lst \\
$linklibs \$(LIB_EX_LIBS)
rm -f \$@.lst
EOF
}
if (windowsdll()) {
$recipe .= <<"EOF";
rm -f apps/$full
@ -2006,6 +2036,15 @@ EOF
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
}
}
my $wrapflags = '';
if (defined $unified_info{wraps}->{$args{bin}}) {
$wrapflags = ' ' . join(' ',
map { "-Wl,--wrap=$_" }
@{$unified_info{wraps}->{$args{bin}}});
}
my $utlibs = $unified_info{unit_test_libs}->{$args{bin}};
$utlibs = $utlibs ne '' ? ' ' . $utlibs : '' if defined $utlibs;
$utlibs //= '';
my $linkflags = join("", map { $_." " } @linkdirs);
my $linklibs = join("", map { $_." " } @linklibs);
my $cmd = '$(CC)';
@ -2023,10 +2062,10 @@ EOF
return <<"EOF";
$bin: $deps
rm -f $bin
\$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
\$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS)$wrapflags \\
-o $bin \\
$objs \\
$linklibs\$(BIN_EX_LIBS)
$linklibs\$(BIN_EX_LIBS)$utlibs
EOF
}
sub in2script {

View file

@ -380,6 +380,9 @@ BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
'$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
CMOCKA_LIBS={- $config{cmocka_libs} // '' -}
DETOURS_LIBS={- $config{detours_libs} // '' -}
# CPPFLAGS_Q is used for one thing only: to build up buildinf.h
CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
$cppflags2 =~ s|([\\"])|\\$1|g;
@ -1001,11 +1004,14 @@ EOF
my $ress = join($target{ld_resp_delim}, @ress);
my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
my $deps = join(" ", @objs, @ress, @deps);
my $utlibs = $unified_info{unit_test_libs}->{$args{bin}};
$utlibs = (defined $utlibs && $utlibs ne '')
? "$utlibs$target{ld_resp_delim}" : '';
return <<"EOF";
$bin: $deps
IF EXIST $bin.manifest DEL /F /Q $bin.manifest
\$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)$target{ldresflag}$target{ldresflag}$ress
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$utlibs$linklibs\$(BIN_EX_LIBS)$target{ldresflag}$target{ldresflag}$ress
<<
IF EXIST $bin.manifest \\
\$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin

111
Configure
View file

@ -27,7 +27,7 @@ use OpenSSL::config;
my $orig_death_handler = $SIG{__DIE__};
$SIG{__DIE__} = \&death_handler;
my $usage="Usage: Configure [no-<feature> ...] [enable-<feature> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]thread-pool] [[no-]default-thread-pool] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] [--help] os/compiler[:flags]\n";
my $usage="Usage: Configure [no-<feature> ...] [enable-<feature> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]thread-pool] [[no-]default-thread-pool] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] [--manpage-format={roff,mdoc}] [--help] os/compiler[:flags]\n";
my $banner = <<"EOF";
@ -295,6 +295,7 @@ my $dofile = abs2rel(catfile($srcdir, "util/dofile.pl"));
my $local_config_envname = 'OPENSSL_LOCAL_CONFIG_DIR';
$config{manpage_format} = "roff";
$config{sourcedir} = abs2rel($srcdir, $blddir);
$config{builddir} = abs2rel($blddir, $blddir);
# echo -n 'holy hand grenade of antioch' | openssl sha256
@ -577,6 +578,7 @@ my @disablables_features = (
"ubsan",
"ui-console",
"unit-test",
"unit-tests",
"uplink",
"weak-ssl-ciphers",
"zlib-dynamic",
@ -654,6 +656,7 @@ our %disabled = ( # "what" => "comment"
"trace" => "default",
"ubsan" => "default",
"unit-test" => "default",
"unit-tests" => "default",
"weak-ssl-ciphers" => "default",
"zlib" => "default",
"zlib-dynamic" => "default",
@ -723,7 +726,7 @@ my @disable_cascades = (
"stdio" => [ "apps", "egd" ],
"apps" => [ "tests" ],
"tests" => [ "external-tests" ],
"tests" => [ "external-tests", "unit-tests" ],
"comp" => [ "zlib", "brotli", "zstd" ],
"sm3" => [ "sm2" ],
sub { !$disabled{"unit-test"} } => [ "heartbeats" ],
@ -1042,6 +1045,10 @@ while (@argvcopy)
{
$config{build_type} = "release";
}
elsif (/^--manpage-format=(mdoc|roff)$/)
{
$config{manpage_format}="$1";
}
elsif (/^--pgo$/)
{
$config{build_type} = "pgo";
@ -1115,6 +1122,22 @@ while (@argvcopy)
{
$withargs{fuzzer_include}=$1;
}
elsif (/^--with-cmocka-lib=(.*)$/)
{
$withargs{cmocka_lib}=$1;
}
elsif (/^--with-cmocka-include=(.*)$/)
{
$withargs{cmocka_include}=$1;
}
elsif (/^--with-detours-lib=(.*)$/)
{
$withargs{detours_lib}=$1;
}
elsif (/^--with-detours-include=(.*)$/)
{
$withargs{detours_include}=$1;
}
elsif (/^--with-rand-seed=(.*)$/)
{
foreach my $x (split(m|,|, $1))
@ -1671,8 +1694,13 @@ unless ($disabled{asan} || defined $detected_sanitizers{asan}) {
$config{target} =~ /^VC-/ ? "/fsanitize=address" : "-fsanitize=address";
}
my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
unless ($disabled{ubsan} || defined $detected_sanitizers{ubsan}) {
push @{$config{cflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all", "-DPEDANTIC";
if ($predefined_C{__clang__}) {
push @{$config{cflags}}, "-fno-sanitize=function";
}
}
unless ($disabled{msan} || defined $detected_sanitizers{msan}) {
@ -1752,7 +1780,6 @@ if ($target{sys_id} ne "")
push @{$config{openssl_sys_defines}}, "OPENSSL_SYS_$target{sys_id}";
}
my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
my %predefined_CXX = $config{CXX}
? compiler_predefined($config{CROSS_COMPILE}.$config{CXX})
: ();
@ -1913,6 +1940,29 @@ unless ($disabled{winstore}) {
push @{$config{openssl_other_defines}}, "OPENSSL_NO_KTLS" if ($disabled{ktls});
# Keywords accepted in a build.info UNIT_TEST[] link set.
my @unit_test_keywords = qw(cmocka detours);
unless ($disabled{"unit-tests"}) {
if ($target =~ /^linux/ || $target =~ /^BSD/) {
$config{cmocka_includes} =
$withargs{cmocka_include} ? [$withargs{cmocka_include}] : [];
$config{cmocka_libs} = $withargs{cmocka_lib}
? "-L$withargs{cmocka_lib} -lcmocka" : "-lcmocka";
} elsif ($target =~ /^VC-/) {
$config{cmocka_includes} =
$withargs{cmocka_include} ? [$withargs{cmocka_include}] : [];
$config{cmocka_libs} = $withargs{cmocka_lib}
? "/LIBPATH:$withargs{cmocka_lib} cmocka.lib" : "cmocka.lib";
$config{detours_includes} =
$withargs{detours_include} ? [$withargs{detours_include}] : [];
$config{detours_libs} = $withargs{detours_lib}
? "/LIBPATH:$withargs{detours_lib} detours.lib" : "detours.lib";
} else {
disable('no-unit-test-support', 'unit-tests');
}
}
# Get the extra flags used when building shared libraries and modules. We
# do this late because some of them depend on %disabled.
@ -2137,6 +2187,8 @@ if ($builder eq "unified") {
my %includes = ();
my %defines = ();
my %depends = ();
my %unit_tests = ();
my %wraps = ();
my %generate = ();
my %imagedocs = ();
my %htmldocs = ();
@ -2392,6 +2444,16 @@ if ($builder eq "unified") {
\$attributes{depends}, $+{ATTRIBS},
tokenize($expand_variables->($+{VALUE})))
if !@skip || $skip[$#skip] > 0; },
qr/^\s* UNIT_TEST ${index_re} \s* = \s* ${value_re} \s* $/x
=> sub { $push_to->(\%unit_tests, $expand_variables->($+{INDEX}),
undef, undef,
tokenize($expand_variables->($+{VALUE})))
if !@skip || $skip[$#skip] > 0; },
qr/^\s* WRAP ${index_re} \s* = \s* ${value_re} \s* $/x
=> sub { $push_to->(\%wraps, $expand_variables->($+{INDEX}),
undef, undef,
tokenize($expand_variables->($+{VALUE})))
if !@skip || $skip[$#skip] > 0; },
qr/^\s* GENERATE ${index_re} ${attribs_re} \s* = \s* ${value_re} \s* $/x
=> sub { $push_to->(\%generate, $expand_variables->($+{INDEX}),
\$attributes{generate}, $+{ATTRIBS},
@ -2678,6 +2740,27 @@ if ($builder eq "unified") {
}
}
foreach my $dest (keys %wraps) {
my $ddest = cleanfile($buildd, $dest, $blddir);
foreach my $fn (@{$wraps{$dest}}) {
push @{$unified_info{wraps}->{$ddest}}, $fn;
}
}
foreach my $dest (keys %unit_tests) {
my $ddest = cleanfile($buildd, $dest, $blddir);
foreach my $kw (@{$unit_tests{$dest}}) {
die "***** Unknown keyword '$kw' in UNIT_TEST[$dest] at $sourced/$f\n"
unless grep { $_ eq $kw } @unit_test_keywords;
}
$unified_info{unit_tests}->{$ddest} =
[ @{$unit_tests{$dest}} ];
}
# WRAP implies cmocka unless an explicit UNIT_TEST set was given
foreach my $dest (keys %{$unified_info{wraps} // {}}) {
$unified_info{unit_tests}->{$dest} //= [ "cmocka" ];
}
foreach my $section (keys %imagedocs) {
foreach (@{$imagedocs{$section}}) {
my $imagedocs = cleanfile($buildd, $_, $blddir);
@ -3010,6 +3093,28 @@ EOF
}
}
# Attach cmocka (and, on Windows, Detours) include paths to unit tests,
# based on each test's UNIT_TEST[] link set.
if (!$disabled{"unit-tests"}) {
while (my ($dest, $libs) = each %{$unified_info{unit_tests} // {}}) {
my %want = map { $_ => 1 } @$libs;
push @{$unified_info{includes}->{$dest}}, @{$config{cmocka_includes}}
if $want{cmocka} && @{$config{cmocka_includes} // []};
push @{$unified_info{includes}->{$dest}}, @{$config{detours_includes}}
if $want{detours} && @{$config{detours_includes} // []};
}
}
if (!$disabled{"unit-tests"}) {
foreach my $dest (sort keys %{$unified_info{unit_tests} // {}}) {
my %want = map { $_ => 1 } @{$unified_info{unit_tests}->{$dest}};
my @resolved;
push @resolved, '$(CMOCKA_LIBS)' if $want{cmocka} && $config{cmocka_libs};
push @resolved, '$(DETOURS_LIBS)' if $want{detours} && $config{detours_libs};
$unified_info{unit_test_libs}->{$dest} = join(' ', @resolved);
}
}
# For the schemes that need it, we provide the old *_obj configs
# from the *_asm_obj ones
foreach (grep /_(asm|aux)_src$/, keys %target) {

194
DOCUMENTATION.md Normal file
View file

@ -0,0 +1,194 @@
OpenSSL Documentation Policy
============================
This document describes the code documentation and commenting requirements
for the OpenSSL project.
The project's documentation is about making the libraries and tools more
accessible to our users and making the code more maintainable. This policy
applies to new submissions; existing code does not uniformly conform to it
and will be brought up to standard gradually.
Any non-trivial change to existing code must bring the affected code into
conformance with this policy as part of the same change. In particular,
renaming or relocating functions, changes to public APIs, and any change
that would render an existing POD page or in-source comment inaccurate
require the corresponding documentation to be updated. This includes
adding documentation that was previously absent where the change brings
the affected code within the scope of this policy.
The form and style of code comments themselves -- comment markers, layout,
the use of `/**` and `/*-` blocks, doxygen markup, the structure of the
sample multi-line comment, and similar -- are described in
[STYLE.md](STYLE.md). This file describes what *must* be documented and
where; [STYLE.md](STYLE.md) describes how code comments look.
Command line commands and arguments
-----------------------------------
All new commands, as well as new or modified arguments to existing
commands, must be documented in the `doc/man1` directory. This
documentation is in POD format.
Public symbols in the libraries
-------------------------------
All new public symbols must be documented in a POD manual page in the
`doc/man3` directory. This includes types, macros, and functions.
The allowed exceptions are:
- guard macros preventing a header file being included twice
- new symbols generated automatically via `make update` (errors, objects, etc.)
Each public function's declaration in its public header must carry a
doxygen comment block. The block's `@see` must include the function's
own manual page (`name(3)`) and may include additional manual pages
that a caller needs to use the function correctly. The doxygen block
is a navigation aid pointing to the canonical reference documentation
in the corresponding POD file; see [STYLE.md](STYLE.md) for the
doxygen form.
Overviews, conventions, et al
-----------------------------
Where additional user-facing information is required, it should be
included in the `doc/man7` section. This includes, but is not limited to:
- algorithm descriptions and parameters
- architectural and subsystem overviews
- user guides and tutorials
- conventions and reference material (environment variables, glossary,
threading rules, file format conventions)
Internal functions, structures, globals and macros
--------------------------------------------------
Internal functions, structures, globals and macros are non-public
items declared in any header that is not part of the public API.
These include items declared in:
- `include/internal/` (shared across subsystems);
- `include/crypto/` (cryptographic internals);
- per-directory local headers (for example, `crypto/asn1/asn1_local.h`)
shared between source files in a single subdirectory.
These should all be documented at the declaration site -- that is,
in the header that declares them -- using a doxygen-style comment
block. For functions, this places the comment at the prototype,
where editor tooling (clangd and similar) can surface it to readers
at every call site. The comment should describe the purpose and,
for functions, the input and output arguments and the return value.
See [STYLE.md](STYLE.md) for the doxygen conventions used by OpenSSL.
For *trivial* items, where their operation is obvious from their
implementation, the documentation requirement is not mandated. The
following are generally representative of trivial items, however it is
quite possible for any of these to be non-trivial in specific instances
and therefore require documentation:
- `OSSL_DISPATCH` tables
- upref functions
- free functions
- simple getter/setter functions
- wrappers for other functions (a function that calls a more recent
`_ex` variant or a group of functions that call a common internal
routine)
For structures, each of the fields should be commented stating its
purpose. Again, a *trivial* exception applies where the purpose is
obvious. Some representative examples:
- `OSSL_LIB_CTX *ctx;` where there is only one library context referenced
in the structure.
- `struct *next;` in a linked list implementation.
- `CRYPTO_REF_COUNT refcnt;`
File-local items
----------------
These are functions, structures, globals, and macros that are local
to a single C file: `static` functions, file-scope variables,
structures, and macros defined inside a `.c` file with no declaration
in any header.
These should all be documented at the point of definition. Follow the
same rules and exceptions as for internal items above. In some cases
slightly more leniency with respect to *trivial* can be tolerated.
Code comments
-------------
The form, style, and content guidance for code comments are described in
[STYLE.md](STYLE.md). Comments are required at the points described in
the internal and static sections above, subject to the *trivial*
exception, and at the additional points described in
[STYLE.md](STYLE.md).
Assembly code
-------------
Assembly code should include a good description of the algorithm and
approach being used. This should be followed by a performance comparison
and then the assembly code itself. The assembly code should be well
commented, but it is not necessary to comment every line. A comment
describing each block of code suffices.
For pure-assembly modules (`.s` files and the perlasm scripts that
generate them), comments use the native syntax of the assembler or
generator (typically `#`). Doxygen-style markup does not apply here;
the algorithm description, performance comparison, and per-block
comments described above are still required.
For assembly that appears inline inside a C file (within an `asm()`
statement, for example), the surrounding C function is documented
with doxygen-style C comments as for any other C code; see
[STYLE.md](STYLE.md). Comments inside the `asm()` body itself use
plain C `/* */` comments.
There are no *trivial* exceptions for assembly code.
Configure options
-----------------
New options added to the configuration scripts must be documented in the
[INSTALL.md](INSTALL.md) file.
Changes and news
----------------
Significant modifications should be documented in the
[CHANGES.md](CHANGES.md) file.
Very significant features and changes should be documented in the
[NEWS.md](NEWS.md) file.
In both cases, the added note should be short and to the point, and
should be written for users of the library, focusing on impact rather
than implementation details.
Automated sanity checking
-------------------------
The `make doc-nits` command should be run before submitting a pull
request and any problems it locates must be addressed.
Language
--------
The language used for documentation shall be *British English*.
In general the language, abbreviations, layout and formatting should also
correspond to the
[LDP](https://openssl-library.org/policies/general/glossary/#ldp)
guidelines.
Common sense
------------
Comments and documentation are to improve readability and comprehension.
Where the code is obvious, there is no need to include a comment.
However, common sense applies: always err in favour of including more
comments than less or none. Code that you have just written that is
*obvious* will not necessarily be to someone else two years later. See
[STYLE.md](STYLE.md) for the form and content of code comments.

View file

@ -169,13 +169,11 @@ issue the following commands to build OpenSSL.
$ nmake test
As mentioned in the [Choices](#choices) section, you need to pick one
of the four Configure targets in the first command.
of the Configure targets in the first command.
Most likely you will be using the `VC-WIN64A`/`VC-WIN64A-HYBRIDCRT` target for
64bit Windows binaries (AMD64) or `VC-WIN32`/`VC-WIN32-HYBRIDCRT` for 32bit
Windows binaries (X86).
The other two options are `VC-WIN64I` (Intel IA64, Itanium) and
`VC-CE` (Windows CE) are rather uncommon nowadays.
Installing OpenSSL
------------------
@ -428,6 +426,22 @@ The names of the libraries are:
* brotlidec.lib
* brotlienc.lib
### with-cmocka-include
--with-cmocka-include=DIR
The directory for the location of the cmocka include file. This option is only
necessary if [enable-unit-tests](#enable-unit-tests) is used and the include
file is not already on the system include path.
### with-cmocka-lib
--with-cmocka-lib=DIR
The directory containing the cmocka library. This option is only necessary if
[enable-unit-tests](#enable-unit-tests) is used and the library is not already
on the system library path.
### with-zlib-include
--with-zlib-include=DIR
@ -818,6 +832,12 @@ external test suites are currently supported:
See the file [test/README-external.md](test/README-external.md)
for further details.
### enable-unit-tests
Enable building and running unit tests.
This works only on platforms supporting ld `--wrap` option like Linux and BSD.
### no-filenames
Don't compile in filename and line number information (e.g. for errors and
@ -1095,10 +1115,12 @@ The User Interface console method enables text based console prompts.
### enable-unit-test
Enable additional unit test APIs.
Enable exposing SSL_test_functions for overwriting ssl_init_wbio_buffer.
This should not typically be used in production deployments.
This option is deprecated and will be removed in OpenSSL 5.0.
### no-uplink
Don't build support for UPLINK interface.
@ -1201,7 +1223,8 @@ Build without support for the specified algorithm.
The `ripemd` algorithm is deprecated and if used is synonymous with `rmd160`.
### Compiler-specific options
Compiler-specific options
-------------------------
-Dxxx, -Ixxx, -Wp, -lxxx, -Lxxx, -Wl, -rpath, -R, -framework, -static
@ -1232,7 +1255,17 @@ encoding.
Take note of the [Environment Variables](#environment-variables) documentation
below and how these flags interact with those variables.
### Environment Variables
Miscellaneous options
---------------------
### --manpage-format
Specify a specific output manpage format. The supported output types are mandoc
and *roff. The *roff output format is the default for legacy and portability
reasons.
Environment Variables
---------------------
VAR=value
@ -1309,10 +1342,18 @@ If `CC` is set, it is advisable to also set `CXX` to ensure both the C and C++
compiler are in the same "family". This becomes relevant with
`enable-external-tests` and `enable-buildtest-c++`.
### Reconfigure
Reconfigure
-----------
reconf
reconfigure
### Make targets
`$ make reconf`
or
`$ make reconfigure`
### Description
Reconfigure from earlier data.
@ -1930,9 +1971,8 @@ on Cygwin, shared libraries are named `cygcrypto-1.1.dll` and `cygssl-1.1.dll`
with import libraries `libcrypto.dll.a` and `libssl.dll.a`.
On Windows build with MSVC or using MingW, shared libraries are named
`libcrypto-1_1.dll` and `libssl-1_1.dll` for 32-bit Windows,
`libcrypto-1_1-x64.dll` and `libssl-1_1-x64.dll` for 64-bit x86_64 Windows,
and `libcrypto-1_1-ia64.dll` and `libssl-1_1-ia64.dll` for IA64 Windows.
`libcrypto-1_1.dll` and `libssl-1_1.dll` for 32-bit Windows, and
`libcrypto-1_1-x64.dll` and `libssl-1_1-x64.dll` for 64-bit x86_64 Windows.
With MSVC, the import libraries are named `libcrypto.lib` and `libssl.lib`,
while with MingW, they are named `libcrypto.dll.a` and `libssl.dll.a`.

View file

@ -31,6 +31,8 @@ OpenSSL 4.1
* API calls `CRYPTO_atomic_load_ptr`, `CRYPTO_atomic_store_ptr`, and
`CRYPTO_atomic_cmp_exch_ptr` have been added.
* Fixed verification of DSA certificates signed with SHA-384 or SHA-512.
OpenSSL 4.0
-----------

View file

@ -49,7 +49,7 @@ The OpenSSL toolkit includes:
basis of the TLS implementation, but can also be used independently.
- **openssl**
the OpenSSL command line tool, a swiss army knife for cryptographic tasks,
the OpenSSL command line tool, a Swiss Army knife for cryptographic tasks,
testing and analyzing. It can be used for
- creation of key parameters
- creation of X.509 certificates, CSRs and CRLs
@ -150,11 +150,10 @@ The manual pages for the master branch and all current stable releases are
available online.
- [OpenSSL master](https://docs.openssl.org/master/)
- [OpenSSL 4.0](https://docs.openssl.org/4.0/)
- [OpenSSL 3.6](https://docs.openssl.org/3.6/)
- [OpenSSL 3.5](https://docs.openssl.org/3.5/)
- [OpenSSL 3.4](https://docs.openssl.org/3.4/)
- [OpenSSL 3.3](https://docs.openssl.org/3.3/)
- [OpenSSL 3.2](https://docs.openssl.org/3.2/)
- [OpenSSL 3.0](https://docs.openssl.org/3.0/)
Demos

1133
STYLE.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -82,7 +82,8 @@ int asn1parse_main(int argc, char **argv)
const unsigned char *ctmpbuf;
int indent = 0, noout = 0, dump = 0, informat = FORMAT_PEM;
int offset = 0, ret = 1, i, j;
long num, tmplen;
long num;
size_t tmplen;
const unsigned char *tmpbuf;
unsigned int length = 0;
OPTION_CHOICE o;
@ -241,12 +242,12 @@ int asn1parse_main(int argc, char **argv)
if (sk_OPENSSL_STRING_num(osk)) {
tmpbuf = str;
tmplen = num;
tmplen = (size_t)num;
for (i = 0; i < sk_OPENSSL_STRING_num(osk); i++) {
ASN1_TYPE *atmp;
int typ;
j = strtol(sk_OPENSSL_STRING_value(osk, i), NULL, 0);
if (j <= 0 || j >= tmplen) {
if (j <= 0 || (size_t)j >= tmplen) {
BIO_printf(bio_err, "'%s' is out of range\n",
sk_OPENSSL_STRING_value(osk, i));
continue;
@ -255,7 +256,7 @@ int asn1parse_main(int argc, char **argv)
tmplen -= j;
atmp = at;
ctmpbuf = tmpbuf;
at = d2i_ASN1_TYPE(NULL, &ctmpbuf, tmplen);
at = d2i_ASN1_TYPE(NULL, &ctmpbuf, (long)tmplen);
ASN1_TYPE_free(atmp);
if (!at) {
BIO_puts(bio_err, "Error parsing structure\n");
@ -272,11 +273,16 @@ int asn1parse_main(int argc, char **argv)
}
/* hmm... this is a little evil but it works */
tmpbuf = ASN1_STRING_get0_data(at->value.asn1_string);
tmplen = ASN1_STRING_length(at->value.asn1_string);
tmplen = ASN1_STRING_length_ex(at->value.asn1_string);
if (tmplen > INT_MAX) {
BIO_puts(bio_err, "ASN.1 string length exceeds INT_MAX\n");
ERR_print_errors(bio_err);
goto end;
}
}
/* XXX casts away const */
str = (unsigned char *)tmpbuf;
num = tmplen;
num = (int)tmplen;
}
if (offset < 0 || offset >= num) {

View file

@ -1077,8 +1077,8 @@ end_of_options:
X509 *xi = sk_X509_value(cert_sk, i);
const ASN1_INTEGER *serialNumber = X509_get0_serialNumber(xi);
const unsigned char *psn = ASN1_STRING_get0_data(serialNumber);
const int snl = ASN1_STRING_length(serialNumber);
const int filen_len = 2 * (snl > 0 ? snl : 1) + sizeof(".pem");
const size_t snl = ASN1_STRING_length_ex(serialNumber);
const size_t filen_len = 2 * (snl > 0 ? snl : 1) + sizeof(".pem");
char *n = new_cert + outdirlen;
if (outdirlen + filen_len > PATH_MAX) {
@ -1089,7 +1089,7 @@ end_of_options:
if (snl > 0) {
static const char HEX_DIGITS[] = "0123456789ABCDEF";
for (j = 0; j < snl; j++, psn++) {
for (j = 0; (size_t)j < snl; j++, psn++) {
*n++ = HEX_DIGITS[*psn >> 4];
*n++ = HEX_DIGITS[*psn & 0x0F];
}
@ -1523,8 +1523,10 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
goto end;
}
if (type != V_ASN1_BMPSTRING && type != V_ASN1_UTF8STRING) {
j = ASN1_PRINTABLE_type(ASN1_STRING_get0_data(str),
ASN1_STRING_length(str));
size_t tmp = ASN1_STRING_length_ex(str);
if (tmp > INT_MAX)
goto end;
j = ASN1_PRINTABLE_type(ASN1_STRING_get0_data(str), (int)tmp);
if ((j == V_ASN1_T61STRING && type != V_ASN1_T61STRING)
|| (j == V_ASN1_IA5STRING && type == V_ASN1_PRINTABLESTRING)) {
BIO_puts(bio_err,
@ -1901,9 +1903,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
/* We now just add it to the database as DB_TYPE_VAL('V') */
row[DB_type] = OPENSSL_strdup("V");
tm = X509_get0_notAfter(ret);
row[DB_exp_date] = app_malloc(ASN1_STRING_length(tm) + 1, "row expdate");
memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length(tm));
row[DB_exp_date][ASN1_STRING_length(tm)] = '\0';
row[DB_exp_date] = app_malloc(ASN1_STRING_length_ex(tm) + 1, "row expdate");
memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length_ex(tm));
row[DB_exp_date][ASN1_STRING_length_ex(tm)] = '\0';
row[DB_rev_date] = NULL;
row[DB_file] = OPENSSL_strdup("unknown");
if ((row[DB_type] == NULL) || (row[DB_file] == NULL)
@ -2137,9 +2139,9 @@ static int do_revoke(X509 *x509, CA_DB *db, REVINFO_TYPE rev_type,
/* We now just add it to the database as DB_TYPE_REV('V') */
row[DB_type] = OPENSSL_strdup("V");
tm = X509_get0_notAfter(x509);
row[DB_exp_date] = app_malloc(ASN1_STRING_length(tm) + 1, "row exp_data");
memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length(tm));
row[DB_exp_date][ASN1_STRING_length(tm)] = '\0';
row[DB_exp_date] = app_malloc(ASN1_STRING_length_ex(tm) + 1, "row exp_data");
memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length_ex(tm));
row[DB_exp_date][ASN1_STRING_length_ex(tm)] = '\0';
row[DB_rev_date] = NULL;
row[DB_file] = OPENSSL_strdup("unknown");
@ -2350,7 +2352,7 @@ static char *make_revocation_str(REVINFO_TYPE rev_type, const char *rev_arg)
const char *reason = NULL, *other = NULL;
ASN1_OBJECT *otmp;
ASN1_UTCTIME *revtm = NULL;
int i;
size_t i;
switch (rev_type) {
case REV_NONE:
@ -2407,12 +2409,12 @@ static char *make_revocation_str(REVINFO_TYPE rev_type, const char *rev_arg)
if (!revtm)
return NULL;
i = ASN1_STRING_length(revtm) + 1;
i = ASN1_STRING_length_ex(revtm) + 1;
if (reason)
i += (int)(strlen(reason) + 1);
i += strlen(reason) + 1;
if (other)
i += (int)(strlen(other) + 1);
i += strlen(other) + 1;
str = app_malloc(i, "revocation reason");
OPENSSL_strlcpy(str, (const char *)ASN1_STRING_get0_data(revtm), i);
@ -2492,7 +2494,7 @@ static int old_entry_print(const ASN1_OBJECT *obj, const ASN1_STRING *str)
{
char buf[25], *pbuf;
const char *p;
int j;
size_t j;
j = i2a_ASN1_OBJECT(bio_err, obj);
pbuf = buf;
@ -2514,7 +2516,7 @@ static int old_entry_print(const ASN1_OBJECT *obj, const ASN1_STRING *str)
BIO_printf(bio_err, "ASN.1 %2d:'", ASN1_STRING_type(str));
p = (const char *)ASN1_STRING_get0_data(str);
for (j = ASN1_STRING_length(str); j > 0; j--) {
for (j = ASN1_STRING_length_ex(str); j > 0; j--) {
if ((*p >= ' ') && (*p <= '~'))
BIO_printf(bio_err, "%c", *p);
else if (*p & 0x80)

View file

@ -2140,7 +2140,7 @@ static int add_certProfile(OSSL_CMP_CTX *ctx, const char *name)
return 0;
if ((utf8string = ASN1_UTF8STRING_new()) == NULL)
goto err;
if (!ASN1_STRING_set(utf8string, name, (int)strlen(name))) {
if (!ASN1_STRING_set_string(utf8string, name)) {
ASN1_STRING_free(utf8string);
goto err;
}
@ -2215,7 +2215,7 @@ static int handle_opt_geninfo(OSSL_CMP_CTX *ctx)
else
*end++ = '\0';
if ((text = ASN1_UTF8STRING_new()) == NULL
|| !ASN1_STRING_set(text, ptr, -1))
|| !ASN1_STRING_set_string(text, ptr))
goto oom;
ptr = end;
ASN1_TYPE_set(type, V_ASN1_UTF8STRING, text);

View file

@ -1580,13 +1580,15 @@ static void receipt_request_print(CMS_ContentInfo *cms)
ERR_print_errors(bio_err);
} else {
const char *id;
int idlen;
size_t idlen;
CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst,
&rlist, &rto);
BIO_puts(bio_err, " Signed Content ID:\n");
idlen = ASN1_STRING_length(scid);
idlen = ASN1_STRING_length_ex(scid);
if (idlen > INT_MAX)
idlen = INT_MAX;
id = (const char *)ASN1_STRING_get0_data(scid);
BIO_dump_indent(bio_err, id, idlen, 4);
BIO_dump_indent(bio_err, id, (int)idlen, 4);
BIO_puts(bio_err, " Receipts From");
if (rlist != NULL) {
BIO_puts(bio_err, " List:\n");

View file

@ -54,7 +54,7 @@ const OPTIONS ec_options[] = {
{ "check", OPT_CHECK, '-', "check key consistency" },
{ "", OPT_CIPHER, '-', "Any supported cipher" },
{ "param_enc", OPT_PARAM_ENC, 's',
"Specifies the way the ec parameters are encoded" },
"Selects between named_curve and explicit EC parameter encoding" },
{ "conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form " },
OPT_SECTION("Output"),

View file

@ -57,7 +57,7 @@ const OPTIONS ecparam_options[] = {
{ "text", OPT_TEXT, '-', "Print the ec parameters in text form" },
{ "noout", OPT_NOOUT, '-', "Do not print the ec parameter" },
{ "param_enc", OPT_PARAM_ENC, 's',
"Specifies the way the ec parameters are encoded" },
"Selects between named_curve and explicit EC parameter encoding" },
OPT_SECTION("Parameter"),
{ "check", OPT_CHECK, '-', "Validate the ec parameters" },

View file

@ -40,6 +40,7 @@
#include <openssl/ssl.h>
#include <openssl/core_names.h>
#include <openssl/encoder.h>
#include <openssl/decoder.h>
#include "s_apps.h"
#include "apps.h"
@ -605,20 +606,46 @@ EVP_PKEY *load_keyparams_suppress(const char *uri, int format, int maybe_stdin,
int suppress_decode_errors)
{
EVP_PKEY *params = NULL;
OSSL_DECODER_CTX *dctx = NULL;
BIO *file_bio = BIO_new_file(uri, "rb");
OSSL_LIB_CTX *libctx = app_get0_libctx();
const char *propq = app_get0_propq();
if (desc == NULL)
desc = "key parameters";
(void)load_key_certs_crls(uri, format, maybe_stdin, NULL, desc,
suppress_decode_errors,
NULL, NULL, &params, NULL, NULL, NULL, NULL, NULL);
if (params != NULL && keytype != NULL && !EVP_PKEY_is_a(params, keytype)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err,
"Unable to load %s from %s (unexpected parameters type)\n",
desc, uri);
EVP_PKEY_free(params);
params = NULL;
/*
* Use the store lookup path for anything that is not DER/ASN1 format
* Or if we are unable to opens the uri as a file.
*/
if (format != FORMAT_ASN1 || file_bio == NULL) {
(void)load_key_certs_crls(uri, format, maybe_stdin, NULL, desc,
suppress_decode_errors,
NULL, NULL, &params, NULL, NULL, NULL, NULL, NULL);
if (params != NULL && keytype != NULL && !EVP_PKEY_is_a(params, keytype)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err,
"Unable to load %s from %s (unexpected parameters type)\n",
desc, uri);
EVP_PKEY_free(params);
params = NULL;
}
} else {
dctx = OSSL_DECODER_CTX_new_for_pkey(&params, NULL, NULL, keytype,
OSSL_KEYMGMT_SELECT_ALL_PARAMETERS,
libctx, propq);
if (dctx == NULL) {
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Unable to allocate decoder context\n");
} else {
if (!OSSL_DECODER_from_bio(dctx, file_bio)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Unable to decode file %s\n", uri);
}
}
}
BIO_free(file_bio);
OSSL_DECODER_CTX_free(dctx);
return params;
}
@ -1849,11 +1876,18 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
goto err;
#ifndef OPENSSL_NO_POSIX_IO
BIO_get_fp(in, &dbfp);
if (fstat(fileno(dbfp), &dbst) == -1) {
ERR_raise_data(ERR_LIB_SYS, errno,
"calling fstat(%s)", dbfile);
goto err;
if (BIO_get_fp(in, &dbfp) > 0 && dbfp != NULL) {
if (fstat(fileno(dbfp), &dbst) == -1) {
ERR_raise_data(ERR_LIB_SYS, errno,
"calling fstat(%s)", dbfile);
goto err;
}
} else {
if (stat(dbfile, &dbst) == -1) {
ERR_raise_data(ERR_LIB_SYS, errno,
"calling stat(%s)", dbfile);
goto err;
}
}
#endif
@ -2799,7 +2833,7 @@ static const char *get_dp_url(DIST_POINT *dp)
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
gen = sk_GENERAL_NAME_value(gens, i);
uri = GENERAL_NAME_get0_value(gen, &gtype);
if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6) {
if (gtype == GEN_URI && ASN1_STRING_length_ex(uri) > 6) {
const char *uptr = (const char *)ASN1_STRING_get0_data(uri);
if (IS_HTTP(uptr)) /* can/should not use HTTPS here */
@ -3117,14 +3151,10 @@ static int WIN32_rename(const char *from, const char *to)
if (tfrom == NULL)
goto err;
tto = tfrom + flen;
#if !defined(_WIN32_WCE) || _WIN32_WCE >= 101
if (!MultiByteToWideChar(CP_ACP, 0, from, (int)flen, (WCHAR *)tfrom, (int)flen))
#endif
for (i = 0; i < flen; i++)
tfrom[i] = (TCHAR)from[i];
#if !defined(_WIN32_WCE) || _WIN32_WCE >= 101
if (!MultiByteToWideChar(CP_ACP, 0, to, (int)tlen, (WCHAR *)tto, (int)tlen))
#endif
for (i = 0; i < tlen; i++)
tto[i] = (TCHAR)to[i];
}
@ -3692,7 +3722,7 @@ int has_stdin_waiting(void)
int corrupt_signature(ASN1_STRING *signature)
{
const unsigned char *valid = ASN1_STRING_get0_data(signature);
int length = ASN1_STRING_length(signature);
size_t length = ASN1_STRING_length_ex(signature);
unsigned char *s = OPENSSL_memdup(valid, length);
if (s == NULL)
@ -3700,7 +3730,7 @@ int corrupt_signature(ASN1_STRING *signature)
s[length - 1] ^= 0x1;
ASN1_STRING_set0(signature, s, length);
ASN1_STRING_set0(signature, s, (int)length);
return 1;
}

View file

@ -345,7 +345,7 @@ static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
STACK_OF(ASN1_UTF8STRING) *strs;
ASN1_UTF8STRING *str;
const char *data;
int len;
size_t len;
if (OBJ_obj2nid(obj) == NID_id_it_certProfile) {
if (!OSSL_CMP_ITAV_get0_certProfile(itav, &strs))
@ -360,7 +360,7 @@ static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
ERR_raise(ERR_LIB_CMP, ERR_R_PASSED_INVALID_ARGUMENT);
return NULL;
}
if (((len = ASN1_STRING_length(str)) != (int)sizeof("profile1") - 1)
if (((len = ASN1_STRING_length_ex(str)) != sizeof("profile1") - 1)
|| memcmp(data, "profile1", len) != 0) {
ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_CERTPROFILE);
return NULL;

View file

@ -1236,9 +1236,7 @@ int opt_isdir(const char *name)
if (len_0 > MAX_PATH)
return -1;
#if !defined(_WIN32_WCE) || _WIN32_WCE >= 101
if (!MultiByteToWideChar(CP_ACP, 0, name, (int)len_0, tempname, MAX_PATH))
#endif
for (i = 0; i < len_0; i++)
tempname[i] = (WCHAR)name[i];

View file

@ -576,6 +576,7 @@ static STRINT_PAIR ssl_versions[] = {
{ "TLS 1.2", TLS1_2_VERSION },
{ "TLS 1.3", TLS1_3_VERSION },
{ "DTLS 1.0", DTLS1_VERSION },
{ "DTLS 1.2", DTLS1_2_VERSION },
{ "DTLS 1.0 (bad)", DTLS1_BAD_VER },
{ NULL }
};
@ -653,7 +654,10 @@ void msg_cb(int write_p, int version, int content_type, const void *buf,
const char *str_version, *str_content_type = "", *str_details1 = "", *str_details2 = "";
const unsigned char *bp = buf;
if (version == TLS1_VERSION || version == TLS1_1_VERSION || version == TLS1_2_VERSION || version == TLS1_3_VERSION || version == DTLS1_VERSION || version == DTLS1_BAD_VER) {
if (version == TLS1_VERSION || version == TLS1_1_VERSION
|| version == TLS1_2_VERSION || version == TLS1_3_VERSION
|| version == DTLS1_VERSION || version == DTLS1_2_VERSION
|| version == DTLS1_BAD_VER) {
str_version = lookup(version, ssl_versions, "???");
switch (content_type) {
case SSL3_RT_CHANGE_CIPHER_SPEC:
@ -775,8 +779,8 @@ static const STRINT_PAIR tlsext_types[] = {
{ NULL }
};
/* from rfc8446 4.2.3. + gost (https://tools.ietf.org/id/draft-smyshlyaev-tls12-gost-suites-04.html) */
static STRINT_PAIR signature_tls13_scheme_list[] = {
/* RFC 8446 4.2.3 */
{ "rsa_pkcs1_sha1", 0x0201 /* TLSEXT_SIGALG_rsa_pkcs1_sha1 */ },
{ "ecdsa_sha1", 0x0203 /* TLSEXT_SIGALG_ecdsa_sha1 */ },
/* {"rsa_pkcs1_sha224", 0x0301 TLSEXT_SIGALG_rsa_pkcs1_sha224}, not in rfc8446 */
@ -795,9 +799,59 @@ static STRINT_PAIR signature_tls13_scheme_list[] = {
{ "rsa_pss_pss_sha256", 0x0809 /* TLSEXT_SIGALG_rsa_pss_pss_sha256 */ },
{ "rsa_pss_pss_sha384", 0x080a /* TLSEXT_SIGALG_rsa_pss_pss_sha384 */ },
{ "rsa_pss_pss_sha512", 0x080b /* TLSEXT_SIGALG_rsa_pss_pss_sha512 */ },
/* RFC 8734 */
{ "ecdsa_brainpoolP256r1tls13_sha256", 0x81a },
{ "ecdsa_brainpoolP256r1tls13_sha384", 0x81b },
{ "ecdsa_brainpoolP256r1tls13_sha512", 0x81c },
/* RFC 8998 */
{ "sm2sig_sm3", 0x0708 /* TLSEXT_SIGALG_sm2sig_sm3 */ },
/* RFC 9367 */
{ "gostr34102012_256a", 0x709 },
{ "gostr34102012_256b", 0x70a },
{ "gostr34102012_256c", 0x70b },
{ "gostr34102012_256d", 0x70c },
{ "gostr34102012_512a", 0x70d },
{ "gostr34102012_512b", 0x70e },
{ "gostr34102012_512c", 0x70f },
/* RFC 9963 */
{ "rsa_pkcs1_sha256_legacy", 0x0420 },
{ "rsa_pkcs1_sha384_legacy", 0x0520 },
{ "rsa_pkcs1_sha512_legacy", 0x0620 },
/* IBS (https://datatracker.ietf.org/doc/html/draft-wang-tls-raw-public-key-with-ibc-02) */
{ "eccsi_sha256", 0x0704 },
{ "iso_ibs1", 0x0705 },
{ "iso_ibs2", 0x0706 },
{ "iso_chinese_ibs", 0x0707 },
/* ML-DSA (https://datatracker.ietf.org/doc/html/draft-ietf-tls-mldsa-00) */
{ "mldsa44", 0x0904 },
{ "mldsa65", 0x0905 },
{ "mldsa87", 0x0906 },
/* SLH-DSA (https://datatracker.ietf.org/doc/html/draft-reddy-tls-slhdsa-01) */
{ "slhdsa_sha2_128s", 0x0911 },
{ "slhdsa_sha2_128f", 0x0912 },
{ "slhdsa_sha2_192s", 0x0913 },
{ "slhdsa_sha2_192f", 0x0914 },
{ "slhdsa_sha2_256s", 0x0915 },
{ "slhdsa_sha2_256f", 0x0916 },
{ "slhdsa_shake_128s", 0x0917 },
{ "slhdsa_shake_128f", 0x0918 },
{ "slhdsa_shake_192s", 0x0919 },
{ "slhdsa_shake_192f", 0x091a },
{ "slhdsa_shake_256s", 0x091b },
{ "slhdsa_shake_256f", 0x091c },
/* GOST (https://tools.ietf.org/id/draft-smyshlyaev-tls12-gost-suites-04.html) */
{ "gostr34102001", 0xeded /* TLSEXT_SIGALG_gostr34102001_gostr3411 */ },
{ "gostr34102012_256", 0xeeee /* TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256 */ },
{ "gostr34102012_512", 0xefef /* TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512 */ },
{ NULL }
};
@ -1474,10 +1528,7 @@ static STRINT_PAIR callback_types[] = {
{ "Signature Algorithm mask", SSL_SECOP_SIGALG_MASK },
{ "Certificate chain EE key", SSL_SECOP_EE_KEY },
{ "Certificate chain CA key", SSL_SECOP_CA_KEY },
{ "Peer Chain EE key", SSL_SECOP_PEER_EE_KEY },
{ "Peer Chain CA key", SSL_SECOP_PEER_CA_KEY },
{ "Certificate chain CA digest", SSL_SECOP_CA_MD },
{ "Peer chain CA digest", SSL_SECOP_PEER_CA_MD },
{ "SSL compression", SSL_SECOP_COMPRESSION },
{ "Session ticket", SSL_SECOP_TICKET },
{ NULL }
@ -1511,7 +1562,6 @@ static int security_callback_debug(const SSL *s, const SSL_CTX *ctx,
show_nm = 0;
break;
case SSL_SECOP_CA_MD:
case SSL_SECOP_PEER_CA_MD:
cert_md = 1;
break;
case SSL_SECOP_SIGALG_SUPPORTED:

View file

@ -495,7 +495,7 @@ static int CreateSocketPair(int SocketFamily,
SocketPair[0] = SockDesc2;
SocketPair[1] = socket_fd(TcpDeviceChan);
return (0);
return 0;
}
/*----------------------------------------------------------------------------*/

View file

@ -74,7 +74,7 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
static int send_ocsp_response(BIO *cbio, const OCSP_RESPONSE *resp);
static char *prog;
#ifdef HTTP_DAEMON
#ifndef OPENSSL_NO_POSIX_IO
static int index_changed(CA_DB *);
#endif
@ -680,7 +680,7 @@ int ocsp_main(int argc, char **argv)
redo_accept:
if (acbio != NULL) {
#ifdef HTTP_DAEMON
#ifndef OPENSSL_NO_POSIX_IO
if (index_changed(rdb)) {
CA_DB *newrdb = load_index(ridx_filename, NULL);
@ -926,7 +926,7 @@ end:
return ret;
}
#ifdef HTTP_DAEMON
#ifndef OPENSSL_NO_POSIX_IO
static int index_changed(CA_DB *rdb)
{
@ -937,7 +937,11 @@ static int index_changed(CA_DB *rdb)
|| rdb->dbst.st_ctime != sb.st_ctime
|| rdb->dbst.st_ino != sb.st_ino
|| rdb->dbst.st_dev != sb.st_dev) {
#ifdef HTTP_DAEMON
syslog(LOG_INFO, "index file changed, reloading");
#else
BIO_printf(bio_err, "%s: index file changed, reloading\n", prog);
#endif
return 1;
}
}

View file

@ -833,7 +833,7 @@ int pkcs12_main(int argc, char **argv)
ASN1_INTEGER_get(pbkdf2_param->iter));
BIO_printf(bio_err, "Key length: %ld, Salt length: %d\n",
ASN1_INTEGER_get(pbkdf2_param->keylength),
ASN1_STRING_length(pbkdf2_param->salt->value.octet_string));
(int)ASN1_STRING_length_ex(pbkdf2_param->salt->value.octet_string));
if (pbkdf2_param->prf == NULL) {
prfnid = NID_hmacWithSHA1;
} else {
@ -847,8 +847,8 @@ int pkcs12_main(int argc, char **argv)
BIO_printf(bio_err, ", Iteration %ld\n",
tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L);
BIO_printf(bio_err, "MAC length: %ld, salt length: %ld\n",
tmac != NULL ? ASN1_STRING_length(tmac) : 0L,
tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L);
tmac != NULL ? (long)ASN1_STRING_length_ex(tmac) : 0L,
tsalt != NULL ? (long)ASN1_STRING_length_ex(tsalt) : 0L);
}
}
@ -1231,7 +1231,7 @@ static int alg_print(const X509_ALGOR *alg)
}
BIO_printf(bio_err, ", Salt length: %d, Cost(N): %ld, "
"Block size(r): %ld, Parallelism(p): %ld",
ASN1_STRING_length(kdf->salt),
(int)ASN1_STRING_length_ex(kdf->salt),
ASN1_INTEGER_get(kdf->costParameter),
ASN1_INTEGER_get(kdf->blockSize),
ASN1_INTEGER_get(kdf->parallelizationParameter));
@ -1282,25 +1282,25 @@ void print_attribute(BIO *out, const ASN1_TYPE *av)
switch (av->type) {
case V_ASN1_BMPSTRING:
value = OPENSSL_uni2asc(ASN1_STRING_get0_data(av->value.bmpstring),
ASN1_STRING_length(av->value.bmpstring));
(int)ASN1_STRING_length_ex(av->value.bmpstring));
BIO_printf(out, "%s\n", value);
OPENSSL_free(value);
break;
case V_ASN1_UTF8STRING:
BIO_printf(out, "%.*s\n", ASN1_STRING_length(av->value.utf8string),
BIO_printf(out, "%.*s\n", (int)ASN1_STRING_length_ex(av->value.utf8string),
ASN1_STRING_get0_data(av->value.utf8string));
break;
case V_ASN1_OCTET_STRING:
hex_print(out, ASN1_STRING_get0_data(av->value.octet_string),
ASN1_STRING_length(av->value.octet_string));
(int)ASN1_STRING_length_ex(av->value.octet_string));
BIO_puts(out, "\n");
break;
case V_ASN1_BIT_STRING:
hex_print(out, ASN1_STRING_get0_data(av->value.bit_string),
ASN1_STRING_length(av->value.bit_string));
(int)ASN1_STRING_length_ex(av->value.bit_string));
BIO_puts(out, "\n");
break;

View file

@ -72,7 +72,7 @@ const OPTIONS pkey_options[] = {
{ "ec_conv_form", OPT_EC_CONV_FORM, 's',
"Specifies the EC point conversion form in the encoding" },
{ "ec_param_enc", OPT_EC_PARAM_ENC, 's',
"Specifies the way the EC parameters are encoded" },
"Selects between named_curve and explicit EC parameter encoding" },
{ NULL }
};

View file

@ -23,6 +23,7 @@ typedef enum OPTION_choice {
OPT_OUT,
OPT_BASE64,
OPT_HEX,
OPT_NO_NEWLINE,
OPT_R_ENUM,
OPT_PROV_ENUM
} OPTION_CHOICE;
@ -37,6 +38,7 @@ const OPTIONS rand_options[] = {
{ "out", OPT_OUT, '>', "Output file" },
{ "base64", OPT_BASE64, '-', "Base64 encode output" },
{ "hex", OPT_HEX, '-', "Hex encode output" },
{ "n", OPT_NO_NEWLINE, '-', "Do not output the trailing newline" },
OPT_R_OPTIONS,
OPT_PROV_OPTIONS,
@ -51,7 +53,7 @@ int rand_main(int argc, char **argv)
BIO *out = NULL;
char *outfile = NULL, *prog;
OPTION_CHOICE o;
int format = FORMAT_BINARY, r, i, ret = 1;
int format = FORMAT_BINARY, r, i, ret = 1, newline = 1;
size_t buflen = (1 << 16); /* max rand chunk size is 2^16 bytes */
long num = -1;
uint64_t scaled_num = 0;
@ -82,6 +84,9 @@ int rand_main(int argc, char **argv)
case OPT_HEX:
format = FORMAT_TEXT;
break;
case OPT_NO_NEWLINE:
newline = 0;
break;
case OPT_PROV_CASES:
if (!opt_provider(o))
goto end;
@ -208,7 +213,7 @@ int rand_main(int argc, char **argv)
}
scaled_num -= chunk;
}
if (format == FORMAT_TEXT)
if (newline && format == FORMAT_TEXT)
BIO_puts(out, "\n");
if (BIO_flush(out) <= 0)
goto end;

View file

@ -1254,25 +1254,21 @@ static int prompt_info(X509_REQ *req,
if (!join(buf, sizeof(buf), type, "_value", "Name"))
goto err;
;
value = app_conf_try_string(req_conf, attr_sect, buf);
if (!join(buf, sizeof(buf), type, "_min", "Name"))
goto err;
;
if (!app_conf_try_number(req_conf, attr_sect, buf, &n_min))
n_min = -1;
if (!join(buf, sizeof(buf), type, "_max", "Name"))
goto err;
;
if (!app_conf_try_number(req_conf, attr_sect, buf, &n_max))
n_max = -1;
if (!add_attribute_object(req,
v->value, def, value, nid, n_min,
n_max, chtype))
goto err;
;
}
}
} else {

View file

@ -3049,6 +3049,7 @@ re_start:
ASN1_TYPE *atyp = NULL;
BIO *ldapbio = BIO_new(BIO_s_mem());
CONF *cnf = NCONF_new(NULL);
size_t ssl_request_len;
if (ldapbio == NULL || cnf == NULL) {
BIO_free(ldapbio);
@ -3081,11 +3082,18 @@ re_start:
BIO_puts(bio_err, "ASN1_generate_nconf failed\n");
goto end;
}
ssl_request_len = ASN1_STRING_length_ex(atyp->value.sequence);
if (ssl_request_len > INT_MAX) {
NCONF_free(cnf);
ASN1_TYPE_free(atyp);
BIO_puts(bio_err, "generated NCONF size is too large\n");
goto end;
}
NCONF_free(cnf);
/* Send SSLRequest packet */
BIO_write(sbio, ASN1_STRING_get0_data(atyp->value.sequence),
ASN1_STRING_length(atyp->value.sequence));
(int)ssl_request_len);
(void)BIO_flush(sbio);
ASN1_TYPE_free(atyp);
@ -3520,29 +3528,32 @@ shut:
print_stuff(bio_c_out, con, full_log);
do_ssl_shutdown(con);
/*
* If we ended with an alert being sent, but still with data in the
* network buffer to be read, then calling BIO_closesocket() will
* result in a TCP-RST being sent. On some platforms (notably
* Windows) then this will result in the peer immediately abandoning
* the connection including any buffered alert data before it has
* had a chance to be read. Shutting down the sending side first,
* and then closing the socket sends TCP-FIN first followed by
* TCP-RST. This seems to allow the peer to read the alert data.
*/
shutdown(SSL_get_fd(con), 1); /* SHUT_WR */
/*
* We just said we have nothing else to say, but it doesn't mean that
* the other side has nothing. It's even recommended to consume incoming
* data. [In testing context this ensures that alerts are passed on...]
*/
timeout.tv_sec = 0;
timeout.tv_usec = 500000; /* some extreme round-trip */
do {
FD_ZERO(&readfds);
openssl_fdset(sock, &readfds);
} while (select(sock + 1, &readfds, NULL, NULL, &timeout) > 0
&& BIO_read(sbio, sbuf, BUFSIZZ) > 0);
/* The following half-close/drain workaround is TCP-specific. */
if (!isdtls && !isquic) {
/*
* If we ended with an alert being sent, but still with data in the
* network buffer to be read, then calling BIO_closesocket() will
* result in a TCP-RST being sent. On some platforms (notably
* Windows) then this will result in the peer immediately abandoning
* the connection including any buffered alert data before it has
* had a chance to be read. Shutting down the sending side first,
* and then closing the socket sends TCP-FIN first followed by
* TCP-RST. This seems to allow the peer to read the alert data.
*/
shutdown(SSL_get_fd(con), 1); /* SHUT_WR */
/*
* We just said we have nothing else to say, but it doesn't mean that
* the other side has nothing. It's even recommended to consume incoming
* data. [In testing context this ensures that alerts are passed on...]
*/
timeout.tv_sec = 0;
timeout.tv_usec = 500000; /* some extreme round-trip */
do {
FD_ZERO(&readfds);
openssl_fdset(sock, &readfds);
} while (select(sock + 1, &readfds, NULL, NULL, &timeout) > 0
&& BIO_read(sbio, sbuf, BUFSIZZ) > 0);
}
BIO_closesocket(SSL_get_fd(con));
end:

View file

@ -462,7 +462,7 @@ typedef struct tlsextctx_st {
static unsigned int ech_print_cb(SSL *s, const char *str)
{
if (str != NULL)
BIO_printf(bio_s_out, "ECH Server callback printing: \n%s\n", str);
BIO_printf(bio_s_out, "ECH Server callback printing:\n%s\n", str);
return 1;
}
@ -4020,6 +4020,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
if (rpk_files != NULL && !rpk_enable(con)) {
BIO_puts(bio_err, "Error enabling client RPK verification\n");
SSL_free(con);
goto err;
}
@ -4543,6 +4544,7 @@ static int rev_body(int s, int stype, int prot, unsigned char *context)
if (rpk_files != NULL && !rpk_enable(con)) {
BIO_puts(bio_err, "Error enabling client RPK verification\n");
ERR_print_errors(bio_err);
SSL_free(con);
goto err;
}

View file

@ -2945,7 +2945,7 @@ int speed_main(int argc, char **argv)
&outlen, loopargs[k].buf,
lengths[testnum])) {
BIO_puts(bio_err,
"\nFailed to to encrypt the data\n");
"\nFailed to encrypt the data\n");
dofail();
exit(1);
}
@ -4633,7 +4633,7 @@ static int do_multi(int multi, int size_num)
for (n = 0; n < multi; ++n) {
while (wait(&status) == -1)
if (errno != EINTR) {
BIO_printf(bio_err, "Waitng for child failed with 0x%x\n",
BIO_printf(bio_err, "Waiting for child failed with 0x%x\n",
errno);
return 1;
}

View file

@ -155,8 +155,8 @@ int spkac_main(int argc, char **argv)
if (spki == NULL)
goto end;
if (challenge != NULL
&& !ASN1_STRING_set(spki->spkac->challenge,
challenge, (int)strlen(challenge)))
&& !ASN1_STRING_set_string(spki->spkac->challenge,
challenge))
goto end;
if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) {
BIO_puts(bio_err, "Error setting public key\n");

View file

@ -583,7 +583,7 @@ static ASN1_INTEGER *create_nonce(int bits)
if ((nonce = ASN1_INTEGER_new()) == NULL)
goto err;
if (!ASN1_STRING_set(nonce, buf, len))
if (!ASN1_STRING_set_data(nonce, buf, len))
goto err;
ret = nonce;

View file

@ -36,25 +36,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <windows.h>
#include <tchar.h>
#include "internal/e_os.h"
#include "internal/numbers.h"
#ifndef LPDIR_H
#include "LPdir.h"
#endif
/*
* We're most likely overcautious here, but let's reserve for broken WinCE
* headers and explicitly opt for UNICODE call. Keep in mind that our WinCE
* builds are compiled with -DUNICODE [as well as -D_UNICODE].
*/
#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
#define FindFirstFile FindFirstFileW
#endif
#if defined(LP_SYS_WINCE) && !defined(FindNextFile)
#define FindNextFile FindNextFileW
#endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif

View file

@ -1,46 +0,0 @@
/*
* Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/*
* This file is dual-licensed and is also available under the following
* terms:
*
* Copyright (c) 2004, Richard Levitte <richard@levitte.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LP_SYS_WINCE
/*
* We might want to define LP_MULTIBYTE_AVAILABLE here. It's currently under
* investigation what the exact conditions would be
*/
/* clang-format off */
#include "LPdir_win.c"
/* clang-format on */

View file

@ -19,7 +19,7 @@
#endif
#include "internal/cryptlib.h"
#ifdef _WIN32
#include <windows.h>
#include "internal/e_os.h"
#else
#include <unistd.h>
#endif
@ -69,7 +69,7 @@ uint32_t OPENSSL_rdtsc(void)
/* First determine if getauxval() is available (OSSL_IMPLEMENT_GETAUXVAL) */
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
void OPENSSL_cpuid_setup(void) __attribute__((constructor));
#endif
@ -415,15 +415,52 @@ void OPENSSL_cpuid_setup(void)
if (OPENSSL_armcap_P & ARMV8_CPUID)
OPENSSL_arm_midr = _armv8_cpuid_probe();
if ((MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N1)) && (OPENSSL_armcap_P & ARMV7_NEON)) {
if ((OPENSSL_armcap_P & ARMV7_NEON)
&& (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N1)))
OPENSSL_armv8_rsa_neonized = 1;
}
if ((MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V1) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N2) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_QCOMM, QCOM_CPU_PART_ORYON_X1) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_MICROSOFT, MICROSOFT_CPU_PART_COBALT_100) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V2) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N3) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3_AE) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3) || MIDR_IMPLEMENTER(OPENSSL_arm_midr) == ARM_CPU_IMP_AMPERE) && (OPENSSL_armcap_P & ARMV8_SHA3))
if ((OPENSSL_armcap_P & ARMV8_SHA3)
&& (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V1)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N2)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_QCOMM, QCOM_CPU_PART_ORYON_X1)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_MICROSOFT, MICROSOFT_CPU_PART_COBALT_100)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V2)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N3)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3_AE)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3)
|| MIDR_IMPLEMENTER(OPENSSL_arm_midr) == ARM_CPU_IMP_AMPERE
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_OLYMPUS)))
OPENSSL_armcap_P |= ARMV8_UNROLL8_EOR3;
if ((MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V1) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V2) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3_AE) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N2) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N3) || MIDR_IMPLEMENTER(OPENSSL_arm_midr) == ARM_CPU_IMP_AMPERE || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_OLYMPUS)) && (OPENSSL_armcap_P & ARMV8_SHA3))
if ((OPENSSL_armcap_P & ARMV8_SHA3)
&& (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V1)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V2)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3_AE)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V3)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N2)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N3)
|| MIDR_IMPLEMENTER(OPENSSL_arm_midr) == ARM_CPU_IMP_AMPERE
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_OLYMPUS)))
OPENSSL_armcap_P |= ARMV8_UNROLL12_EOR3;
if ((MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_PRO) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_PRO) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_MAX) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_PRO) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_QCOMM, QCOM_CPU_PART_ORYON_X1) || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_OLYMPUS)) && (OPENSSL_armcap_P & ARMV8_SHA3))
if ((OPENSSL_armcap_P & ARMV8_SHA3)
&& (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_PRO)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_PRO)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_MAX)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_PRO)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_QCOMM, QCOM_CPU_PART_ORYON_X1)
|| MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_OLYMPUS)))
OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
if (OPENSSL_armcap_P & ARMV9_SVE2) {
uint64_t vl_bytes = _armv8_sve_get_vl_bytes();

View file

@ -18,7 +18,7 @@
#ifndef OPENSSL_NO_DEPRECATED_4_1
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
{
return ASN1_STRING_set(x, d, len);
return ossl_asn1_string_set_internal(x, d, len, /*add_nul_byte=*/0);
}
#endif
@ -263,8 +263,9 @@ int ASN1_BIT_STRING_set1(ASN1_BIT_STRING *abs, const uint8_t *data, size_t lengt
if (length > 0 && (data[length - 1] & ((1 << unused_bits) - 1)) != 0)
return 0;
if (!ASN1_STRING_set(abs, data, (int)length))
if (!ossl_asn1_string_set_internal(abs, data, (int)length, /*add_nul_byte=*/0))
return 0;
abs->type = V_ASN1_BIT_STRING;
ossl_asn1_bit_string_set_unused_bits(abs, unused_bits);

View file

@ -1,5 +1,5 @@
/*
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@ -141,7 +141,20 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
i = BIO_read(in, &(b->data[len]), (int)want);
if (i <= 0) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_NOT_ENOUGH_DATA);
/*
* A read error (i < 0), an EOF in the middle of an object
* (diff != 0, some bytes already buffered), or an EOF while
* still inside an indefinite-length constructed value awaiting
* its end-of-contents octets (eos != 0) all mean the input is
* truncated. Only a clean EOF at a top-level object boundary
* (i == 0, diff == 0, eos == 0) is the normal end of input:
* fail without queuing an error so that callers looping over
* concatenated DER values (e.g. the libcrypto d2i_*_bio()
* consumers in CPython's ssl module) terminate cleanly instead
* of seeing a spurious ASN1_R_NOT_ENOUGH_DATA.
*/
if (i < 0 || diff != 0 || eos != 0)
ERR_raise(ERR_LIB_ASN1, ASN1_R_NOT_ENOUGH_DATA);
goto err;
}

View file

@ -316,7 +316,7 @@ ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
} else
ret = *a;
if (r > INT_MAX || ASN1_STRING_set(ret, NULL, (int)r) == 0) {
if (ASN1_STRING_set_data(ret, NULL, r) == 0) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto err;
}
@ -371,7 +371,7 @@ static int asn1_string_set_int64(ASN1_STRING *a, int64_t r, int itype)
off = asn1_put_uint64(tbuf, r);
a->type &= ~V_ASN1_NEG;
}
return ASN1_STRING_set(a, tbuf + off, (int)(sizeof(tbuf) - off));
return ASN1_STRING_set_data(a, tbuf + off, (sizeof(tbuf) - off));
}
static int asn1_string_get_uint64(uint64_t *pr, const ASN1_STRING *a,
@ -399,7 +399,7 @@ static int asn1_string_set_uint64(ASN1_STRING *a, uint64_t r, int itype)
a->type = itype;
off = asn1_put_uint64(tbuf, r);
return ASN1_STRING_set(a, tbuf + off, (int)(sizeof(tbuf) - off));
return ASN1_STRING_set_data(a, tbuf + off, (sizeof(tbuf) - off));
}
/*
@ -503,7 +503,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
if (len == 0)
len = 1;
if (ASN1_STRING_set(ret, NULL, len) == 0) {
if (ASN1_STRING_set_data(ret, NULL, len) == 0) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto err;
}

View file

@ -69,6 +69,9 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
if (len < 0) {
ERR_raise(ERR_LIB_ASN1, ERR_R_PASSED_INVALID_ARGUMENT);
return -1;
} else if (len >= INT_MAX) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG);
return -1;
}
/* First do a string check and work out the number of characters */
@ -168,7 +171,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
}
/* If both the same type just copy across */
if (inform == outform) {
if (!ASN1_STRING_set(dest, in, len)) {
if (!ASN1_STRING_set_data(dest, in, len)) {
if (free_out) {
ASN1_STRING_free(dest);
*out = NULL;
@ -305,7 +308,7 @@ static int out_utf8(uint32_t value, void *arg)
return len;
}
outlen = arg;
if (*outlen > INT_MAX - len) {
if (*outlen >= INT_MAX - len) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG);
return -1;
}

View file

@ -25,5 +25,11 @@ int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
int len)
{
return ASN1_STRING_set(x, d, len);
if (len < -1) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_SMALL);
return 0;
}
if (len == -1)
return ASN1_STRING_set_string(x, (const char *)d);
return ASN1_STRING_set_data(x, d, len);
}

View file

@ -12,6 +12,7 @@
#include "internal/cryptlib.h"
#include "internal/sizes.h"
#include "internal/unicode.h"
#include "internal/safe_math.h"
#include "crypto/asn1.h"
#include <openssl/byteorder.h>
#include <openssl/crypto.h>
@ -31,6 +32,8 @@
#define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_2254 | ASN1_STRFLGS_ESC_QUOTE | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB)
OSSL_SAFE_MATH_SIGNED(int, int)
/*
* Three IO functions for sending data to memory, a BIO and a FILE
* pointer.
@ -142,6 +145,10 @@ static int do_buf(const unsigned char *buf, int buflen,
const unsigned char *p, *q;
uint32_t c;
if (buflen < 0)
return -1;
if (buflen == 0)
return 0;
p = buf;
q = buf + buflen;
outlen = 0;
@ -236,6 +243,10 @@ static int do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf,
unsigned char *p, *q;
char hextmp[2];
if (buflen < 0)
return -1;
if (buflen == 0)
return 0;
if (arg) {
p = buf;
q = buf + buflen;
@ -430,6 +441,7 @@ static int do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n,
char objtmp[80];
const char *objbuf;
int outlen, len;
int err = 0;
char *sep_dn, *sep_mv, *sep_eq;
int sep_dn_len, sep_mv_len, sep_eq_len;
if (indent < 0)
@ -493,14 +505,20 @@ static int do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n,
if (prev == X509_NAME_ENTRY_set(ent)) {
if (!io_ch(arg, sep_mv, sep_mv_len))
return -1;
outlen += sep_mv_len;
outlen = safe_add_int(outlen, sep_mv_len, &err);
if (err != 0)
return -1;
} else {
if (!io_ch(arg, sep_dn, sep_dn_len))
return -1;
outlen += sep_dn_len;
outlen = safe_add_int(outlen, sep_dn_len, &err);
if (err != 0)
return -1;
if (!do_indent(io_ch, arg, indent))
return -1;
outlen += indent;
outlen = safe_add_int(outlen, indent, &err);
if (err != 0)
return -1;
}
}
prev = X509_NAME_ENTRY_set(ent);
@ -531,11 +549,18 @@ static int do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n,
if ((objlen < fld_len) && (flags & XN_FLAG_FN_ALIGN)) {
if (!do_indent(io_ch, arg, fld_len - objlen))
return -1;
outlen += fld_len - objlen;
outlen = safe_add_int(outlen, fld_len - objlen, &err);
if (err != 0)
return -1;
}
if (!io_ch(arg, sep_eq, sep_eq_len))
return -1;
outlen += objlen + sep_eq_len;
outlen = safe_add_int(outlen, objlen, &err);
if (err != 0)
return -1;
outlen = safe_add_int(outlen, sep_eq_len, &err);
if (err != 0)
return -1;
}
/*
* If the field name is unknown then fix up the DER dump flag. We
@ -550,7 +575,9 @@ static int do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n,
len = do_print_ex(io_ch, arg, flags | orflags, val);
if (len < 0)
return -1;
outlen += len;
outlen = safe_add_int(outlen, len, &err);
if (err != 0)
return -1;
}
return outlen;
}

View file

@ -271,7 +271,7 @@ ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
if (tmps == NULL)
return NULL;
if (!ASN1_STRING_set(tmps, NULL, len))
if (!ASN1_STRING_set_data(tmps, NULL, len))
goto err;
tmps->type = type;

View file

@ -651,7 +651,7 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto bad_str;
}
if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) {
if (!ASN1_STRING_set_string(atmp->value.asn1_string, str)) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto bad_str;
}
@ -706,7 +706,7 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
atmp->value.asn1_string->length = rdlen;
atmp->value.asn1_string->type = utype;
} else if (format == ASN1_GEN_FORMAT_ASCII) {
if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) {
if (!ASN1_STRING_set_string(atmp->value.asn1_string, str)) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto bad_str;
}

View file

@ -265,7 +265,8 @@ int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
if (str == NULL)
return 0;
dst->type = str->type;
if (!ASN1_STRING_set(dst, str->data, str->length))
if (!ossl_asn1_string_set_internal(dst, str->data, str->length,
/*add_nul_byte=*/0))
return 0;
/* Copy flags but preserve embed value */
dst->flags &= ASN1_STRING_FLAG_EMBED;
@ -289,12 +290,18 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str)
return ret;
}
int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
int ossl_asn1_string_set_internal(ASN1_STRING *str, const uint8_t *data,
int len_in, int add_nul_byte)
{
unsigned char *c;
const char *data = _data;
size_t len;
size_t len, alloc_len;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/*
* Force no NUL byte for callers that are requesting it
* 0 length object data will be NULL
*/
add_nul_byte = 0;
#endif
if (len_in < -1) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_SMALL);
return 0;
@ -302,16 +309,17 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
if (len_in == -1) {
if (data == NULL)
return 0;
len = strlen(data);
len = strlen((const char *)data);
} else {
len = (size_t)len_in;
}
/*
* Verify that the length fits within an integer for assignment to
* str->length below. The additional 1 is subtracted to allow for the
* '\0' terminator even though this isn't strictly necessary.
* Add one to the length to allow for adding an a '\0' terminator
* "even though this isn't strictly necessary".
*/
if (len > INT_MAX - 1) {
alloc_len = add_nul_byte ? len + 1 : len;
if (alloc_len > INT_MAX) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_LARGE);
return 0;
}
@ -322,39 +330,47 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
str->flags &= ~ASN1_STRING_FLAG_DATA_NOT_OWNED;
}
if ((size_t)str->length <= len || str->data == NULL) {
c = str->data;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* No NUL terminator in fuzzing builds */
str->data = OPENSSL_realloc(c, len != 0 ? len : 1);
#else
str->data = OPENSSL_realloc(c, len + 1);
#endif
if (str->data == NULL) {
str->data = c;
return 0;
}
/* Ensure copying a 0 length data field is defined. */
if (alloc_len == 0) {
OPENSSL_free(str->data);
str->data = NULL;
str->length = 0;
return 1;
}
if ((size_t)str->length != alloc_len) {
uint8_t *c;
c = OPENSSL_realloc(str->length == 0 ? NULL : str->data, alloc_len);
if (c == NULL)
return 0;
str->data = c;
}
/* length never includes the added \0 byte */
str->length = (int)len;
if (data != NULL) {
if (data != NULL && str->data != NULL) {
memcpy(str->data, data, len);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Set the unused byte to something non NUL and printable. */
if (len == 0)
str->data[len] = '~';
#else
/*
* Add a NUL terminator. This should not be necessary - but we add it as
* a safety precaution
*/
str->data[len] = '\0';
#endif
if (add_nul_byte) {
/*
* Add a '\0' terminator. This should not be necessary - but we add it as
* a safety precaution
*/
str->data[len] = '\0';
}
}
ossl_asn1_bit_string_clear_unused_bits(str);
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_4_1
int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
{
return ossl_asn1_string_set_internal(str, (const uint8_t *)_data, len_in,
/*add_nul_byte=*/1);
}
#endif
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
{
if (!(str->flags & ASN1_STRING_FLAG_DATA_NOT_OWNED)) {
@ -365,6 +381,26 @@ void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
str->length = len;
}
int ASN1_STRING_set_data(ASN1_STRING *str, const uint8_t *data, size_t len_in)
{
if (str->type == V_ASN1_BIT_STRING) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
return 0;
}
/* This will go away once ASN1_STRING can size_t internally */
if (len_in > INT_MAX) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_LARGE);
return 0;
}
return ossl_asn1_string_set_internal(str, data, (int)len_in, /*add_nul_byte=*/0);
}
int ASN1_STRING_set_string(ASN1_STRING *str, const char *c_string)
{
return ASN1_STRING_set_data(str, (const uint8_t *)c_string,
strlen(c_string));
}
ASN1_STRING *ASN1_STRING_new(void)
{
return ASN1_STRING_type_new(V_ASN1_OCTET_STRING);
@ -469,10 +505,17 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
}
}
#ifndef OPENSSL_NO_DEPRECATED_4_1
int ASN1_STRING_length(const ASN1_STRING *x)
{
return x->length;
}
#endif
size_t ASN1_STRING_length_ex(const ASN1_STRING *x)
{
return (size_t)x->length;
}
#ifndef OPENSSL_NO_DEPRECATED_3_0
void ASN1_STRING_length_set(ASN1_STRING *x, int len)
@ -509,7 +552,7 @@ char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text,
current = sk_ASN1_UTF8STRING_value(text, i);
if (i > 0)
length += sep_len;
length += ASN1_STRING_length(current);
length += ASN1_STRING_length_ex(current);
if (max_len != 0 && length > max_len)
return NULL;
}
@ -519,7 +562,7 @@ char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text,
p = result;
for (i = 0; i < sk_ASN1_UTF8STRING_num(text); i++) {
current = sk_ASN1_UTF8STRING_value(text, i);
length = ASN1_STRING_length(current);
length = ASN1_STRING_length_ex(current);
if (i > 0 && sep_len > 0) {
strncpy(p, sep, sep_len + 1); /* using + 1 to silence gcc warning */
p += sep_len;

View file

@ -12,6 +12,7 @@
#if !defined(OSSL_LIBCRYPTO_ASN1_ASN1_LOCAL_H)
#define OSSL_LIBCRYPTO_ASN1_ASN1_LOCAL_H
#include <openssl/asn1t.h>
#include "crypto/asn1.h"
typedef const ASN1_VALUE const_ASN1_VALUE;
@ -99,5 +100,9 @@ int ossl_asn1_item_ex_new_intern(ASN1_VALUE **pval, const ASN1_ITEM *it,
OSSL_LIB_CTX *libctx, const char *propq);
int ossl_asn1_time_time_t_to_tm(const time_t *time, struct tm *out_tm);
int ossl_asn1_time_tm_to_time_t(const struct tm *tm, time_t *out);
int ossl_asn1_call_aux_cb(const ASN1_AUX *aux, int operation,
const ASN1_VALUE **in, const ASN1_ITEM *it, void *exarg);
int ossl_asn1_string_set_internal(ASN1_STRING *str, const uint8_t *data,
int len_in, int add_nul_byte);
#endif /* !defined(OSSL_LIBCRYPTO_ASN1_ASN1_LOCAL_H) */

View file

@ -34,6 +34,7 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len)
{
int ret, num;
size_t tmp;
const unsigned char *p;
if ((a->type != V_ASN1_OCTET_STRING) || (a->value.octet_string == NULL)) {
@ -41,7 +42,13 @@ int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_l
return -1;
}
p = ASN1_STRING_get0_data(a->value.octet_string);
ret = ASN1_STRING_length(a->value.octet_string);
tmp = ASN1_STRING_length_ex(a->value.octet_string);
if (tmp > INT_MAX) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_LARGE);
return -1;
}
ret = (int)tmp;
if (ret < max_len)
num = ret;
else
@ -69,11 +76,19 @@ static ossl_inline void asn1_type_init_oct(ASN1_OCTET_STRING *oct,
static int asn1_type_get_int_oct(ASN1_OCTET_STRING *oct, int32_t anum,
long *num, unsigned char *data, int max_len)
{
int ret = ASN1_STRING_length(oct), n;
int ret, n;
size_t tmp;
if (num != NULL)
*num = anum;
tmp = ASN1_STRING_length_ex(oct);
if (tmp > INT_MAX)
tmp = INT_MAX;
ret = (int)tmp;
if (max_len > ret)
n = ret;
else

View file

@ -173,7 +173,7 @@ static X509_ALGOR *pkcs5_scrypt_set(const unsigned char *salt, int saltlen,
saltlen = PKCS5_DEFAULT_PBE2_SALT_LEN;
/* This will either copy salt or grow the buffer */
if (ASN1_STRING_set(sparam->salt, salt, saltlen) == 0) {
if (ASN1_STRING_set_data(sparam->salt, salt, saltlen) == 0) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
goto err;
}

View file

@ -72,11 +72,13 @@ int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,
const unsigned char **pk, int *ppklen,
const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8)
{
if (ASN1_STRING_length_ex(p8->pkey) > INT_MAX)
return 0;
if (ppkalg)
*ppkalg = p8->pkeyalg->algorithm;
if (pk) {
*pk = ASN1_STRING_get0_data(p8->pkey);
*ppklen = ASN1_STRING_length(p8->pkey);
*ppklen = (int)ASN1_STRING_length_ex(p8->pkey);
}
if (pa)
*pa = p8->pkeyalg;

View file

@ -983,7 +983,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, long len,
ASN1_STRING_set0(stmp, (unsigned char *)cont /* UGLY CAST! */, ilen);
*free_cont = 0;
} else {
if (!ASN1_STRING_set(stmp, cont, ilen)) {
if (!ASN1_STRING_set_data(stmp, cont, len)) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
ASN1_STRING_free(stmp);
*pval = NULL;

View file

@ -85,16 +85,10 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
int i, seqcontlen, seqlen, ndef = 1;
const ASN1_EXTERN_FUNCS *ef;
const ASN1_AUX *aux = it->funcs;
ASN1_aux_const_cb *asn1_cb = NULL;
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && *pval == NULL)
return 0;
if (aux != NULL) {
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
}
switch (it->itype) {
case ASN1_ITYPE_PRIMITIVE:
@ -123,7 +117,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
ERR_raise(ERR_LIB_ASN1, ASN1_R_BAD_TEMPLATE);
return -1;
}
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
if (!ossl_asn1_call_aux_cb(aux, ASN1_OP_I2D_PRE, pval, it, NULL))
return 0;
i = ossl_asn1_get_choice_selector_const(pval, it);
if ((i >= 0) && (i < it->tcount)) {
@ -134,7 +128,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);
}
/* Fixme: error condition if selector out of range */
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
if (!ossl_asn1_call_aux_cb(aux, ASN1_OP_I2D_POST, pval, it, NULL))
return 0;
break;
@ -166,7 +160,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
| V_ASN1_UNIVERSAL;
}
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
if (!ossl_asn1_call_aux_cb(aux, ASN1_OP_I2D_PRE, pval, it, NULL))
return 0;
/* First work out sequence content length */
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
@ -200,7 +194,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
}
if (ndef == 2)
ASN1_put_eoc(out);
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
if (!ossl_asn1_call_aux_cb(aux, ASN1_OP_I2D_POST, pval, it, NULL))
return 0;
return seqlen;

View file

@ -138,15 +138,12 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
const ASN1_EXTERN_FUNCS *ef;
const ASN1_VALUE **tmpfld;
const ASN1_AUX *aux = it->funcs;
ASN1_aux_const_cb *asn1_cb = NULL;
ASN1_PRINT_ARG parg;
int i;
if (aux != NULL) {
parg.out = out;
parg.indent = indent;
parg.pctx = pctx;
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
}
if (((it->itype != ASN1_ITYPE_PRIMITIVE)
@ -220,13 +217,11 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
}
}
if (asn1_cb) {
i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg);
if (i == 0)
return 0;
if (i == 2)
return 1;
}
i = ossl_asn1_call_aux_cb(aux, ASN1_OP_PRINT_PRE, fld, it, &parg);
if (i == 0)
return 0;
if (i == 2)
return 1;
/* Print each field entry */
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
@ -244,11 +239,9 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
return 0;
}
if (asn1_cb) {
i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg);
if (i == 0)
return 0;
}
i = ossl_asn1_call_aux_cb(aux, ASN1_OP_PRINT_POST, fld, it, &parg);
if (i == 0)
return 0;
break;
default:

View file

@ -288,3 +288,19 @@ err:
ERR_raise(ERR_LIB_ASN1, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE);
return NULL;
}
int ossl_asn1_call_aux_cb(const ASN1_AUX *aux, int operation,
const ASN1_VALUE **in, const ASN1_ITEM *it, void *exarg)
{
if (aux == NULL)
return 1;
if ((aux->flags & ASN1_AFLG_CONST_CB) != 0) {
if (aux->asn1_const_cb != NULL)
return aux->asn1_const_cb(operation, in, it, exarg);
} else if (aux->asn1_cb != NULL) {
return aux->asn1_cb(operation, (ASN1_VALUE **)in, it, exarg);
}
return 1;
}

View file

@ -12,7 +12,7 @@
#ifdef ASYNC_WIN
#include <windows.h>
#include "internal/e_os.h"
#include "internal/cryptlib.h"
int ASYNC_is_capable(void)

View file

@ -21,6 +21,7 @@
#include <openssl/crypto.h>
#include <openssl/e_os2.h>
#include <internal/e_os.h>
typedef struct async_ctx_st async_ctx;
typedef struct async_pool_st async_pool;
@ -29,7 +30,6 @@ typedef struct async_pool_st async_pool;
#define ASYNC_WIN
#define ASYNC_ARCH
#include <windows.h>
#include "internal/cryptlib.h"
typedef struct async_fibre_st {

View file

@ -116,24 +116,22 @@ BIO *BIO_new(const BIO_METHOD *method)
return BIO_new_ex(NULL, method);
}
int BIO_free(BIO *a)
static int BIO_free_int(BIO *a, int *ret)
{
int ret;
if (a == NULL)
return 0;
if (CRYPTO_DOWN_REF(&a->references, &ret) <= 0)
if (CRYPTO_DOWN_REF(&a->references, ret) <= 0)
return 0;
REF_PRINT_COUNT("BIO", ret, a);
if (ret > 0)
REF_PRINT_COUNT("BIO", *ret, a);
if (*ret > 0)
return 1;
REF_ASSERT_ISNT(ret < 0);
REF_ASSERT_ISNT(*ret < 0);
if (HAS_CALLBACK(a)) {
ret = (int)bio_call_callback(a, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL);
if (ret <= 0)
if ((int)bio_call_callback(a, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL) <= 0)
return 0;
}
@ -149,6 +147,13 @@ int BIO_free(BIO *a)
return 1;
}
int BIO_free(BIO *b)
{
int ref;
return BIO_free_int(b, &ref);
}
void BIO_set_data(BIO *a, void *ptr)
{
a->ptr = ptr;
@ -188,7 +193,7 @@ int BIO_up_ref(BIO *a)
{
int i;
if (CRYPTO_UP_REF(&a->references, &i) <= 0)
if (!CRYPTO_UP_REF(&a->references, &i))
return 0;
REF_PRINT_COUNT("BIO", i, a);
@ -874,11 +879,11 @@ void BIO_free_all(BIO *bio)
while (bio != NULL) {
b = bio;
CRYPTO_GET_REF(&b->references, &ref);
bio = bio->next_bio;
BIO_free(b);
/* Since ref count > 1, don't free anyone else. */
if (ref > 1)
ref = 0;
BIO_free_int(b, &ref);
/* Since ref count > 0, don't free anyone else. */
if (ref > 0)
break;
}
}

View file

@ -74,6 +74,7 @@ struct bio_addrinfo_st {
#include "internal/cryptlib.h"
#include "internal/bio.h"
#include "internal/refcount.h"
#include "internal/time.h"
typedef struct bio_f_buffer_ctx_struct {
/*-
@ -122,6 +123,87 @@ struct bio_st {
};
#ifndef OPENSSL_NO_SOCK
typedef struct bio_connect_st {
int state;
int connect_family;
int connect_sock_type;
char *param_hostname;
char *param_service;
int connect_mode;
#ifndef OPENSSL_NO_KTLS
unsigned char record_type;
#endif
int tfo_first;
BIO_ADDRINFO *addr_first;
const BIO_ADDRINFO *addr_iter;
/*
* int socket; this will be kept in bio->num so that it is compatible
* with the bss_sock bio
*/
/*
* called when the connection is initially made callback(BIO,state,ret);
* The callback should return 'ret'. state is for compatibility with the
* ssl info_callback
*/
BIO_info_cb *info_callback;
/*
* Used when connect_sock_type is SOCK_DGRAM. Owned by us; we forward
* read/write(mmsg) calls to this if present.
*/
BIO *dgram_bio;
} BIO_CONNECT;
typedef struct bio_accept_st {
int state;
int accept_family;
int bind_mode; /* Socket mode for BIO_listen */
int accepted_mode; /* Socket mode for BIO_accept (set on accepted sock) */
char *param_addr;
char *param_serv;
int accept_sock;
BIO_ADDRINFO *addr_first;
const BIO_ADDRINFO *addr_iter;
BIO_ADDR cache_accepting_addr; /* Useful if we asked for port 0 */
char *cache_accepting_name, *cache_accepting_serv;
BIO_ADDR cache_peer_addr;
char *cache_peer_name, *cache_peer_serv;
BIO *bio_chain;
} BIO_ACCEPT;
#ifndef OPENSSL_NO_DGRAM
typedef struct bio_dgram_data_st {
BIO_ADDR peer;
BIO_ADDR local_addr;
unsigned int connected;
unsigned int _errno;
unsigned int mtu;
OSSL_TIME next_timeout;
OSSL_TIME socket_timeout;
unsigned int peekmode;
char local_addr_enabled;
} bio_dgram_data;
#endif
#define BIO_CONN_S_BEFORE 1
#define BIO_CONN_S_GET_ADDR 2
#define BIO_CONN_S_CREATE_SOCKET 3
#define BIO_CONN_S_CONNECT 4
#define BIO_CONN_S_OK 5
#define BIO_CONN_S_BLOCKED_CONNECT 6
#define BIO_CONN_S_CONNECT_ERROR 7
#define BIO_ACPT_S_BEFORE 1
#define BIO_ACPT_S_GET_ADDR 2
#define BIO_ACPT_S_CREATE_SOCKET 3
#define BIO_ACPT_S_LISTEN 4
#define BIO_ACPT_S_ACCEPT 5
#define BIO_ACPT_S_OK 6
#ifdef OPENSSL_SYS_VMS
typedef unsigned int socklen_t;
#endif

View file

@ -111,7 +111,7 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args)
*/
sz = vsnprintf(buf, sizeof(buf), format, args);
if (sz >= 0) {
if ((size_t)sz > sizeof(buf)) {
if ((size_t)sz >= sizeof(buf)) {
sz += 1;
abuf = (char *)OPENSSL_malloc(sz);
if (abuf == NULL) {

View file

@ -15,26 +15,6 @@
#ifndef OPENSSL_NO_SOCK
typedef struct bio_accept_st {
int state;
int accept_family;
int bind_mode; /* Socket mode for BIO_listen */
int accepted_mode; /* Socket mode for BIO_accept (set on accepted sock) */
char *param_addr;
char *param_serv;
int accept_sock;
BIO_ADDRINFO *addr_first;
const BIO_ADDRINFO *addr_iter;
BIO_ADDR cache_accepting_addr; /* Useful if we asked for port 0 */
char *cache_accepting_name, *cache_accepting_serv;
BIO_ADDR cache_peer_addr;
char *cache_peer_name, *cache_peer_serv;
BIO *bio_chain;
} BIO_ACCEPT;
static int acpt_write(BIO *h, const char *buf, int num);
static int acpt_read(BIO *h, char *buf, int size);
static int acpt_puts(BIO *h, const char *str);
@ -46,13 +26,6 @@ static void acpt_close_socket(BIO *data);
static BIO_ACCEPT *BIO_ACCEPT_new(void);
static void BIO_ACCEPT_free(BIO_ACCEPT *a);
#define ACPT_S_BEFORE 1
#define ACPT_S_GET_ADDR 2
#define ACPT_S_CREATE_SOCKET 3
#define ACPT_S_LISTEN 4
#define ACPT_S_ACCEPT 5
#define ACPT_S_OK 6
static const BIO_METHOD methods_acceptp = {
BIO_TYPE_ACCEPT,
"socket accept",
@ -83,7 +56,7 @@ static int acpt_new(BIO *bi)
if ((ba = BIO_ACCEPT_new()) == NULL)
return 0;
bi->ptr = (char *)ba;
ba->state = ACPT_S_BEFORE;
ba->state = BIO_ACPT_S_BEFORE;
bi->shutdown = 1;
return 1;
}
@ -152,7 +125,7 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
for (;;) {
switch (c->state) {
case ACPT_S_BEFORE:
case BIO_ACPT_S_BEFORE:
if (c->param_addr == NULL && c->param_serv == NULL) {
ERR_raise_data(ERR_LIB_BIO,
BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED,
@ -174,10 +147,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
OPENSSL_free(c->cache_peer_serv);
c->cache_peer_serv = NULL;
c->state = ACPT_S_GET_ADDR;
c->state = BIO_ACPT_S_GET_ADDR;
break;
case ACPT_S_GET_ADDR: {
case BIO_ACPT_S_GET_ADDR: {
int family = AF_UNSPEC;
switch (c->accept_family) {
case BIO_FAMILY_IPV6:
@ -213,10 +186,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
goto exit_loop;
}
c->addr_iter = c->addr_first;
c->state = ACPT_S_CREATE_SOCKET;
c->state = BIO_ACPT_S_CREATE_SOCKET;
break;
case ACPT_S_CREATE_SOCKET:
case BIO_ACPT_S_CREATE_SOCKET:
ERR_set_mark();
s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
BIO_ADDRINFO_socktype(c->addr_iter),
@ -238,11 +211,11 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
}
c->accept_sock = s;
b->num = s;
c->state = ACPT_S_LISTEN;
c->state = BIO_ACPT_S_LISTEN;
s = -1;
break;
case ACPT_S_LISTEN: {
case BIO_ACPT_S_LISTEN: {
if (!BIO_listen(c->accept_sock,
BIO_ADDRINFO_address(c->addr_iter),
c->bind_mode)) {
@ -271,14 +244,14 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
OPENSSL_free(c->cache_accepting_serv);
c->cache_accepting_name = BIO_ADDR_hostname_string(&c->cache_accepting_addr, 1);
c->cache_accepting_serv = BIO_ADDR_service_string(&c->cache_accepting_addr, 1);
c->state = ACPT_S_ACCEPT;
c->state = BIO_ACPT_S_ACCEPT;
s = -1;
ret = 1;
goto end;
case ACPT_S_ACCEPT:
case BIO_ACPT_S_ACCEPT:
if (b->next_bio != NULL) {
c->state = ACPT_S_OK;
c->state = BIO_ACPT_S_OK;
break;
}
BIO_clear_retry_flags(b);
@ -334,14 +307,14 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
c->cache_peer_name = BIO_ADDR_hostname_string(&c->cache_peer_addr, 1);
c->cache_peer_serv = BIO_ADDR_service_string(&c->cache_peer_addr, 1);
c->state = ACPT_S_OK;
c->state = BIO_ACPT_S_OK;
bio = NULL;
ret = 1;
goto end;
case ACPT_S_OK:
case BIO_ACPT_S_OK:
if (b->next_bio == NULL) {
c->state = ACPT_S_ACCEPT;
c->state = BIO_ACPT_S_ACCEPT;
break;
}
ret = 1;
@ -412,7 +385,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
switch (cmd) {
case BIO_CTRL_RESET:
ret = 0;
data->state = ACPT_S_BEFORE;
data->state = BIO_ACPT_S_BEFORE;
acpt_close_socket(b);
BIO_ADDRINFO_free(data->addr_first);
data->addr_first = NULL;
@ -474,7 +447,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_C_SET_FD:
b->num = *((int *)ptr);
data->accept_sock = b->num;
data->state = ACPT_S_ACCEPT;
data->state = BIO_ACPT_S_ACCEPT;
b->shutdown = (int)num;
b->init = 1;
break;

View file

@ -16,37 +16,6 @@
#ifndef OPENSSL_NO_SOCK
typedef struct bio_connect_st {
int state;
int connect_family;
int connect_sock_type;
char *param_hostname;
char *param_service;
int connect_mode;
#ifndef OPENSSL_NO_KTLS
unsigned char record_type;
#endif
int tfo_first;
BIO_ADDRINFO *addr_first;
const BIO_ADDRINFO *addr_iter;
/*
* int socket; this will be kept in bio->num so that it is compatible
* with the bss_sock bio
*/
/*
* called when the connection is initially made callback(BIO,state,ret);
* The callback should return 'ret'. state is for compatibility with the
* ssl info_callback
*/
BIO_info_cb *info_callback;
/*
* Used when connect_sock_type is SOCK_DGRAM. Owned by us; we forward
* read/write(mmsg) calls to this if present.
*/
BIO *dgram_bio;
} BIO_CONNECT;
static int conn_write(BIO *h, const char *buf, int num);
static int conn_read(BIO *h, char *buf, int size);
static int conn_puts(BIO *h, const char *str);
@ -65,14 +34,6 @@ static void conn_close_socket(BIO *data);
static BIO_CONNECT *BIO_CONNECT_new(void);
static void BIO_CONNECT_free(BIO_CONNECT *a);
#define BIO_CONN_S_BEFORE 1
#define BIO_CONN_S_GET_ADDR 2
#define BIO_CONN_S_CREATE_SOCKET 3
#define BIO_CONN_S_CONNECT 4
#define BIO_CONN_S_OK 5
#define BIO_CONN_S_BLOCKED_CONNECT 6
#define BIO_CONN_S_CONNECT_ERROR 7
static const BIO_METHOD methods_connectp = {
BIO_TYPE_CONNECT,
"socket connect",

View file

@ -14,7 +14,6 @@
#include <stdio.h>
#include <errno.h>
#include "internal/time.h"
#include "bio_local.h"
#ifndef OPENSSL_NO_DGRAM
@ -213,21 +212,7 @@ static const BIO_METHOD methods_dgramp_sctp = {
NULL, /* sendmmsg */
NULL, /* recvmmsg */
};
#endif
typedef struct bio_dgram_data_st {
BIO_ADDR peer;
BIO_ADDR local_addr;
unsigned int connected;
unsigned int _errno;
unsigned int mtu;
OSSL_TIME next_timeout;
OSSL_TIME socket_timeout;
unsigned int peekmode;
char local_addr_enabled;
} bio_dgram_data;
#ifndef OPENSSL_NO_SCTP
typedef struct bio_dgram_sctp_save_message_st {
BIO *bio;
char *data;

View file

@ -332,7 +332,13 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
/* the ptr parameter is actually a FILE ** in this case. */
if (ptr != NULL) {
fpp = (FILE **)ptr;
*fpp = (FILE *)b->ptr;
if (BIO_FLAGS_UPLINK_INTERNAL == 0
|| b->flags & BIO_FLAGS_UPLINK_INTERNAL) {
*fpp = (FILE *)b->ptr;
} else { /* avoid returning internal FILE * to the app */
*fpp = NULL;
ret = 0;
}
}
break;
case BIO_CTRL_GET_CLOSE:

View file

@ -22,8 +22,7 @@
#include "bio_local.h"
#include "internal/cryptlib.h"
#if defined(OPENSSL_SYS_WINCE)
#elif defined(OPENSSL_SYS_WIN32)
#if defined(OPENSSL_SYS_WIN32)
#elif defined(__wasi__)
#define NO_SYSLOG
#elif defined(OPENSSL_SYS_VMS)

View file

@ -8,7 +8,7 @@
*/
#include "../bn_local.h"
#if !(defined(__GNUC__) && __GNUC__ >= 2)
#if !defined(__GNUC__)
/* clang-format off */
# include "../bn_asm.c" /* kind of dirty hack for Sun Studio */
/* clang-format on */

View file

@ -97,6 +97,8 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
return 0;
r->top = max;
if (max == 0)
goto end;
ap = a->d;
bp = b->d;
@ -116,6 +118,7 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
*rp = carry;
r->top += (int)carry;
end:
r->neg = 0;
bn_check_top(r);
return 1;
@ -143,6 +146,9 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
if (bn_wexpand(r, max) == NULL)
return 0;
if (max == 0)
goto end;
ap = a->d;
bp = b->d;
rp = r->d;
@ -162,6 +168,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
while (max && *--rp == 0)
max--;
end:
r->top = max;
r->neg = 0;
bn_pollute(r);

View file

@ -160,7 +160,7 @@ static int bn_left_align(BIGNUM *num)
#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
&& !defined(PEDANTIC) && !defined(BN_DIV3W)
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
#if defined(__i386) || defined(__i386__)
/*-
* There were two reasons for implementing this template:

View file

@ -1,5 +1,5 @@
/*
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@ -89,15 +89,6 @@ const BIGNUM *BN_value_one(void)
return &const_one;
}
/*
* Old Visual Studio ARM compiler miscompiles BN_num_bits_word()
* https://mta.openssl.org/pipermail/openssl-users/2018-August/008465.html
*/
#if defined(_MSC_VER) && defined(_ARM_) && defined(_WIN32_WCE) \
&& _MSC_VER >= 1400 && _MSC_VER < 1501
#define MS_BROKEN_BN_num_bits_word
#pragma optimize("", off)
#endif
int BN_num_bits_word(BN_ULONG l)
{
BN_ULONG x, mask;
@ -142,9 +133,6 @@ int BN_num_bits_word(BN_ULONG l)
return bits;
}
#ifdef MS_BROKEN_BN_num_bits_word
#pragma optimize("", on)
#endif
/*
* This function still leaks `a->dmax`: it's caller's responsibility to
@ -708,19 +696,37 @@ int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
int i;
BN_ULONG t1, t2, *ap, *bp;
/*
* As it is a public API function, we should handle NULL parameters in
* some way. The function cant return an error, so lets define that NULL
* is less than any BIGNUM.
*/
if (!ossl_assert(a != NULL && b != NULL))
return (b == NULL) - (a == NULL);
ap = a->d;
bp = b->d;
if (BN_get_flags(a, BN_FLG_CONSTTIME)
&& a->top == b->top) {
|| BN_get_flags(b, BN_FLG_CONSTTIME)) {
int res = 0;
int min_top = a->top < b->top ? a->top : b->top;
for (i = 0; i < b->top; i++) {
for (i = 0; i < min_top; i++) {
res = constant_time_select_int((int)constant_time_lt_bn(ap[i], bp[i]),
-1, res);
res = constant_time_select_int((int)constant_time_lt_bn(bp[i], ap[i]),
1, res);
}
for (i = min_top; i < a->top; ++i)
res = constant_time_select_int((int)constant_time_is_zero_bn(ap[i]),
res, 1);
for (i = min_top; i < b->top; ++i)
res = constant_time_select_int((int)constant_time_is_zero_bn(bp[i]),
res, -1);
return res;
}

View file

@ -380,7 +380,7 @@ struct bn_gencb_st {
#if defined(__DECC)
#include <c_asm.h>
#define BN_UMULT_HIGH(a, b) (BN_ULONG)asm("umulh %a0,%a1,%v0", (a), (b))
#elif defined(__GNUC__) && __GNUC__ >= 2
#elif defined(__GNUC__)
#define BN_UMULT_HIGH(a, b) ({ \
register BN_ULONG ret; \
asm ("umulh %1,%2,%0" \
@ -389,7 +389,7 @@ struct bn_gencb_st {
ret; })
#endif /* compiler */
#elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG)
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
#define BN_UMULT_HIGH(a, b) ({ \
register BN_ULONG ret; \
asm ("mulhdu %0,%1,%2" \
@ -398,7 +398,7 @@ struct bn_gencb_st {
ret; })
#endif /* compiler */
#elif (defined(__x86_64) || defined(__x86_64__)) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
#define BN_UMULT_HIGH(a, b) ({ \
register BN_ULONG ret,discard; \
asm ("mulq %3" \
@ -422,7 +422,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
#define BN_UMULT_LOHI(low, high, a, b) ((low) = _umul128((a), (b), &(high)))
#endif
#elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
#define BN_UMULT_HIGH(a, b) ({ \
register BN_ULONG ret; \
asm ("dmultu %1,%2" \
@ -435,7 +435,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
: "r"(a), "r"(b));
#endif
#elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)
#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__GNUC__)
#define BN_UMULT_HIGH(a, b) ({ \
register BN_ULONG ret; \
asm ("umulh %0,%1,%2" \

View file

@ -20,16 +20,20 @@
#include <unistd.h>
#include <errno.h>
/*
* Returns 1 for success, 0 for failure, and -1 to tell the caller to use the
* SW-fallback.
*/
static int s390x_mod_exp_hw(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m)
{
struct ica_rsa_modexpo me;
unsigned char *buffer;
size_t size;
int res = 0;
int res = -1;
if (OPENSSL_s390xcex == -1 || OPENSSL_s390xcex_nodev)
return 0;
return -1;
size = BN_num_bytes(m);
buffer = OPENSSL_calloc(size, 4);
if (buffer == NULL)
@ -42,11 +46,15 @@ static int s390x_mod_exp_hw(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
me.n_modulus = buffer + 3 * size;
if (BN_bn2binpad(a, me.inputdata, size) == -1
|| BN_bn2binpad(p, me.b_key, size) == -1
|| BN_bn2binpad(m, me.n_modulus, size) == -1)
|| BN_bn2binpad(m, me.n_modulus, size) == -1) {
res = 0;
goto dealloc;
}
if (ioctl(OPENSSL_s390xcex, ICARSAMODEXPO, &me) != -1) {
if (BN_bin2bn(me.outputdata, size, r) != NULL)
res = 1;
else
res = 0;
} else if (errno == EBADF || errno == ENOTTY) {
/*
* In this cases, someone (e.g. a sandbox) closed the fd.
@ -71,27 +79,34 @@ dealloc:
int s390x_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
{
if (s390x_mod_exp_hw(r, a, p, m) == 1)
return 1;
return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
int rc;
rc = s390x_mod_exp_hw(r, a, p, m);
if (rc < 0)
return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
return rc;
}
/*
* Returns 1 for success, 0 for failure, and -1 to tell the caller to use the
* SW-fallback.
*/
int s390x_crt(BIGNUM *r, const BIGNUM *i, const BIGNUM *p, const BIGNUM *q,
const BIGNUM *dmp, const BIGNUM *dmq, const BIGNUM *iqmp)
{
struct ica_rsa_modexpo_crt crt;
unsigned char *buffer, *part;
size_t size, plen, qlen;
int res = 0;
int res = -1;
if (OPENSSL_s390xcex == -1 || OPENSSL_s390xcex_nodev)
return 0;
return -1;
/*-
* Hardware-accelerated CRT can only deal with p>q. Fall back to
* software in the (hopefully rare) other cases.
*/
if (BN_ucmp(p, q) != 1)
return 0;
return -1;
plen = BN_num_bytes(p);
qlen = BN_num_bytes(q);
size = (plen > qlen ? plen : qlen);
@ -119,11 +134,15 @@ int s390x_crt(BIGNUM *r, const BIGNUM *i, const BIGNUM *p, const BIGNUM *q,
|| BN_bn2binpad(q, crt.nq_prime, size) == -1
|| BN_bn2binpad(dmp, crt.bp_key, size + 8) == -1
|| BN_bn2binpad(dmq, crt.bq_key, size) == -1
|| BN_bn2binpad(iqmp, crt.u_mult_inv, size + 8) == -1)
|| BN_bn2binpad(iqmp, crt.u_mult_inv, size + 8) == -1) {
res = 0;
goto dealloc;
}
if (ioctl(OPENSSL_s390xcex, ICARSACRT, &crt) != -1) {
if (BN_bin2bn(crt.outputdata, crt.outputdatalength, r) != NULL)
res = 1;
else
res = 0;
} else if (errno == EBADF || errno == ENOTTY) {
/*
* In this cases, someone (e.g. a sandbox) closed the fd.

View file

@ -16,7 +16,6 @@ IF[{- !$disabled{uplink} -}]
$UPLINKSRC_common=../ms/uplink.c
$UPLINKSRC_x86=$UPLINKSRC_common uplink-x86.S
$UPLINKSRC_x86_64=$UPLINKSRC_common uplink-x86_64.s
$UPLINKSRC_ia64=$UPLINKSRC_common uplink-ia64.s
IF[$UPLINKSRC_{- $target{uplink_arch} -}]
$UPLINKSRC=$UPLINKSRC_{- $target{uplink_arch} -}
@ -118,7 +117,6 @@ GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "
GENERATE[uplink-x86.S]=../ms/uplink-x86.pl
GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl
GENERATE[uplink-ia64.s]=../ms/uplink-ia64.pl
GENERATE[x86cpuid.S]=x86cpuid.pl
DEPEND[x86cpuid.s]=perlasm/x86asm.pl

View file

@ -24,7 +24,7 @@ typedef union {
#define ROTATE(v, n) (((v) << (n)) | ((v) >> (32 - (n))))
#ifndef PEDANTIC
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
#if defined(__GNUC__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
#if defined(__riscv_zbb) || defined(__riscv_zbkb)
#if __riscv_xlen == 64
#undef ROTATE

View file

@ -819,7 +819,7 @@ int ossl_cmp_X509_STORE_add1_certs(X509_STORE *store, STACK_OF(X509) *certs,
int only_self_issued);
STACK_OF(X509) *ossl_cmp_X509_STORE_get1_certs(X509_STORE *store);
int ossl_cmp_sk_ASN1_UTF8STRING_push_str(STACK_OF(ASN1_UTF8STRING) *sk,
const char *text, int len);
const char *text, size_t len);
int ossl_cmp_asn1_octet_string_set1(ASN1_OCTET_STRING **tgt,
const ASN1_OCTET_STRING *src);
int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,

View file

@ -824,13 +824,13 @@ OSSL_CMP_MSG *ossl_cmp_error_new(OSSL_CMP_CTX *ctx, const OSSL_CMP_PKISI *si,
goto err;
msg->body->value.error->errorDetails = ft;
if (lib != NULL && *lib != '\0'
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, lib, -1))
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, lib, strlen(lib)))
goto err;
if (reason != NULL && *reason != '\0'
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, reason, -1))
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, reason, strlen(reason)))
goto err;
if (details != NULL
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, details, -1))
&& !ossl_cmp_sk_ASN1_UTF8STRING_push_str(ft, details, strlen(details)))
goto err;
}

View file

@ -73,7 +73,11 @@ ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_CTX *ctx,
pbm_str = (ASN1_STRING *)ppval;
pbm_str_uc = ASN1_STRING_get0_data(pbm_str);
pbm = d2i_OSSL_CRMF_PBMPARAMETER(NULL, &pbm_str_uc, ASN1_STRING_length(pbm_str));
if (ASN1_STRING_length_ex(pbm_str) > INT_MAX) {
ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_ALGORITHM_OID);
goto end;
}
pbm = d2i_OSSL_CRMF_PBMPARAMETER(NULL, &pbm_str_uc, (long)ASN1_STRING_length_ex(pbm_str));
if (pbm == NULL) {
ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_ALGORITHM_OID);
goto end;
@ -81,7 +85,7 @@ ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_CTX *ctx,
if (!OSSL_CRMF_pbm_new(ctx->libctx, ctx->propq,
pbm, prot_part_der, prot_part_der_len,
ASN1_STRING_get0_data(ctx->secretValue), ASN1_STRING_length(ctx->secretValue),
ASN1_STRING_get0_data(ctx->secretValue), ASN1_STRING_length_ex(ctx->secretValue),
&protection, &sig_len))
goto end;
@ -202,7 +206,7 @@ static X509_ALGOR *pbmac_algor(const OSSL_CMP_CTX *ctx)
goto err;
if ((pbm_der_len = i2d_OSSL_CRMF_PBMPARAMETER(pbm, &pbm_der)) < 0)
goto err;
if (!ASN1_STRING_set(pbm_str, pbm_der, pbm_der_len))
if (!ASN1_STRING_set_data(pbm_str, pbm_der, pbm_der_len))
goto err;
alg = ossl_X509_ALGOR_from_nid(NID_id_PasswordBasedMAC,
V_ASN1_SEQUENCE, pbm_str);

View file

@ -214,7 +214,7 @@ static char *snprint_PKIStatusInfo_parts(int status, int fail_info,
for (i = 0; i < n_status_strings; i++) {
text = sk_ASN1_UTF8STRING_value(status_strings, i);
printed_chars = BIO_snprintf(write_ptr, bufsize, "\"%.*s\"%s",
ASN1_STRING_length(text),
(int)ASN1_STRING_length_ex(text),
ASN1_STRING_get0_data(text),
i < n_status_strings - 1 ? ", " : "");
ADVANCE_BUFFER;
@ -275,7 +275,7 @@ OSSL_CMP_PKISI *OSSL_CMP_STATUSINFO_new(int status, int fail_info,
if (text != NULL) {
if ((utf8_text = ASN1_UTF8STRING_new()) == NULL
|| !ASN1_STRING_set(utf8_text, text, -1))
|| !ASN1_STRING_set_string(utf8_text, text))
goto err;
if ((si->statusString = sk_ASN1_UTF8STRING_new_null()) == NULL)
goto err;

View file

@ -219,7 +219,7 @@ int ossl_cmp_X509_STORE_add1_certs(X509_STORE *store, STACK_OF(X509) *certs,
}
int ossl_cmp_sk_ASN1_UTF8STRING_push_str(STACK_OF(ASN1_UTF8STRING) *sk,
const char *text, int len)
const char *text, size_t len)
{
ASN1_UTF8STRING *utf8string;
@ -227,7 +227,7 @@ int ossl_cmp_sk_ASN1_UTF8STRING_push_str(STACK_OF(ASN1_UTF8STRING) *sk,
return 0;
if ((utf8string = ASN1_UTF8STRING_new()) == NULL)
return 0;
if (!ASN1_STRING_set(utf8string, text, len))
if (!ASN1_STRING_set_data(utf8string, (const uint8_t *)text, len))
goto err;
if (!sk_ASN1_UTF8STRING_push(sk, utf8string))
goto err;

View file

@ -306,9 +306,9 @@ ASN1_NDEF_SEQUENCE(CMS_AuthEnvelopedData) = {
ASN1_IMP_OPT(CMS_AuthEnvelopedData, originatorInfo, CMS_OriginatorInfo, 0),
ASN1_SET_OF(CMS_AuthEnvelopedData, recipientInfos, CMS_RecipientInfo),
ASN1_SIMPLE(CMS_AuthEnvelopedData, authEncryptedContentInfo, CMS_EncryptedContentInfo),
ASN1_IMP_SET_OF_OPT(CMS_AuthEnvelopedData, authAttrs, X509_ALGOR, 2),
ASN1_IMP_SET_OF_OPT(CMS_AuthEnvelopedData, authAttrs, X509_ATTRIBUTE, 1),
ASN1_SIMPLE(CMS_AuthEnvelopedData, mac, ASN1_OCTET_STRING),
ASN1_IMP_SET_OF_OPT(CMS_AuthEnvelopedData, unauthAttrs, X509_ALGOR, 3)
ASN1_IMP_SET_OF_OPT(CMS_AuthEnvelopedData, unauthAttrs, X509_ATTRIBUTE, 2)
} ASN1_NDEF_SEQUENCE_END(CMS_AuthEnvelopedData)
ASN1_NDEF_SEQUENCE(CMS_AuthenticatedData) = {

View file

@ -92,7 +92,7 @@ int ossl_cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain,
else
r = 1;
} else {
if (!ASN1_STRING_set(dd->digest, md, mdlen))
if (!ASN1_STRING_set_data(dd->digest, md, mdlen))
goto err;
r = 1;
}

View file

@ -29,7 +29,7 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
BIGNUM *bnpub = NULL;
const unsigned char *p;
unsigned char *buf = NULL;
int plen;
size_t plen;
X509_ALGOR_get0(&aoid, &atype, &aval, alg);
if (OBJ_obj2nid(aoid) != NID_dhpublicnumber)
@ -43,29 +43,33 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
goto err;
/* Get public key */
plen = ASN1_STRING_length(pubkey);
plen = ASN1_STRING_length_ex(pubkey);
if (plen > INT_MAX)
goto err;
p = ASN1_STRING_get0_data(pubkey);
if (p == NULL || plen == 0)
goto err;
if ((public_key = d2i_ASN1_INTEGER(NULL, &p, plen)) == NULL)
if ((public_key = d2i_ASN1_INTEGER(NULL, &p, (int)plen)) == NULL)
goto err;
/*
* Pad to full p parameter size as that is checked by
* EVP_PKEY_set1_encoded_public_key()
*/
plen = EVP_PKEY_get_size(pk);
if (plen > INT_MAX)
goto err;
if ((bnpub = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL)
goto err;
if ((buf = OPENSSL_malloc(plen)) == NULL)
goto err;
if (BN_bn2binpad(bnpub, buf, plen) < 0)
if (BN_bn2binpad(bnpub, buf, (int)plen) < 0)
goto err;
pkpeer = EVP_PKEY_new();
if (pkpeer == NULL
|| !EVP_PKEY_copy_parameters(pkpeer, pk)
|| EVP_PKEY_set1_encoded_public_key(pkpeer, buf, plen) <= 0)
|| EVP_PKEY_set1_encoded_public_key(pkpeer, buf, (int)plen) <= 0)
goto err;
if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)
@ -85,8 +89,9 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
ASN1_OCTET_STRING *ukm;
const unsigned char *p;
unsigned char *dukm = NULL;
int dukmlen = 0;
int keylen, plen;
size_t dukmlen = 0;
int keylen;
size_t plen;
EVP_CIPHER *kekcipher = NULL;
EVP_CIPHER_CTX *kekctx;
const ASN1_OBJECT *aoid;
@ -116,8 +121,10 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
goto err;
p = ASN1_STRING_get0_data(parameter);
plen = ASN1_STRING_length(parameter);
kekalg = d2i_X509_ALGOR(NULL, &p, plen);
plen = ASN1_STRING_length_ex(parameter);
if (plen > INT_MAX)
goto err;
kekalg = d2i_X509_ALGOR(NULL, &p, (int)plen);
if (kekalg == NULL)
goto err;
kekctx = CMS_RecipientInfo_kari_get0_ctx(ri);
@ -146,13 +153,15 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
goto err;
if (ukm != NULL) {
dukmlen = ASN1_STRING_length(ukm);
dukm = OPENSSL_memdup(ASN1_STRING_get0_data(ukm), dukmlen);
dukmlen = ASN1_STRING_length_ex(ukm);
if (dukmlen > INT_MAX)
goto err;
dukm = OPENSSL_memdup(ASN1_STRING_get0_data(ukm), (int)dukmlen);
if (dukm == NULL)
goto err;
}
if (EVP_PKEY_CTX_set0_dh_kdf_ukm(pctx, dukm, dukmlen) <= 0)
if (EVP_PKEY_CTX_set0_dh_kdf_ukm(pctx, dukm, (int)dukmlen) <= 0)
goto err;
dukm = NULL;
@ -206,7 +215,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
ASN1_OCTET_STRING *ukm;
unsigned char *penc = NULL, *dukm = NULL;
int penclen;
int dukmlen = 0;
size_t dukmlen = 0;
int rv = 0;
int kdf_type, wrap_nid;
const EVP_MD *kdf_md;
@ -298,13 +307,15 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
goto err;
if (ukm != NULL) {
dukmlen = ASN1_STRING_length(ukm);
dukmlen = ASN1_STRING_length_ex(ukm);
if (dukmlen > INT_MAX)
goto err;
dukm = OPENSSL_memdup(ASN1_STRING_get0_data(ukm), dukmlen);
if (dukm == NULL)
goto err;
}
if (EVP_PKEY_CTX_set0_dh_kdf_ukm(pctx, dukm, dukmlen) <= 0)
if (EVP_PKEY_CTX_set0_dh_kdf_ukm(pctx, dukm, (int)dukmlen) <= 0)
goto err;
dukm = NULL;

View file

@ -79,7 +79,7 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
int rv = 0;
EVP_PKEY *pkpeer = NULL;
const unsigned char *p;
int plen;
size_t plen;
X509_ALGOR_get0(&aoid, &atype, &aval, alg);
if (OBJ_obj2nid(aoid) != NID_X9_62_id_ecPublicKey)
@ -106,12 +106,14 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
goto err;
}
/* We have parameters now set public key */
plen = ASN1_STRING_length(pubkey);
plen = ASN1_STRING_length_ex(pubkey);
if (plen > INT_MAX)
goto err;
p = ASN1_STRING_get0_data(pubkey);
if (p == NULL || plen == 0)
goto err;
if (EVP_PKEY_set1_encoded_public_key(pkpeer, p, plen) <= 0)
if (EVP_PKEY_set1_encoded_public_key(pkpeer, p, (int)plen) <= 0)
goto err;
if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)
@ -163,7 +165,8 @@ static int ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
ASN1_OCTET_STRING *ukm;
const unsigned char *p;
unsigned char *der = NULL;
int plen, keylen;
int keylen, plen_i;
size_t plen;
EVP_CIPHER *kekcipher = NULL;
EVP_CIPHER_CTX *kekctx;
const ASN1_OBJECT *aoid = NULL;
@ -186,8 +189,10 @@ static int ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
return 0;
p = ASN1_STRING_get0_data(parameter);
plen = ASN1_STRING_length(parameter);
kekalg = d2i_X509_ALGOR(NULL, &p, plen);
plen = ASN1_STRING_length_ex(parameter);
if (plen > INT_MAX)
goto err;
kekalg = d2i_X509_ALGOR(NULL, &p, (int)plen);
if (kekalg == NULL)
goto err;
kekctx = CMS_RecipientInfo_kari_get0_ctx(ri);
@ -206,12 +211,12 @@ static int ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
if (EVP_PKEY_CTX_set_ecdh_kdf_outlen(pctx, keylen) <= 0)
goto err;
plen = CMS_SharedInfo_encode(&der, kekalg, ukm, keylen);
plen_i = CMS_SharedInfo_encode(&der, kekalg, ukm, keylen);
if (plen <= 0)
if (plen_i <= 0)
goto err;
if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, der, plen) <= 0)
if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, der, plen_i) <= 0)
goto err;
der = NULL;

View file

@ -278,12 +278,17 @@ BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data,
CMS_ContentInfo *ci;
BIO *bio = NULL;
int res = 0;
size_t secret_len = 0;
if (env == NULL) {
ERR_raise(ERR_LIB_CMS, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
if (secret != NULL
&& (secret_len = ASN1_STRING_length_ex(secret)) > INT_MAX)
return NULL;
if ((ci = CMS_ContentInfo_new_ex(libctx, propq)) == NULL
|| (bio = BIO_new(BIO_s_mem())) == NULL)
goto end;
@ -291,7 +296,7 @@ BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data,
ci->d.envelopedData = env;
if (secret != NULL
&& CMS_decrypt_set1_password(ci, (unsigned char *)ASN1_STRING_get0_data(secret),
ASN1_STRING_length(secret))
(int)secret_len)
!= 1)
goto end;
res = CMS_decrypt(ci, secret == NULL ? pkey : NULL,
@ -1236,6 +1241,35 @@ BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms)
return cms_EnvelopedData_Decryption_init_bio(cms);
}
/* The DER encoding of authAttrs, with the universal SET OF tag, is the AAD */
static int cms_AuthEnvelopedData_set_aad(BIO *b,
STACK_OF(X509_ATTRIBUTE) *authAttrs)
{
EVP_CIPHER_CTX *ctx;
unsigned char *aad = NULL;
int aadlen, outl, ok = 0;
const ASN1_ITEM *item;
if (!BIO_get_cipher_ctx(b, &ctx))
return 0;
item = EVP_CIPHER_CTX_is_encrypting(ctx)
? ASN1_ITEM_rptr(CMS_Attributes_AadEncrypt)
: ASN1_ITEM_rptr(CMS_Attributes_AadDecrypt);
aadlen = ASN1_item_i2d((ASN1_VALUE *)authAttrs, &aad, item);
if (aadlen <= 0 || aad == NULL) {
ERR_raise(ERR_LIB_CMS, ERR_R_ASN1_LIB);
goto err;
}
if (EVP_CipherUpdate(ctx, NULL, &outl, aad, aadlen) <= 0) {
ERR_raise(ERR_LIB_CMS, CMS_R_CTRL_FAILURE);
goto err;
}
ok = 1;
err:
OPENSSL_free(aad);
return ok;
}
BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms)
{
CMS_EncryptedContentInfo *ec;
@ -1252,9 +1286,16 @@ BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms)
ec->taglen = aenv->mac->length;
}
ret = ossl_cms_EncryptedContent_init_bio(ec, ossl_cms_get0_cmsctx(cms), 1);
if (ret == NULL)
return NULL;
/* If error or no cipher end of processing */
if (ret == NULL || ec->cipher == NULL)
/* authAttrs, if present, are the AEAD associated data */
if (aenv->authAttrs != NULL
&& !cms_AuthEnvelopedData_set_aad(ret, aenv->authAttrs))
goto err;
/* If no cipher end of processing */
if (ec->cipher == NULL)
return ret;
/* Now encrypt content key according to each RecipientInfo type */

View file

@ -131,7 +131,7 @@ CMS_ReceiptRequest *CMS_ReceiptRequest_create0_ex(
if (id)
ASN1_STRING_set0(rr->signedContentIdentifier, id, idlen);
else {
if (!ASN1_STRING_set(rr->signedContentIdentifier, NULL, 32)) {
if (!ASN1_STRING_set_data(rr->signedContentIdentifier, NULL, 32)) {
ERR_raise(ERR_LIB_CMS, ERR_R_ASN1_LIB);
goto err;
}

View file

@ -388,7 +388,7 @@ int ossl_cms_RecipientInfo_kemri_decrypt(const CMS_ContentInfo *cms,
goto err;
kem_ct = ASN1_STRING_get0_data(kemri->kemct);
kem_ct_len = ASN1_STRING_length(kemri->kemct);
kem_ct_len = ASN1_STRING_length_ex(kemri->kemct);
if (EVP_PKEY_decapsulate(kemri->pctx, NULL, &kem_secret_len, kem_ct, kem_ct_len) <= 0)
return 0;

View file

@ -401,6 +401,9 @@ DECLARE_ASN1_ITEM(CMS_EncryptedContentInfo)
DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
/* The authAttrs AAD encoding matches the signed-attributes one */
#define CMS_Attributes_AadEncrypt_it CMS_Attributes_Sign_it
#define CMS_Attributes_AadDecrypt_it CMS_Attributes_Verify_it
DECLARE_ASN1_ITEM(CMS_RecipientInfo)
DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)

View file

@ -43,7 +43,7 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
int nid;
int rv = -1;
const unsigned char *label = NULL;
int labellen = 0;
size_t labellen = 0;
const EVP_MD *mgf1md = NULL, *md = NULL;
RSA_OAEP_PARAMS *oaep;
const ASN1_OBJECT *aoid;
@ -90,7 +90,9 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
}
label = ASN1_STRING_get0_data(parameter);
labellen = ASN1_STRING_length(parameter);
labellen = ASN1_STRING_length_ex(parameter);
if (labellen > INT_MAX)
goto err;
}
if (EVP_PKEY_CTX_set_rsa_padding(pkctx, RSA_PKCS1_OAEP_PADDING) <= 0)
@ -105,7 +107,7 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
if (dup_label == NULL)
goto err;
if (EVP_PKEY_CTX_set0_rsa_oaep_label(pkctx, dup_label, labellen) <= 0) {
if (EVP_PKEY_CTX_set0_rsa_oaep_label(pkctx, dup_label, (int)labellen) <= 0) {
OPENSSL_free(dup_label);
goto err;
}

View file

@ -304,7 +304,7 @@ static int ossl_cms_add1_signing_cert(CMS_SignerInfo *si,
p = pp;
i2d_ESS_SIGNING_CERT(sc, &p);
if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) {
if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set_data(seq, pp, len)) {
ASN1_STRING_free(seq);
OPENSSL_free(pp);
return 0;
@ -329,7 +329,7 @@ static int ossl_cms_add1_signing_cert_v2(CMS_SignerInfo *si,
p = pp;
i2d_ESS_SIGNING_CERT_V2(sc, &p);
if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) {
if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set_data(seq, pp, len)) {
ASN1_STRING_free(seq);
OPENSSL_free(pp);
return 0;

View file

@ -36,6 +36,7 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
unsigned char buf[4096];
int r = 0, i;
BIO *tmpout;
BIO *aeadbuf = NULL;
tmpout = cms_get_text_bio(out, flags);
@ -44,6 +45,33 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
goto err;
}
/*
* For AEAD content (AuthEnvelopedData) the integrity tag is only verified
* once all the ciphertext has been processed, by the
* BIO_get_cipher_status() call below. RFC 5083 requires that the plaintext
* is not released to the caller until that verification succeeds, so
* buffer it in memory and only forward it to the output BIO once the tag
* has been checked. When CMS_TEXT is set tmpout is already a memory BIO
* that is flushed only on success, so the extra buffering is not needed.
*/
if (tmpout == out && BIO_method_type(in) == BIO_TYPE_CIPHER) {
EVP_CIPHER_CTX *ctx = NULL;
if (BIO_get_cipher_ctx(in, &ctx) > 0 && ctx != NULL
&& (EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(ctx))
& EVP_CIPH_FLAG_AEAD_CIPHER)
!= 0) {
aeadbuf = BIO_new(BIO_s_mem());
if (aeadbuf == NULL) {
ERR_raise(ERR_LIB_CMS, ERR_R_BIO_LIB);
goto err;
}
/* Return 0 (EOF) rather than a retryable -1 once drained. */
BIO_set_mem_eof_return(aeadbuf, 0);
tmpout = aeadbuf;
}
}
/* Read all content through chain to process digest, decrypt etc */
for (;;) {
i = BIO_read(in, buf, sizeof(buf));
@ -66,6 +94,17 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
ERR_raise(ERR_LIB_CMS, CMS_R_SMIME_TEXT_ERROR);
goto err;
}
} else if (aeadbuf != NULL) {
/* Forward the AEAD BIO to out BIO as the tag has been verified. */
for (;;) {
i = BIO_read(aeadbuf, buf, sizeof(buf));
if (i < 0)
goto err;
if (i == 0)
break;
if (BIO_write(out, buf, i) != i)
goto err;
}
}
r = 1;

Some files were not shown because too many files have changed in this diff Show more