Commit Graph

38742 Commits

Author SHA1 Message Date
Matt Caswell
85645be82e Clean up some unnecessary includes
Now that we have removed lots of deadcode various files are including
more than they need to. We can slim down the list of includes.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
b217b18009 Remove dead EVP_rc5() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
6215430101 Remove legacy fields from the EVP_CIPHER structure
We remove legacy fields that are no longer used for anything from the
EVP_CIPHER structure.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
f9bdb61bbf Remove some last remaining EVP_CIPHER related legacy paths
There were some final remaining legacy paths that are now redundant and
can be removed.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
86d7f1665d Remove dead EVP_rc4_hmac_md5() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
4c8280a13c Remove dead EVP_enc_null() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
4237166530 Remove dead EVP_chacha20_*() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
32eaa748a3 Cleanup block cipher macros in include/crypto/evp.h
Remove some unneeded deadcode and fix the formatting

Also fix all users of those macros to avoid compilation warnings

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
d4c1efccab Remove dead EVP_aes_*() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
c68b696289 Remove dead EVP_aes_*_cbc_hmac_sha256() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Matt Caswell
6f850e16fb Remove dead EVP_aes_*_cbc_hmac_sha1() code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00
Jiasheng Jiang
bfdf7c889b fuzz/provider.c: Add check for OPENSSL_malloc() to avoid potential NULL pointer dereference
Add check for the return value of OPENSSL_malloc() to avoid potential NULL pointer dereference.

Fixes: f3b988d ("Add provider fuzzer")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27868)
2026-01-10 09:35:49 -05:00
Matt Caswell
cec5022d5c Document the EVP_PKEY_asn1* removed functions
For every function that was removed we add an entry to
ossl-removed-api.pod

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29405)
2026-01-09 15:53:16 +00:00
Matt Caswell
1d4919dcc7 Update the documentation to remove referenceds to EVP_PKEY_ASN1_METHOD
Now that EVP_PKEY_ASN1_METHODs have been removed from the public API we
need to update the documentation accordingly. They still exist internally
and so some references are still appropriate in the internal documetnation.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29405)
2026-01-09 15:52:12 +00:00
Matt Caswell
c65e34bfce Remove the ability to create a custom EVP_PKEY_ASN1_METHOD
Now that the ability to register a custom EVP_PKEY_ASN1_METHOD has
been removed in an earlier commit, we can now remove the functions that
are used to create a custom EVP_PKEY_ASN1_METHOD.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29405)
2026-01-09 15:52:12 +00:00
Matt Caswell
f9f6d5666a Remove the ability to query the internal EVP_PKEY_ASN1_METHODs
Previously there were a few functions where you could obtain a handle
on registered EVP_PKEY_ASN1_METHODs and query information about them.
We remove the capability.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29405)
2026-01-09 15:52:12 +00:00
Matt Caswell
48d311ee55 Remove EVP_PKEY_asn1_add0()
We remove the ability to add application defined EVP_PKEY_ASN1_METHODs
via the `EVP_PKEY_asn1_add0()` function. We also remove the related function
`EVP_PKEY_asn1_add_alias()`.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29405)
2026-01-09 15:52:12 +00:00
Neil Horman
f247e19fd3 Add a test to ensure that instantiation of drbgs work
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29560)
2026-01-09 10:07:59 -05:00
Neil Horman
8655a91c79 fetch macctx while fetching digest when creating HMAC-DRBG
Somewhere in our conversion from .c files to .inc files for our rand
providers, we created code in drbg_hmac_set_ctx_params_locked to fetch
our digest and hmac when creating the rand instance.  However, the
function drbg_fetch_algs_from_prov only fetched our digest for this rand
type, not the hmac, and returned 1 while doing so, indicating success.
This is problematic because it means that we never wind up fetching an
HMAC for this rand type.  As a result we never compute the strength of
the DRBG and so any attempt to seed it fails.

Ensure that, if we load a digest for this DRBG, we also fetch an HMAC,
and fail if we can't do so, so the HMAC-DRBG is useful.

Fixes openssl/private#853

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29560)
2026-01-09 10:07:59 -05:00
Matt Caswell
2b91fd900f Clean up some unnecessary inclusions
After the deadcode removal there were varios include files being used
that are no longer necessary. We remove them.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29460)
2026-01-09 09:25:51 -05:00
Matt Caswell
b2168cd81d Remove some legacy fields from the EVP_MD_CTX structure
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29460)
2026-01-09 09:25:51 -05:00
Matt Caswell
84b5f265ce Cleanup the EVP_MD structure
Remove fields that are no longer needed.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29460)
2026-01-09 09:25:51 -05:00
Matt Caswell
a82bb34662 Remove legacy method deadcode for EVP_MD implementations
Remove the legacy EVP_MD implementation functions. These are no longer
used due to providers. This code is now unreachable due to the removal of
the functions related to custom EVP_MD methods.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29460)
2026-01-09 09:25:51 -05:00
Alexandr Nedvedicky
1cb0d36b39 MinGW does not know __int64, we can rely on int64_t provided by <stdint.h>
<stdint.H> is part of libraries which come with C99 compiler.

