openssl.git
22 months agoopenssl-x509.pod.in: fix description of certificate serial number storage
Dr. David von Oheimb [Tue, 31 May 2022 08:02:02 +0000 (10:02 +0200)]
openssl-x509.pod.in: fix description of certificate serial number storage

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18373)

(cherry picked from commit aa73b7d352c383e415d4d7567b79ce074c6762cd)

22 months agoAPPS/x509: With -CA but both -CAserial and -CAcreateserial not given, use random...
Dr. David von Oheimb [Mon, 30 May 2022 14:53:05 +0000 (16:53 +0200)]
APPS/x509: With -CA but both -CAserial and -CAcreateserial not given, use random serial.

Also improve openssl-x509.pod.in and error handling of load_serial() in apps.c.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18373)

(cherry picked from commit ec8a3409487c871b440fa52bff7c3ef33378494a)

22 months agoapps/x509: Fix -CAfile option being neglected with -new or -in
Dr. David von Oheimb [Fri, 20 May 2022 04:23:54 +0000 (06:23 +0200)]
apps/x509: Fix -CAfile option being neglected with -new or -in

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18373)

(cherry picked from commit 10c7887330bb6ca136cd16fe081639f4462a072e)

22 months agoAdd an EVP demo for CMAC
Daniel Fiala [Mon, 11 Jul 2022 07:03:58 +0000 (09:03 +0200)]
Add an EVP demo for CMAC

Fixes openssl#14110

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18778)

(cherry picked from commit cdf0a5c46032ba4c39d93a7bec52494b4808830f)

22 months agoCheck for EVP_MD being NULL inside ssl.
slontis [Tue, 12 Jul 2022 04:28:37 +0000 (14:28 +1000)]
Check for EVP_MD being NULL inside ssl.

Fix multiple places that could potentially segfault if memory
allocations fail. e.g. ssl_load_ciphers() could fail while calling
ssl_evp_md_fetch().

Found by #18355

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18784)

(cherry picked from commit b740012f77aed97cb4b3cd8a4f1fb2f668542795)

22 months agospeed: Always reset the outlen when calling EVP_PKEY_derive
Tomas Mraz [Mon, 11 Jul 2022 10:49:56 +0000 (12:49 +0200)]
speed: Always reset the outlen when calling EVP_PKEY_derive

Fixes #18768

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18777)

(cherry picked from commit ab8d56d05b773e499c86be874fd3f11f5950213c)

22 months agoPre-declare all core dispatch table functions, and fix the internal ones
Richard Levitte [Thu, 28 Apr 2022 06:15:53 +0000 (08:15 +0200)]
Pre-declare all core dispatch table functions, and fix the internal ones

When assigning pointers to functions in an OSSL_DISPATCH table, we try
to ensure that those functions are properly defined or declared with
an extra declaration using the corresponding function typedefs that
are defined by include/openssl/core_dispatch.h.

For the core dispatch table, found in crypto/provider_core.c, it seems
we forgot this habit, and thus didn't ensure well enough that the
function pointers that are assigned in the table can actually be used
for those dispatch table indexes.

This change adds all the missing declarations, and compensates for
differences with functions that do the necessary casting, making those
explicit rather than implicit, thereby trying to assure that we know
what we're doing.

One function is not fixed in this change, because there's a controversy,
a clash between the signature of BIO_ctrl() and OSSL_FUNC_BIO_ctrl_fn.
They have different return types.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18198)

(cherry picked from commit 9574842e90e29015daa2b071e965cec9aa885c17)

22 months agoadd a check for the return of OBJ_new_nid()
xkernel [Mon, 11 Jul 2022 07:21:09 +0000 (15:21 +0800)]
add a check for the return of OBJ_new_nid()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18773)

(cherry picked from commit a0ff8e413e94ba46720a4bf3a5032c50531c526c)

22 months agoci: add GitHub token permissions for workflows
Varun Sharma [Sat, 9 Jul 2022 14:03:23 +0000 (07:03 -0700)]
ci: add GitHub token permissions for workflows

Signed-off-by: Varun Sharma <varunsh@stepsecurity.io>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18766)

(cherry picked from commit c6e7f427c82dfa17416a39af7661c40162d57aaf)

22 months agoOSSL_trace_set_channel.pod and openssl.pod: fix missing/inconsistent category items
Dr. David von Oheimb [Fri, 8 Jul 2022 09:14:16 +0000 (11:14 +0200)]
OSSL_trace_set_channel.pod and openssl.pod: fix missing/inconsistent category items

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18763)

22 months agox509_vfy.c: Revert the core of #14094 regarding chain_build() error reporting
Dr. David von Oheimb [Sat, 9 Jul 2022 09:09:08 +0000 (11:09 +0200)]
x509_vfy.c: Revert the core of #14094 regarding chain_build() error reporting

The problem of producing to-the-point diagnostics will be fixed in a follow-up PR.
Fixes #18691

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18758)

(cherry picked from commit 1f00dc4f8c0ef0101368de2adf22495e5e295114)

22 months agotest/certs/setup.sh: add missing comment on CA cert variant without basic constraints
Dr. David von Oheimb [Fri, 8 Jul 2022 19:49:28 +0000 (21:49 +0200)]
test/certs/setup.sh: add missing comment on CA cert variant without basic constraints

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18758)

