openssl.git
21 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)

21 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)

21 months agocrypto/x509/v3_purp.c: Improve coding style
Dr. David von Oheimb [Fri, 8 Jul 2022 20:25:12 +0000 (22:25 +0200)]
crypto/x509/v3_purp.c: Improve coding style

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/18759)

21 months agocrypto/x509/x509_vfy.c: Improve coding style
Dr. David von Oheimb [Sat, 9 Jul 2022 08:44:35 +0000 (10:44 +0200)]
crypto/x509/x509_vfy.c: Improve coding style

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/18759)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 months agoAdd config option for speed command
Kan [Tue, 21 Jun 2022 06:55:55 +0000 (14:55 +0800)]
Add config option for speed command
Fixed #16986

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18616)

21 months agoAdd the LibreOffice Draw source for the QUIC overview graph
Tomas Mraz [Thu, 7 Jul 2022 15:23:10 +0000 (17:23 +0200)]
Add the LibreOffice Draw source for the QUIC overview graph

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

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 months agoAdd config option OPENSSL_NO_UNIX_SOCK
Max Bachmann [Thu, 5 May 2022 16:46:03 +0000 (18:46 +0200)]
Add config option OPENSSL_NO_UNIX_SOCK

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

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 months agoFix Coverity 1498605 & 1498606: uninitialised value
Pauli [Wed, 16 Mar 2022 03:41:37 +0000 (14:41 +1100)]
Fix Coverity 1498605 & 1498606: uninitialised value

Both of these are false positives but better to be rid of the issue permanently
than for it to repeatedly return to haunt us.

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

21 months agodoc: document the event queue internal API
Pauli [Wed, 11 May 2022 03:30:51 +0000 (13:30 +1000)]
doc: document the event queue internal API

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

21 months agoAdd unit test for event queue
Pauli [Mon, 27 Jun 2022 01:02:51 +0000 (11:02 +1000)]
Add unit test for event queue

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

21 months agossl: implement an event queue
Pauli [Tue, 10 May 2022 02:05:11 +0000 (12:05 +1000)]
ssl: implement an event queue

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

21 months agossl: add a zero time macro
Pauli [Tue, 24 May 2022 08:20:27 +0000 (18:20 +1000)]
ssl: add a zero time macro

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

21 months agoAdd sparse array to libssl
Pauli [Tue, 17 May 2022 03:35:40 +0000 (13:35 +1000)]
Add sparse array to libssl

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

21 months agoAdd additional include
Pauli [Mon, 27 Jun 2022 01:03:41 +0000 (11:03 +1000)]
Add additional include

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

21 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>
21 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>
21 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)

21 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)

21 months agoIncrease test coverage by enabling more build options
Tomas Mraz [Mon, 20 Jun 2022 05:52:24 +0000 (07:52 +0200)]
Increase test coverage by enabling more build options

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

21 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)

21 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)

21 months agoapps/cmp.c: improve print_itavs()
Dr. David von Oheimb [Fri, 3 Dec 2021 16:58:26 +0000 (17:58 +0100)]
apps/cmp.c: improve print_itavs()

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/18657)

21 months agoapps/cmp.c: Fix glitch in -newkeypass warning and extend warnings for genm
Dr. David von Oheimb [Fri, 3 Dec 2021 09:36:50 +0000 (10:36 +0100)]
apps/cmp.c: Fix glitch in -newkeypass warning and extend warnings for genm

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/18657)

21 months agoCMP: implement optional hashAlg field of certConf CMPv3 message
Dr. David von Oheimb [Fri, 6 Aug 2021 09:45:13 +0000 (11:45 +0200)]
CMP: implement optional hashAlg field of certConf CMPv3 message

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/18294)

21 months agoCMP: introduce version 3, while version 2 stays the default
Dr. David von Oheimb [Wed, 4 May 2022 13:49:47 +0000 (15:49 +0200)]
CMP: introduce version 3, while version 2 stays the default

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/18294)

21 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)

21 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)

21 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)

21 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)