Fixes: #29548

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29553)
2026-01-08 08:02:31 -05:00
Richard Levitte
aa4b47483f Fix util/mkinstallvars.pl to treat LIBDIR and libdir correctly
OpenSSL's build file (Makefile) handles library directories via two
variables, 'LIBDIR' and 'libdir', where the former is empty when the
path given through ./Configure's '--libdir' is absolute.

This was forgotten when treating the resulting values in,
util/mkinstallvars.pl, which got libdir in exporters/libcrypto.pc
to not be quite right if .Configure was called with a '--libdir'
with an absolute path.

The fix turns out to be quite easy.

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

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29540)
2026-01-08 12:30:24 +01:00
Bernd Edlinger
48b788cad3 Fix a possible crash in ASN1_generate_nconf
Due to an out of memory error, the i2d_ASN1_TYPE might fail
and cause a segfault.
This adds a missing check for NULL pointer and a test case
that exercises IMPLICIT and EXPLICT tagging in generate_v3,
since there was no test coverage at all for this code section.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 10:13:43 2026
(Merged from https://github.com/openssl/openssl/pull/29545)
2026-01-08 11:13:25 +01:00
Alexandr Nedvedicky
818bbcf475 ctx_simd and ctx_ref must be freed in error path
CID 1679597
CID 1679599

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
MergeDate: Thu Jan  8 10:10:49 2026
(Merged from https://github.com/openssl/openssl/pull/29543)
2026-01-08 11:10:46 +01:00
Frederik Wedel-Heinen
b0041c909e Cleanup in cryptlib.h.
Remove unused ossl_crypto_ex_data_get_ossl_lib_ctx() and memdbg_lock.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jan  8 10:08:08 2026
(Merged from https://github.com/openssl/openssl/pull/29500)
2026-01-08 11:08:02 +01:00
Frederik Wedel-Heinen
2ffad846c7 Correctly handle the cases where SSL_dup fails.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
MergeDate: Thu Jan  8 10:06:48 2026
(Merged from https://github.com/openssl/openssl/pull/29485)
2026-01-08 11:06:43 +01:00
JohnnySavages
c8bae42190 Remove unnecessary argc assign
Found by Linux Verification Center (linuxtesting.org) with SVACE.

CLA:trivial

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Thu Jan  8 10:03:55 2026
(Merged from https://github.com/openssl/openssl/pull/29457)
2026-01-08 11:03:40 +01:00
Dr. David von Oheimb
bfb103387c X509_VERIFY_PARAM_set_flags.pod: fix doc of NULL param to X509_VERIFY_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 09:56:15 2026
(Merged from https://github.com/openssl/openssl/pull/29150)
2026-01-08 10:56:10 +01:00
Dr. David von Oheimb
ac5e2d22af X509_VERIFY_PARAM_set_flags.pod: remove heavily outdated texts on X509_V_FLAG_NO_ALT_CHAINS; other small fixes
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 09:56:14 2026
(Merged from https://github.com/openssl/openssl/pull/29150)
2026-01-08 10:56:10 +01:00
Dr. David von Oheimb
6d643de2d5 X509_VERIFY_PARAM_set_flags.pod: add hint on joint use of X509_VERIFY_PARAM_set1_host() and SSL_set_tlsext_host_name()
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 09:56:12 2026
(Merged from https://github.com/openssl/openssl/pull/29150)
2026-01-08 10:55:50 +01:00
Anton Moryakov
5e2e7c60d3 apps: ocsp.c: fix null dereference in ocsp_response
Report of the static analyzer:
Function 'OCSP_cert_to_id' may return NULL on allocation failure,
but its return value is dereferenced in 'OCSP_id_issuer_cmp'
without prior NULL check at ocsp.c:1088. This can lead to a null
pointer dereference and cause a segmentation fault, resulting
in a denial-of-service (DoS) condition. Although such failures
are rare, an attacker could potentially trigger them under memory
pressure. All other calls to 'OCSP_cert_to_id' in the codebase
(e.g., add_ocsp_cert, add_ocsp_serial) properly check for NULL,
making this instance a clear omission.

Correct explained:
Added a NULL check after calling OCSP_cert_to_id() when creating
'ca_id' inside the issuer lookup loop. If the allocation fails, the
function now safely returns an internal error response instead of
risking a crash. This change aligns the code with existing
error-handling patterns in the same file and improves robustness
against resource exhaustion attacks.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 09:01:09 2026
(Merged from https://github.com/openssl/openssl/pull/29033)
2026-01-08 10:01:00 +01:00
Andreas Aigner
2a0aea5a9b Remove unused Data::Dumper from cmake exporter
* Remove additional dependency for old build boxes (in particular centos)

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Thu Jan  8 08:55:10 2026
(Merged from https://github.com/openssl/openssl/pull/24632)

(cherry picked from commit df0a0fd613)
2026-01-08 09:55:48 +01:00
Dr. David von Oheimb
d57a13c6c4 apps/cmp.c: fix handling of passwords when loading pubkey from possibyl password-protected container
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28477)
2026-01-07 12:56:15 +01:00
Dr. David von Oheimb
62af159ea5 apps/cmp.c: refactor load_key_pwd() and load_cert_pwd() params for clarity w.r.t. password source vs. actual password
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28477)
2026-01-07 12:56:15 +01:00
Dr. David von Oheimb
2f949642a1 apps/lib/apps.c: fix load_certs_multifile() and load_certstore() w.r.t. password source vs. actual password
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28477)
2026-01-07 12:56:15 +01:00
Dr. David von Oheimb
48d4c8fb8b apps/lib/apps.c load_key_certs_crls() refactor uidata use and tweak error message
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28477)
2026-01-07 12:56:15 +01:00
Neil Horman
2d4bb3753b Add new test test_base64_simdutf to .gitignore file
the test_base64_simdutf test is commonly built but not ignored by our
.gitignore file, fix that up

Fixes #29529

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29551)
2026-01-07 13:59:42 +11:00
Neil Horman
ee8772e356 prevent large latency in base64_simdutf test
The base64_simdutf test has a printf statement inside a double for loop
that causes a huge amount of latency when run under our perl scripts.
Average run time on my system is about 1min 58 seconds.

We shouldn't be using a printf statement there anyway (likely TEST_info
instead), but we don't need that either, so just remove the printf
entirely.  This decreases the run time to around a second to complete.

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29542)
2026-01-07 11:31:05 +11:00
Anatolii Ohorodnyk
5707fd0753 test: use runtime FIPS detection instead of compile-time check
Replace #ifdef FIPS_MODULE with OSSL_PROVIDER_available() runtime check
in ecdsatest.c. The compile-time check is not meaningful for test cases
as the test binary may be compiled without FIPS_MODULE but run with the
FIPS provider loaded.

Fixes #28255

CLA: trivial

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29527)
2026-01-07 08:28:51 +11:00
Dr. David von Oheimb
7123614134 apps.c: fix next_item() to correctly handle space(s) before comma separators
* Modified the parsing logic to handle space-followed-by-comma patterns
* Updated the separator skipping logic to process at most one comma while allowing multiple spaces
* Added a test case with a mixed DNS and IP SAN entry that includes the problematic spacing pattern

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28471)
2026-01-06 21:02:20 +01:00
Bernd Edlinger
c0a7890b62 Fix a memory leak in sctp code
There is a memory leak of the addrinfo struct when
`./openssl s_server -dtls -sctp -accept 127.0.0.1:4433`
is used, but `sysctl -w net.sctp.auth_enable=1`
is not done before.
Additionally this fixes an oversight, when
`./openssl s_client -dtls -sctp -connect localhost:4433`
is used to connect to above server.
The first connect attempt is to IPv6 ::1, which might fail,
but the second attempt might still succeed, so continue to
try all addesses even when the SCTP socket fails for one of them.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29541)
2026-01-06 07:56:14 -05:00
Dr. David von Oheimb
7e05e8d6a3 UI_new.pod: fix doc of UI_add_user_data()
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28475)
2026-01-05 17:59:40 +01:00
Frederik Wedel-Heinen
4185261efc Fix possible null pointer dereference.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/29537)
2026-01-05 09:36:06 -05:00
Neil Horman
cf8b11c184 Fix dead code/constant expression in simdutf test
Coverity issues:
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677828
and
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677827