(cherry picked from commit a148a9b4f49b0c456d45a39c0d63a52405aa5ea9)

22 months agoFix memory leak in EVP_PKEY_get1_encoded_public_key.
slontis [Thu, 7 Jul 2022 05:03:08 +0000 (15:03 +1000)]
Fix memory leak in EVP_PKEY_get1_encoded_public_key.

Occurs if a failure happens after the malloc call in the second call to
EVP_PKEY_get_octet_string_param().

Detected by PR #18355

Some calling code assumes that nothing is allocated in the returned
pointer if there was a failure. Other calling code always trys freeing.
The third case is in ecdh_cms_encrypt() where it does not check the
return value. I am assuming this change is ok since the legacy path in
EVP_PKEY_get1_encoded_public_key() also does not return the pointer on
failure.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18739)

(cherry picked from commit 4e9a4997c540e64647d4e1708a1dbda51fb59a68)

22 months agohttp_client.c: fix calculation of Content-Length in set1_content()
Dr. David von Oheimb [Fri, 1 Jul 2022 15:46:36 +0000 (17:46 +0200)]
http_client.c: fix calculation of Content-Length in set1_content()

Work around an inconsistency in the implementations of BIO_CTRL_INFO.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18701)

(cherry picked from commit 243465fd556837402bff52b7bf3d59420b68a02e)

22 months agoapps/cmp.c: fix cleanup of CMP_CTX vs. APP_HTTP_TLS_INFO in its http_cb_arg field
Dr. David von Oheimb [Fri, 1 Jul 2022 18:38:59 +0000 (20:38 +0200)]
apps/cmp.c: fix cleanup of CMP_CTX vs. APP_HTTP_TLS_INFO in its http_cb_arg field

Prevent crashes on error by making sure the info is freed after OSSL_CMP_CTX_free(),
which may call OSSL_HTTP_close() and thus indirectly reference the info.
Moreover, should not attempt to reference the cmp_ctx variable when NULL.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18702)

(cherry picked from commit 8c094747d78bb8627e9ca5241fed0550a3de2fdb)

22 months agocmp_http.c: extend comment in keep_alive()
Dr. David von Oheimb [Fri, 1 Jul 2022 18:25:55 +0000 (20:25 +0200)]
cmp_http.c: extend comment in keep_alive()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18702)

(cherry picked from commit 93d9d6097685dc29e654db15c091c550aef16d5b)

22 months agoFix memory leak in X509V3_add1_i2d when flag is X509V3_ADD_DELETE
Allan [Thu, 7 Jul 2022 23:04:09 +0000 (16:04 -0700)]
Fix memory leak in X509V3_add1_i2d when flag is X509V3_ADD_DELETE

Fixes #18677

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18698)

(cherry picked from commit 4798e0680b112993815098ca21d7d68ff31ebc6e)

22 months agouse #pragma comment(lib) with _MSC_VER only
Viktor Szakats [Sun, 3 Jul 2022 22:30:06 +0000 (22:30 +0000)]
use #pragma comment(lib) with _MSC_VER only

Avoid this warning when compiled with llvm/gcc + mingw-w64 and
`USE_BCRYPTGENRANDOM` enabled:

```
../providers/implementations/rands/seeding/rand_win.c:31:11: warning: unknown pragma ignored [-Wunknown-pragmas]
          ^
1 warning generated.
```

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18709)

(cherry picked from commit 695cb63c744bab090144a86949b68324ee3094d6)

22 months agofeat: add hmac-sm3 test cases from GM/T 0042-2015 Appendix D.3
Mingjun.Yang [Mon, 4 Jul 2022 09:41:54 +0000 (17:41 +0800)]
feat: add hmac-sm3 test cases from GM/T 0042-2015 Appendix D.3

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18714)

(cherry picked from commit 0648ec1c35a54fb2b7ead34a215691fe9e38516d)

22 months agoFix SHA, SHAKE, and KECCAK ASM flag passing
Juergen Christ [Thu, 7 Jul 2022 16:57:55 +0000 (18:57 +0200)]
Fix SHA, SHAKE, and KECCAK ASM flag passing

Flags for ASM implementations of SHA, SHAKE, and KECCAK were only passed to
the FIPS provider and not to the default or legacy provider.  This left some
potential for optimization.  Pass the correct flags also to these providers.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18747)

(cherry picked from commit a8b238f0e4c1198935e066ef19579ca694253286)

22 months agoMake evp_test skip mac tests if digest or ciphers are disabled.
slontis [Thu, 7 Jul 2022 02:01:09 +0000 (12:01 +1000)]
Make evp_test skip mac tests if digest or ciphers are disabled.

Fixes test error in #18714
This only happens currently during minimal builds.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18737)

(cherry picked from commit c8a016cac44d5402df3106f46c9725aa1b480e40)

22 months agoAdd an EVP demo for HMAC
Daniel Fiala [Thu, 7 Jul 2022 06:55:06 +0000 (08:55 +0200)]
Add an EVP demo for HMAC

Fixes openssl#14109

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18752)

(cherry picked from commit e269d8af79de7b0dcc1b72687eed340cc3822a9e)

22 months agossl/tls_srp.c: Add check for BN_dup
Jiasheng Jiang [Fri, 1 Jul 2022 08:23:58 +0000 (16:23 +0800)]
ssl/tls_srp.c: Add check for BN_dup