21 months agoUpdate the default macsaltlen and Add the configure for macsaltlen
Kan [Tue, 14 Jun 2022 04:06:39 +0000 (12:06 +0800)]
Update the default macsaltlen and Add the configure for macsaltlen
Fixed #18489

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/18550)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 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)

21 months agoCMS: Export CMS_EnvelopedData and add CMS_EnvelopedData_decrypt()
Dr. David von Oheimb [Mon, 9 May 2022 19:00:03 +0000 (21:00 +0200)]
CMS: Export CMS_EnvelopedData and add CMS_EnvelopedData_decrypt()

Also document CMS_decrypt_set1_password() and fix CMS_EnvelopedData_create.pod.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
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/18301)

21 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)

21 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)

21 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)

21 months agoAdd a DTLS next epoch test
Matt Caswell [Fri, 17 Jun 2022 15:37:24 +0000 (16:37 +0100)]
Add a DTLS next epoch test

Test that if we receive a packet from the next epoch, we can buffer it
and still use it.

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

21 months agoObjects: Add OIDs needed for CAdES-Processing
Lutz Jaenicke [Mon, 13 Sep 2021 10:20:38 +0000 (12:20 +0200)]
Objects: Add OIDs needed for CAdES-Processing

Add objects from ETSI-specification(s) used in CAdES processing.
Main document referenced is ETSI EN 319 122-1 V1.2.1.

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

21 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)

21 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)

21 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)

21 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)

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)

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)

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)

22 months agotest: placate Clang's --Wbitwise-instead-of-logical
Sam James [Fri, 24 Jun 2022 07:12:00 +0000 (08:12 +0100)]
test: placate Clang's --Wbitwise-instead-of-logical

```
test/test_test.c:58:9: note: cast one or both operands to int to silence this warning
test/test_test.c:58:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
    if (!TEST(1, TEST_uint_eq(3u, 3u))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/test_test.c:58:9: note: cast one or both operands to int to silence this warning
```

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

22 months agoCI: Upgrade to Ubuntu 22.04 to add GCC 12, Clang 13, Clang 14
Sam James [Thu, 23 Jun 2022 03:24:32 +0000 (04:24 +0100)]
CI: Upgrade to Ubuntu 22.04 to add GCC 12, Clang 13, Clang 14

Notably, this might have caught #18225, as Clang 14 wasn't - and is not yet
until this commit - in OpenSSL's CI.

It makes sense to ensure CI tests compilers used in newer Linux distributions:
* Fedora 36 ships with GCC 12
* Ubuntu 22.04 ships with Clang 14

We switch from 'ubuntu-latest' (which can change meaning but currently points
to ubuntu-20.04) to ubuntu-20.04 for the older existing compilers, and
ubuntu-22.04 for the newer ones added by this commit.

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

22 months agoCI: add GCC 11
Sam James [Wed, 22 Jun 2022 06:20:31 +0000 (07:20 +0100)]
CI: add GCC 11

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

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)

22 months agoAdd initial demo-driven design demos
Hugo Landau [Tue, 29 Mar 2022 12:53:58 +0000 (13:53 +0100)]
Add initial demo-driven design demos

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

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)

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)

(cherry picked from commit b07db93f6b38aaea8b131f7dcfba7ad7386196d2)

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)

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)

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/18609)

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/18609)

22 months agoput_str: Use memcpy instead of strncpy
Tomas Mraz [Wed, 22 Jun 2022 10:36:02 +0000 (12:36 +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/18627)

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)

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)

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)

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)

22 months agoAdd ROTATE inline asm support for SM3
Hongren (Zenithal) Zheng [Wed, 11 May 2022 09:18:27 +0000 (17:18 +0800)]
Add ROTATE inline asm support for SM3

And move ROTATE inline asm to header.

Now this benefits SM3, SHA (when with Zbb only and no Zknh)
and other hash functions

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

22 months agoAdd SM3 implementation in RISC-V Zksh asm
Hongren (Zenithal) Zheng [Wed, 11 May 2022 08:11:18 +0000 (16:11 +0800)]
Add SM3 implementation in RISC-V Zksh asm

This works for both RV32 and RV64

Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18287)