caught some dead code in the simdutf test.

The total variable is defined as an int, which is tested against <=
INT_MAX, and > INT_MAX, which will always be true, and false
respectively, making the <= test needless, and the condition the latter
bounds dead code

Clean that up.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)
2026-01-04 17:51:56 -05:00
Neil Horman
b6aed64e47 Fix overflow in EVP_EncodeFinal
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677829

With recent changes, evp_encodeblock_int may return a negative value,
which EVP_EncodeFinal does not anticipate.  As the latter sets out[ret]
to "\0" where ret is the return value of evp_encodeblock_int, we may
underflow the array index and access invalid memory locations.

Only update the output buffer if the return value is greater or equal to
zero.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)
2026-01-04 17:51:56 -05:00
Neil Horman
fb99acc994 Fix constant bounds checking in evp_encodeblock_int
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677830

Reports that several locations in the above function bound for loops
with a check for
ret <= INT_MAX

Given that ret is defined as an int, it can never be larger than
INT_MAX, and so is always true.

We can just remove the check for this variable.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)
2026-01-04 17:51:56 -05:00
Neil Horman
3b69cc994c Fix more dead code in b64_write
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677831

reports more dead code in b64_write

ret is incremented by inl in b64_write prior to being tested for zero.
Since inl is previously tested for being <= 0, and returns if it is, ret
must be at least 1 during the test, making the trinary test dead code.

Just return -1 here.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)
2026-01-04 17:51:56 -05:00