As the potential failure of the BN_dup,
it should be better to check the return value
in order to guarantee the success.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18699)

(cherry picked from commit 12e488367d34657a5c0e1bc322e66c48463d2a0c)

22 months agoNEWS.md: Drop an extra empty line causing mdlint failure
Tomas Mraz [Thu, 7 Jul 2022 08:35:16 +0000 (10:35 +0200)]
NEWS.md: Drop an extra empty line causing mdlint failure

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18740)

22 months agoFix reported performance degradation on aarch64
Bernd Edlinger [Sun, 12 Jun 2022 07:37:26 +0000 (09:37 +0200)]
Fix reported performance degradation on aarch64

This restores the implementation prior to
commit 2621751 ("aes/asm/aesv8-armx.pl: avoid 32-bit lane assignment in CTR mode")
for 64bit targets only, since it is reportedly 2-17% slower,
and the silicon errata only affects 32bit targets.
Only for 32bit targets the new algorithm is used.

Fixes #18445

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18581)

(cherry picked from commit 65523758e546fcef0f930e5f8878ef51d174dbc8)

22 months agoWindows: use the basename of the product (.dll) for definition files
Richard Levitte [Wed, 6 Jul 2022 04:54:49 +0000 (06:54 +0200)]
Windows: use the basename of the product (.dll) for definition files

This resolves the faulty LIBRARY value that contained the directory
of the product (.dll) in the build tree.  This applies to engines and
other modules alike.

Fixes #18726

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/18732)

(cherry picked from commit 5cc9ab5cf51137daf6d2d57718f56316dcb62744)

22 months agoUpdated information for OSSL_SIGNATURE_PARAM_PSS_SALTLEN
Allan [Wed, 6 Jul 2022 21:26:16 +0000 (14:26 -0700)]
Updated information for OSSL_SIGNATURE_PARAM_PSS_SALTLEN
Fixes #18066

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18736)

(cherry picked from commit d104c6ff7499b0638c82557ce94e284b00f74627)

22 months agoFixes OSCP->OCSP typo in ocsp command line
Alexander Scheel [Wed, 29 Jun 2022 14:19:58 +0000 (10:19 -0400)]
Fixes OSCP->OCSP typo in ocsp command line

The existing help text says:

>  -badsig                 Corrupt last byte of loaded OSCP response signature (for test)

but this should be OCSP. This is the only occurrence within the project
of this typo.

CLA: trivial

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18684)

(cherry picked from commit 2837b19fcba4bf4ff2ecdc8435c650bf18c27552)

22 months agohttp_client.c: fix comment and documentation of the memory BIOs used
Dr. David von Oheimb [Tue, 28 Jun 2022 10:06:52 +0000 (12:06 +0200)]
http_client.c: fix comment and documentation of the memory BIOs used

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18674)

(cherry picked from commit 7d5019c15af8f88443a7edddd4b150a7dafeda5d)

22 months agoOSSL_HTTP_REQ_CTX_nbio(): fix copy&paste glitch calling BIO_should_retry(rctx-rbio)
Dr. David von Oheimb [Tue, 28 Jun 2022 09:51:32 +0000 (11:51 +0200)]
OSSL_HTTP_REQ_CTX_nbio(): fix copy&paste glitch calling BIO_should_retry(rctx-rbio)

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18674)

(cherry picked from commit 059a4ad0999dd6dbd7340b5e4f7566812d51bb1e)

22 months agoOSSL_HTTP_open(): improve use of use_ssl and its documentation
Dr. David von Oheimb [Tue, 28 Jun 2022 15:47:40 +0000 (17:47 +0200)]
OSSL_HTTP_open(): improve use of use_ssl and its documentation

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18674)

(cherry picked from commit 35750cb9af007702dad92d62da57200fdf9ddaf4)

22 months agoapp_http_tls_cb(): fix crash on inconsistency w.r.t. use of TLS
Dr. David von Oheimb [Tue, 28 Jun 2022 09:30:50 +0000 (11:30 +0200)]
app_http_tls_cb(): fix crash on inconsistency w.r.t. use of TLS

This happens if use_ssl is not set but an SSL_CTX is provided.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18674)

(cherry picked from commit 96e13a1679872d879683346c1e09ca227f77efb0)

22 months agoopenssl-cmds.pod.in: add missing entry for cmp
Dr. David von Oheimb [Fri, 24 Jun 2022 10:39:49 +0000 (12:39 +0200)]
openssl-cmds.pod.in: add missing entry for cmp

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18653)

(cherry picked from commit 33478aedafaff1f414cabd67fb30970c41996f5c)

22 months agoFix typos in SSL_CTX_use_certificate.pod file
EasySec [Mon, 11 Apr 2022 22:15:51 +0000 (00:15 +0200)]
Fix typos in SSL_CTX_use_certificate.pod file

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18087)

(cherry picked from commit a97931955da72c39287a860155ffe071a3125f9f)

22 months agoAdd missing header for memcmp
Gregor Jasny [Tue, 5 Jul 2022 10:57:06 +0000 (12:57 +0200)]
Add missing header for memcmp

CLA: trivial

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18719)

(cherry picked from commit f9e578e720bb35228948564192adbe3bc503d5fb)

22 months agoPrepare for 3.0.6
Richard Levitte [Tue, 5 Jul 2022 08:57:42 +0000 (10:57 +0200)]
Prepare for 3.0.6

Reviewed-by: Paul Dale <pauli@openssl.org>
Release: yes

22 months agoPrepare for release of 3.0.5 openssl-3.0.5
Richard Levitte [Tue, 5 Jul 2022 08:57:04 +0000 (10:57 +0200)]
Prepare for release of 3.0.5

Reviewed-by: Paul Dale <pauli@openssl.org>
Release: yes

22 months agomake update
Richard Levitte [Tue, 5 Jul 2022 08:56:48 +0000 (10:56 +0200)]
make update

Reviewed-by: Paul Dale <pauli@openssl.org>
Release: yes

22 months agoUpdate copyright year
Richard Levitte [Tue, 5 Jul 2022 08:33:12 +0000 (10:33 +0200)]
Update copyright year

Reviewed-by: Paul Dale <pauli@openssl.org>
Release: yes

22 months agoUpdate CHANGES and NEWS for upcoming release 3.0.5
Richard Levitte [Tue, 5 Jul 2022 08:24:48 +0000 (10:24 +0200)]
Update CHANGES and NEWS for upcoming release 3.0.5

Reviewed-by: Paul Dale <pauli@openssl.org>
Release: yes

22 months agoAES OCB test vectors
Alex Chernyakhovsky [Thu, 16 Jun 2022 02:02:37 +0000 (12:02 +1000)]
AES OCB test vectors

Add test vectors for AES OCB for x86 AES-NI multiple of 96 byte issue.

Co-authored-by: Alejandro Sedeño <asedeno@google.com>
Co-authored-by: David Benjamin <davidben@google.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 2f19ab18a29cf9c82cdd68bc8c7e5be5061b19be)

22 months agoFix AES OCB encrypt/decrypt for x86 AES-NI
Alex Chernyakhovsky [Thu, 16 Jun 2022 02:00:22 +0000 (12:00 +1000)]
Fix AES OCB encrypt/decrypt for x86 AES-NI

aesni_ocb_encrypt and aesni_ocb_decrypt operate by having a fast-path
that performs operations on 6 16-byte blocks concurrently (the
"grandloop") and then proceeds to handle the "short" tail (which can
be anywhere from 0 to 5 blocks) that remain.

As part of initialization, the assembly initializes $len to the true
length, less 96 bytes and converts it to a pointer so that the $inp
can be compared to it. Each iteration of "grandloop" checks to see if
there's a full 96-byte chunk to process, and if so, continues. Once
this has been exhausted, it falls through to "short", which handles
the remaining zero to five blocks.

Unfortunately, the jump at the end of "grandloop" had a fencepost
error, doing a `jb` ("jump below") rather than `jbe` (jump below or
equal). This should be `jbe`, as $inp is pointing to the *end* of the
chunk currently being handled. If $inp == $len, that means that
there's a whole 96-byte chunk waiting to be handled. If $inp > $len,
then there's 5 or fewer 16-byte blocks left to be handled, and the
fall-through is intended.

The net effect of `jb` instead of `jbe` is that the last 16-byte block
of the last 96-byte chunk was completely omitted. The contents of
`out` in this position were never written to. Additionally, since
those bytes were never processed, the authentication tag generated is
also incorrect.

The same fencepost error, and identical logic, exists in both
aesni_ocb_encrypt and aesni_ocb_decrypt.

This addresses CVE-2022-2097.

Co-authored-by: Alejandro Sedeño <asedeno@google.com>
Co-authored-by: David Benjamin <davidben@google.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 6ebf6d51596f51d23ccbc17930778d104a57d99c)

22 months agoFix bn_gcd code to check return value when calling BN_one()
slontis [Fri, 1 Jul 2022 03:47:11 +0000 (13:47 +1000)]
Fix bn_gcd code to check return value when calling BN_one()

BN_one() uses the expand function which calls malloc which may fail.
All other places that reference BN_one() check the return value.

The issue is triggered by a memory allocation failure.
Detected by PR #18355

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18697)

(cherry picked from commit 7fe7cc57af3db1e497877f0329ba17609b2efc8b)

22 months agov3_sxnet: add a check for the return of i2s_ASN1_INTEGER()
xkernel [Mon, 20 Jun 2022 09:46:39 +0000 (17:46 +0800)]
v3_sxnet: add a check for the return of i2s_ASN1_INTEGER()

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/18608)

(cherry picked from commit 9ef1f848a646565d4dd86e56542cf921d4921ad9)

22 months agoAvoid crashing if CONF_modules_unload() is called after OPENSSL_cleanup()
Tomas Mraz [Tue, 28 Jun 2022 15:37:39 +0000 (17:37 +0200)]
Avoid crashing if CONF_modules_unload() is called after OPENSSL_cleanup()

Although this is basically an incorrect API call it was not crashing
before and it might happen inadvertently if CONF_modules_unload()
is called from a destructor for example.

Fixes #18669

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18673)

(cherry picked from commit d840f07bcdfc3910de5aa327a245866a67f94799)

22 months agoAPPS: dsaparam, gendsa: Support setting properties
Clemens Lang [Wed, 15 Jun 2022 10:50:07 +0000 (12:50 +0200)]
APPS: dsaparam, gendsa: Support setting properties

The -provider and -propquery options did not work on dsaparam and
gendsa. Fix this and add tests that check that operations that are not
supported by the FIPS provider work when run with

| -provider default -propquery '?fips!=yes'

See also https://bugzilla.redhat.com/show_bug.cgi?id=2094956, where this
was initially reported.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18576)

(cherry picked from commit 30b2c3592e8511b60d44f93eb657a1ecb3662c08)

22 months agoCoverity: fix 1506297: negative returns
Pauli [Fri, 17 Jun 2022 01:02:52 +0000 (11:02 +1000)]
Coverity: fix 1506297: negative returns

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18587)

(cherry picked from commit 3ee2611677e7e9f90e270f3ee4f343c9d3d86835)

22 months agoCoverity: fix 1506298: negative returns
Pauli [Fri, 17 Jun 2022 01:02:36 +0000 (11:02 +1000)]
Coverity: fix 1506298: negative returns

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18587)

(cherry picked from commit be54ad88a67d2fba3b4fd51bef0fe7db0c01b99a)

22 months agoDocumentation update for EVP_set_default_properties
slontis [Wed, 29 Jun 2022 00:10:16 +0000 (10:10 +1000)]
Documentation update for EVP_set_default_properties

Explicitly state that it is not thread safe.
Fixes #18613

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18678)

(cherry picked from commit 5c535e4692a5a4f2ec7691de4efc6290193a0882)

22 months agofix Coverity 1506709: error handling
Pauli [Wed, 29 Jun 2022 01:23:27 +0000 (11:23 +1000)]
fix Coverity 1506709: error handling

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18679)

(cherry picked from commit f80cdee7c1eee93d13c7dcbeda32dfca3e1e4059)

22 months agoRemove redundant check for `saltlen > UINT32_MAX`
Daniel Fiala [Tue, 28 Jun 2022 08:00:29 +0000 (10:00 +0200)]
Remove redundant check for `saltlen > UINT32_MAX`

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18671)

(cherry picked from commit 05e51bc79bac45e194dd6f0bf73c99ed5ca06272)

22 months agoFix memory leak in cmp_calc_protection()
slontis [Mon, 27 Jun 2022 23:49:17 +0000 (09:49 +1000)]
Fix memory leak in cmp_calc_protection()

Triggered by a  memory allocation failure.
Detected by PR #18355

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18670)

22 months agoAvoid using union wrt. SystemTimeToFileTime
Tee KOBAYASHI [Sun, 26 Jun 2022 08:40:29 +0000 (17:40 +0900)]
Avoid using union wrt. SystemTimeToFileTime

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18660)

(cherry picked from commit 8eca6864e080c9b8197fec81cd6f327be43bb14c)

22 months agoAvoid using union wrt. optlen parameter for getsockopt
Tee KOBAYASHI [Sun, 26 Jun 2022 08:30:02 +0000 (17:30 +0900)]
Avoid using union wrt. optlen parameter for getsockopt

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18660)

(cherry picked from commit 8e949b35d396005d63f3a2c944c36a1c94e41019)

22 months agokdf objects missing a return if malloc fails.
slontis [Thu, 23 Jun 2022 03:10:55 +0000 (13:10 +1000)]
kdf objects missing a return if malloc fails.

I have searched through all references of ERR_R_MALLOC_FAILURE for any
other instances..

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18638)

(cherry picked from commit 7260709e9ef155c8b3fccaa32e8ba496a3059905)

22 months agoSSL_get_current_cipher() and SSL_get_pending_cipher() return 'const SSL_CIPHER *'
olszomal [Fri, 17 Jun 2022 13:01:11 +0000 (15:01 +0200)]
SSL_get_current_cipher() and SSL_get_pending_cipher() return 'const SSL_CIPHER *'

Fix the documentation.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18599)

(cherry picked from commit d842b6eff0940b6ce337536cb718a8d561290f50)

22 months agoAdd test for try_key_ref() fallback handling
Tomas Mraz [Thu, 7 Apr 2022 14:48:41 +0000 (16:48 +0200)]
Add test for try_key_ref() fallback handling

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17554)

(cherry picked from commit dca637f50cf71372c46a9cf6022ad4eb9970ab7f)

22 months agoAdd missing documentation of OSSL_FUNC_store_export_object()
Tomas Mraz [Thu, 7 Apr 2022 14:48:06 +0000 (16:48 +0200)]
Add missing documentation of OSSL_FUNC_store_export_object()

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17554)

(cherry picked from commit 13941d438458068d4150c5899f6bbc0add393cc4)

22 months agoCorrect doubled OSSL_OSSL when documenting OSSL_FUNC_.._fn
Tomas Mraz [Wed, 6 Apr 2022 14:20:47 +0000 (16:20 +0200)]
Correct doubled OSSL_OSSL when documenting OSSL_FUNC_.._fn

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17554)

(cherry picked from commit 13b47155ba425ffd0683e1bff30f746c96a19049)

22 months agostore_result: Add fallback for fetching the keymgmt from the provider of the store
Tomas Mraz [Thu, 20 Jan 2022 18:49:40 +0000 (19:49 +0100)]
store_result: Add fallback for fetching the keymgmt from the provider of the store

Fixes #17531

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17554)

(cherry picked from commit 4cfcc7e1213d39c78852a614894ebcd2e2be095c)

22 months agocrypto/provider_core.c: Avoid calling unlock two times
Peiwei Hu [Thu, 23 Jun 2022 15:59:50 +0000 (23:59 +0800)]
crypto/provider_core.c: Avoid calling unlock two times

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18641)

(cherry picked from commit 61f510600e2c7cdee6e61f8b7075fb0e939eb179)

22 months agoAllocate EVP_PBE_CTL with OPENSSL_zalloc.
Daniel Fiala [Mon, 27 Jun 2022 11:36:48 +0000 (13:36 +0200)]
Allocate EVP_PBE_CTL with OPENSSL_zalloc.

Fixes openssl#18598.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18666)

(cherry picked from commit 3211266aa23253ce8af2b98c4fd94a12a4afa7e4)

22 months agoFix range_should_be_prefix() to actually return the correct result
Matt Caswell [Fri, 10 Jun 2022 14:58:58 +0000 (15:58 +0100)]
Fix range_should_be_prefix() to actually return the correct result

range_should_be_prefix() was misidentifying whether an IP address range
should in fact be represented as a prefix. This was due to a bug introduced
in commit 42d7d7dd which made this incorrect change:

-    OPENSSL_assert(memcmp(min, max, length) <= 0);
+    if (memcmp(min, max, length) <= 0)
+        return -1;

This error leads to incorrect DER being encoded/accepted.

Reported by Theo Buehler (@botovq)

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18524)

(cherry picked from commit 30532e59f475e0066c030693e4d614311a9e0cae)

22 months agofuzz/asn1.c: Add check for ASN1_item_i2d
Jiasheng Jiang [Fri, 24 Jun 2022 07:35:05 +0000 (15:35 +0800)]
fuzz/asn1.c: Add check for ASN1_item_i2d

As the potential failure of the ASN1_item_i2d,
it should be better to check the return value.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18647)

(cherry picked from commit 1cb35ce06a968dc82e7cd9502ecce8e89eca9580)

22 months agoFix memory leak in ossl_rsa_fromdata.
slontis [Fri, 24 Jun 2022 04:01:07 +0000 (14:01 +1000)]
Fix memory leak in ossl_rsa_fromdata.

Occurs if a malloc failure happens inside collect_numbers()

Reported via #18365

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18646)

(cherry picked from commit 28adea95975c3ea53fc590efda35dee13efd4767)

22 months agoAdd a test for an all 0 RSA key
Matt Caswell [Fri, 24 Jun 2022 10:02:22 +0000 (11:02 +0100)]
Add a test for an all 0 RSA key

Testing a key with all values set to 0.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18651)

(cherry picked from commit 995eccb611431a4857cac3283e2442c01109d428)

22 months agoThe rsa_validate_keypair_multiprime() function return is not boolean
Matt Caswell [Fri, 24 Jun 2022 10:01:22 +0000 (11:01 +0100)]
The rsa_validate_keypair_multiprime() function return is not boolean

A -ve return value from this function indicates an error which we should
treat as a failure to validate.

Fixes #18538

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18651)

(cherry picked from commit 518f1ee81d5a6910365ef404888d0e119a87fd81)

22 months agoImprove checks for invalid saltlen in DER writer.
Daniel Fiala [Wed, 22 Jun 2022 18:49:51 +0000 (20:49 +0200)]
Improve checks for invalid saltlen in DER writer.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 08f876d0dea184b071a5aded4c55317e5a63c80e)

22 months agoder_writer: Use uint32_t instead of long.
Daniel Fiala [Mon, 20 Jun 2022 16:40:30 +0000 (18:40 +0200)]
der_writer: Use uint32_t instead of long.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 59196250cb45ecd128d2f8bbc47de612167606d3)

22 months agoAdd checks for saltlen and trailerfield to rsa key writer.
Daniel Fiala [Sun, 19 Jun 2022 21:40:46 +0000 (23:40 +0200)]
Add checks for saltlen and trailerfield to rsa key writer.

Fixes openssl#18168.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 48320997b49b07b5abadec89c7fbe5d5f3d41da4)

22 months agoFix a memory leak in EC_GROUP_new_from_ecparameters
Bernd Edlinger [Wed, 22 Jun 2022 15:05:55 +0000 (17:05 +0200)]
Fix a memory leak in EC_GROUP_new_from_ecparameters

This can be reproduced with my error injection patch.

The test vector has been validated on the 1.1.1 branch
but the issue is of course identical in all branches.

$ ERROR_INJECT=1656112173 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/fe543a8d7e09109a9a08114323eefec802ad79e2
    #0 0x7fb61945eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
    #1 0x402f84 in my_malloc fuzz/test-corpus.c:114
    #2 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #3 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
    #4 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
    #5 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
    #6 0x7fb618e7aa13 in asn1_string_to_bn crypto/asn1/a_int.c:503
    #7 0x7fb618e7aa13 in ASN1_INTEGER_to_BN crypto/asn1/a_int.c:559
    #8 0x7fb618fd8e79 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:814
    #9 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #10 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #11 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #12 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #13 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #14 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #15 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #16 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #20 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #21 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #22 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #23 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #24 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #25 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #26 0x402afb in testfile fuzz/test-corpus.c:182
    #27 0x402656 in main fuzz/test-corpus.c:226
    #28 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
    #29 0x402756  (/home/ed/OPC/openssl/fuzz/x509-test+0x402756)

=================================================================
==12221==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #2 0x7fb618ef5f11 in BN_new crypto/bn/bn_lib.c:246
    #3 0x7fb618ef82f4 in BN_bin2bn crypto/bn/bn_lib.c:440
    #4 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
    #5 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #6 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #7 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #8 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #9 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #10 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #11 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #12 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #13 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #14 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #15 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #16 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #17 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #18 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #19 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #20 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #21 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #22 0x402afb in testfile fuzz/test-corpus.c:182
    #23 0x402656 in main fuzz/test-corpus.c:226
    #24 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

Indirect leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #2 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
    #3 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
    #4 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
    #5 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
    #6 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #7 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #8 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #9 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #10 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #11 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #12 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #13 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #14 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #15 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #16 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #20 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #21 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #22 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #23 0x402afb in testfile fuzz/test-corpus.c:182
    #24 0x402656 in main fuzz/test-corpus.c:226
    #25 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/18633)

(cherry picked from commit be50862e72d96e599f1111bbb69f41b5af651c97)

22 months agoAdded documentation for PEM_X509_INFO_read() and PEM_X509_INFO_read_bio()
Allan [Mon, 20 Jun 2022 08:22:50 +0000 (01:22 -0700)]
Added documentation for PEM_X509_INFO_read() and PEM_X509_INFO_read_bio()

Fixes #18342
Fixes <propq> to I<propq>
Updated copyright year

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18623)

(cherry picked from commit 9454423bf1eac4c75e70ff4fd67456e4cfb05a92)

22 months agoUpdate fips source checksums to drop the unwanted headers
Tomas Mraz [Wed, 22 Jun 2022 13:08:58 +0000 (15:08 +0200)]
Update fips source checksums to drop the unwanted headers

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18630)

22 months agoAvoid including decoder/encoder/store headers into fips module
Tomas Mraz [Wed, 22 Jun 2022 13:08:18 +0000 (15:08 +0200)]
Avoid including decoder/encoder/store headers into fips module

Fixes #18618

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18630)

22 months agoFix compile issues in test/v3ext.c with no-rfc3779
Bernd Edlinger [Fri, 17 Jun 2022 08:25:24 +0000 (10:25 +0200)]
Fix compile issues in test/v3ext.c with no-rfc3779

There are no ASIdentifiers if OPENSSL_NO_RFC3779 is defined,
therefore the test cannot be compiled.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18634)

(cherry picked from commit b76efe61ea9710a8f69e1cb8caf1aeb2ba6f1ebe)

22 months agoAdd a CI workflow for no-rfc3779
Bernd Edlinger [Fri, 17 Jun 2022 07:30:04 +0000 (09:30 +0200)]
Add a CI workflow for no-rfc3779

Currently this configurations seem to be failing.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18634)

(cherry picked from commit a09adac311975afcb5ad099b2e1cfc7eb1e72865)

22 months agoTest whether decoded-from-explicit survives import/export
Tomas Mraz [Mon, 20 Jun 2022 10:18:44 +0000 (12:18 +0200)]
Test whether decoded-from-explicit survives import/export

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18629)

22 months agoThe flag "decoded-from-explicit" must be imp/exportable
Tomas Mraz [Mon, 20 Jun 2022 10:10:06 +0000 (12:10 +0200)]
The flag "decoded-from-explicit" must be imp/exportable

Otherwise the information that the EC group was imported from
explicit parameters is lost when the key is moved across providers.

Fixes #18600

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18629)

22 months agoput_str: Use memcpy instead of strncpy
Tomas Mraz [Wed, 22 Jun 2022 10:50:52 +0000 (12:50 +0200)]
put_str: Use memcpy instead of strncpy

This fixes a warning from latest gcc.

There is no point in using strncpy here as we
intentionally copy only the string contents without
the terminating NUL. The len is set from strlen().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18628)

22 months agoFix the checks of X509_LOOKUP_* functions
Peiwei Hu [Tue, 24 May 2022 16:14:35 +0000 (00:14 +0800)]
Fix the checks of X509_LOOKUP_* functions

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18400)

(cherry picked from commit e22ea36fa8296b402348da8f5ab5e258be8402cf)

22 months agoFix the checks of X509_REVOKED_add1_ext_i2d
Peiwei Hu [Tue, 24 May 2022 16:09:54 +0000 (00:09 +0800)]
Fix the checks of X509_REVOKED_add1_ext_i2d

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18400)

(cherry picked from commit c540a82767954a616934ba6caa6ddc736502c574)

22 months agocrypto/http/http_client.c: Add the check for OPENSSL_strdup
Jiasheng Jiang [Wed, 22 Jun 2022 08:41:12 +0000 (16:41 +0800)]
crypto/http/http_client.c: Add the check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(), it should
be better to check the return value and return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18624)

(cherry picked from commit 816d6e578ccc4d8ae41de77e3069762d03079d18)

22 months agorsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2
Xi Ruoyao [Wed, 22 Jun 2022 10:07:05 +0000 (18:07 +0800)]
rsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2

bn_reduce_once_in_place expects the number of BN_ULONG, but factor_size
is moduli bit size.

Fixes #18625.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18626)

(cherry picked from commit 4d8a88c134df634ba610ff8db1eb8478ac5fd345)

22 months agotest/v3nametest.c: Add check for OPENSSL_malloc
Jiasheng Jiang [Wed, 15 Jun 2022 07:37:36 +0000 (15:37 +0800)]
test/v3nametest.c: Add check for OPENSSL_malloc

As the potential failure of the OPENSSL_malloc(),
it should be better to add the check and return
error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18573)

(cherry picked from commit b147b9daf17744d529f23b5da40397a6071a88aa)

22 months agotest/evp_test.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 08:57:15 +0000 (16:57 +0800)]
test/evp_test.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18592)

(cherry picked from commit 5203a8dfdc209f05c7dbd9c1e5208743fcaa6752)

22 months agoImprove diagnostics on setting groups
Dmitry Belyavskiy [Fri, 17 Jun 2022 08:08:22 +0000 (10:08 +0200)]
Improve diagnostics on setting groups

- If keymgmmt is not available, it's not an error but the error message
  persists in stack
- when setting groups, it's worth saying which group is not available
Fixes #18585

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18591)

(cherry picked from commit ce8822b7e5f4fdf836677faee336a5cf996d4363)

22 months agoapps/s_server.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 09:44:24 +0000 (17:44 +0800)]
apps/s_server.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18595)

(cherry picked from commit a6a2dd9f60b3f3e93de1337ee84f9e8f33bc86a8)

22 months agocrypto/x509/by_store.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 09:07:15 +0000 (17:07 +0800)]
crypto/x509/by_store.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18593)

(cherry picked from commit e163969d3580e5b797fcebde0d3000302912ef18)

22 months agoPrepare for 3.0.5
Matt Caswell [Tue, 21 Jun 2022 13:31:08 +0000 (14:31 +0100)]
Prepare for 3.0.5

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

22 months agoPrepare for release of 3.0.4 openssl-3.0.4
Matt Caswell [Tue, 21 Jun 2022 13:30:58 +0000 (14:30 +0100)]
Prepare for release of 3.0.4

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

22 months agomake update
Matt Caswell [Tue, 21 Jun 2022 13:30:57 +0000 (14:30 +0100)]
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

22 months agoUse --release in dev/release.sh
Hugo Landau [Fri, 13 May 2022 12:11:44 +0000 (13:11 +0100)]
Use --release in dev/release.sh

Fixes #18243.
Fixes #18242.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18305)

22 months agoUpdate copyright year
Matt Caswell [Tue, 21 Jun 2022 13:03:39 +0000 (14:03 +0100)]
Update copyright year

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

22 months agoUpdate CHANGES.md and NEWS.md for new release
Matt Caswell [Mon, 20 Jun 2022 13:14:20 +0000 (14:14 +0100)]
Update CHANGES.md and NEWS.md for new release

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

23 months agoc_rehash: Drop the issuer_name_hash= prefix from the CRL hash
Tomas Mraz [Mon, 13 Jun 2022 15:10:15 +0000 (17:10 +0200)]
c_rehash: Drop the issuer_name_hash= prefix from the CRL hash

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
23 months agoFix file operations in c_rehash.
Daniel Fiala [Sun, 29 May 2022 18:11:24 +0000 (20:11 +0200)]
Fix file operations in c_rehash.

CVE-2022-2068

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
23 months agoproviders/implementations/exchange/kdf_exch.c: fix unavailable SIZE_MAX
Richard Levitte [Mon, 20 Jun 2022 06:23:27 +0000 (08:23 +0200)]
providers/implementations/exchange/kdf_exch.c: fix unavailable SIZE_MAX

SIZE_MAX is used in a recent fix of this file, but without including
internal/numbers.h, so that macro ends up not existing on some platforms,
resulting in build failures.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18605)

23 months agoClarify use of EGD for HPNS in rand/rand_egd.c comments.
Randall S. Becker [Tue, 14 Jun 2022 10:10:53 +0000 (06:10 -0400)]
Clarify use of EGD for HPNS in rand/rand_egd.c comments.

Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18565)

23 months agoFix documentation of BIO_FLAGS_BASE64_NO_NL
Fraser Tweedale [Wed, 15 Jun 2022 00:50:57 +0000 (10:50 +1000)]
Fix documentation of BIO_FLAGS_BASE64_NO_NL

Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
`BIO_f_base64(3)` to improve the documentation of the
`BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
states that when this flag is used, all newlines in the input are
ignored.  This is incorrect, as the following program proves:

```c

unsigned char *in_buf =
    "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

int main(int argc, char **argv) {
    BIO *b64 = BIO_new(BIO_f_base64());
    if (b64 == NULL) return 1;
    BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
    int in_len = strlen(in_buf);
    BIO *in = BIO_new_mem_buf(in_buf, in_len);
    if (in == NULL) return 2;
    in = BIO_push(b64, in);
    unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
    if (out_buf == NULL) return 3;
    size_t out_len;
    int r = BIO_read_ex(in, out_buf, in_len, &out_len);
    printf("rv = %d\n", r);
    printf("decoded = %s\n", out_buf);
    return 0;
}
```

Update the text of `BIO_f_base64(3)` to clarify that when the flag
is set, the data must be all on one line (with or without a trailing
newline character).

Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18568)

(cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

23 months agoHave set_dateopt() return 1 on success to make -dateopt work
Hartmut Holzgraefe [Tue, 14 Jun 2022 08:39:47 +0000 (10:39 +0200)]
Have set_dateopt() return 1 on success to make -dateopt work

Fixes #18553

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18554)