openssl.git
2 years agoPEM_read_...: document that garbage and other PEM data is skipped
Tomas Mraz [Wed, 30 Jun 2021 16:02:24 +0000 (18:02 +0200)]
PEM_read_...: document that garbage and other PEM data is skipped

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

2 years agoload_key_certs_crls: Avoid reporting any spurious errors
Tomas Mraz [Wed, 30 Jun 2021 14:11:17 +0000 (16:11 +0200)]
load_key_certs_crls: Avoid reporting any spurious errors

When there is other PEM data in between certs the OSSL_STORE_load
returns NULL and reports error. Avoid printing that error unless
there was nothing read at all.

Fixes #15945

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

2 years agotest_pem_reading: Test loading a key from a file with multiple PEM data
Tomas Mraz [Tue, 29 Jun 2021 15:18:34 +0000 (17:18 +0200)]
test_pem_reading: Test loading a key from a file with multiple PEM data

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

2 years agoload_pkey_pem: Check for spurious errors when loading
Tomas Mraz [Tue, 29 Jun 2021 14:44:00 +0000 (16:44 +0200)]
load_pkey_pem: Check for spurious errors when loading

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

2 years agopem_read_bio_key: Add passphrase caching to avoid asking for password twice
Tomas Mraz [Tue, 29 Jun 2021 14:24:59 +0000 (16:24 +0200)]
pem_read_bio_key: Add passphrase caching to avoid asking for password twice

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

2 years agopem_read_bio_key_decoder: Avoid spurious error on unknown PEM data
Tomas Mraz [Tue, 29 Jun 2021 13:46:25 +0000 (15:46 +0200)]
pem_read_bio_key_decoder: Avoid spurious error on unknown PEM data

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

2 years agoFix compile errors when building with --api=1.1.0 no-deprecated.
Shane Lontis [Thu, 1 Jul 2021 02:01:22 +0000 (12:01 +1000)]
Fix compile errors when building with --api=1.1.0 no-deprecated.

Fixes #15963

INSTALL.md uses these exact options as an example so it should work.

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

2 years agoupdate pyca-cryptography regression test suite
Paul Kehrer [Thu, 1 Jul 2021 13:24:49 +0000 (08:24 -0500)]
update pyca-cryptography regression test suite

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

2 years agoDefined out MUTEX attributes not available on NonStop SPT Threads.
Randall S. Becker [Wed, 23 Jun 2021 20:50:09 +0000 (14:50 -0600)]
Defined out MUTEX attributes not available on NonStop SPT Threads.

Standard Posix Threads (SPT) Threads are an older separate branch of
pthreads that do not support some of the capabilities in the current
Posix User Threads (PUT).

The change also includes a rename of the close field of OSSL_STORE_LOADER
which was causing preprocessor conflicts.

Fixes #15885

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

2 years agodoc: Mention the update of der data pointers in d2i/i2d
Tomas Mraz [Wed, 30 Jun 2021 09:17:09 +0000 (11:17 +0200)]
doc: Mention the update of der data pointers in d2i/i2d

Fixes #15958

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

2 years agoDOC: clarify OPENSSL_API_COMPAT
Richard Levitte [Wed, 30 Jun 2021 04:31:58 +0000 (06:31 +0200)]
DOC: clarify OPENSSL_API_COMPAT

Fixes #15928

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

2 years agoci: add a memory sanitiser test run
Pauli [Tue, 29 Jun 2021 23:25:40 +0000 (09:25 +1000)]
ci: add a memory sanitiser test run

This omission noted in #15950

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

2 years agoafalg: add some memory initialisation calls to pacify memory sanitisation.
Pauli [Wed, 30 Jun 2021 00:21:17 +0000 (10:21 +1000)]
afalg: add some memory initialisation calls to pacify memory sanitisation.

The engine is modifying memory without the sanitiser realising.  By pre-
initialising this memory, the sanitiser now thinks that read accesses are okay.

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

2 years agoDocument cross-compile considerations for NonStop x86 builds.
Randall S. Becker [Tue, 29 Jun 2021 14:39:29 +0000 (08:39 -0600)]
Document cross-compile considerations for NonStop x86 builds.

Fixes #15919

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15948)

2 years agoFix use of uninitialized memory in test_rsa_oaep
David Benjamin [Tue, 29 Jun 2021 18:41:12 +0000 (14:41 -0400)]
Fix use of uninitialized memory in test_rsa_oaep

48f1739600f33c92387debce2002acec6e365f1d did not convert the RSA OAEP
tests correctly. The corrupted ciphertext and truncation tests were
really decrypting uninitialized memory, rather than the sample
ciphertext. This results in an error in tools like MSan.

The test is somewhat roundabout. In the original version, before the
conversion, ctext_ex was an OAEP test vector from key1(), etc.,
functions. The test would:

1. Encrypt ptext_ex as ctext.
2. Decrypt ctext and check it gives ptext_ex.
3. Decrypt ctext_ex and check it gives ptext_ex.
4. Try corrupted and truncated versions of ctext.

48f1739600f33c92387debce2002acec6e365f1d then moved steps 1 and 2 into
test_rsa_simple, which meant ctext is no longer available for step 4. It
then mistakenly left the variable around, but uninitialized, so the test
wasn't testing anything. (Confusingly, test_rsa_simple outputs ctext_ex
to the caller, but doesn't do anything with it. The ctext_ex output is
also only usable for OAEP, not PKCS#1 v1.5.)

It doesn't really matter whether we use ctext or ctext_ex for step 4, so
this PR fixes it by using ctext_ex instead.

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

2 years agoOSSL_CRMF_{CERTTEMPLATE,CERTID}_get0_serialNumber(): Make result const for consistency
Dr. David von Oheimb [Tue, 29 Jun 2021 09:11:05 +0000 (11:11 +0200)]
OSSL_CRMF_{CERTTEMPLATE,CERTID}_get0_serialNumber(): Make result const for consistency

Also make doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod consistent with crmf.h.in regarding const results

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

2 years agocmp_mock_srv.c: Add missing OldCertID check for 'kur' cert update requests
Dr. David von Oheimb [Tue, 22 Jun 2021 13:40:49 +0000 (15:40 +0200)]
cmp_mock_srv.c: Add missing OldCertID check for 'kur' cert update requests

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

2 years agoCMP: Add missing getter functions to CRMF API and CMP API
Dr. David von Oheimb [Wed, 16 Jun 2021 08:26:26 +0000 (10:26 +0200)]
CMP: Add missing getter functions to CRMF API and CMP API

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

2 years agotest: fix test ordering in threads test
Pauli [Wed, 30 Jun 2021 01:13:35 +0000 (11:13 +1000)]
test: fix test ordering in threads test

Fixes #15953

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

2 years agoevp: fix coverity 1473380 Copy into fixed size buffer (STRING_OVERFLOW)
Pauli [Mon, 28 Jun 2021 22:26:11 +0000 (08:26 +1000)]
evp: fix coverity 1473380 Copy into fixed size buffer (STRING_OVERFLOW)

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

2 years agodh_test: fix coverity 1473239 Argument cannot be negative (NEGATIVE_RETURNS)
Pauli [Mon, 28 Jun 2021 22:18:30 +0000 (08:18 +1000)]
dh_test: fix coverity 1473239 Argument cannot be negative (NEGATIVE_RETURNS)

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

2 years agos_time: avoid unlikely division by zero
Pauli [Mon, 28 Jun 2021 22:05:19 +0000 (08:05 +1000)]
s_time: avoid unlikely division by zero

Fixing coverity 966560 Division or modulo by zero (DIVIDE_BY_ZERO)

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

2 years agobio: check for valid socket when closing
Pauli [Mon, 28 Jun 2021 22:01:13 +0000 (08:01 +1000)]
bio: check for valid socket when closing

Fixes coverity 271258 Improper use of negative value (NEGATIVE_RETURNS)

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

2 years agotest: fix coverity 1469427 Improper use of negative value (NEGATIVE_RETURNS)
Pauli [Mon, 28 Jun 2021 21:59:00 +0000 (07:59 +1000)]
test: fix coverity 1469427 Improper use of negative value (NEGATIVE_RETURNS)

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

2 years agox509: improve error reporting
Pauli [Tue, 29 Jun 2021 01:43:00 +0000 (11:43 +1000)]
x509: improve error reporting

Distinguish between not being able to extract a public key versus not knowing
the key's type.

Alternative to #15921

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

2 years agoMissing link to fips_config documentation
Dmitry Belyavskiy [Mon, 28 Jun 2021 13:44:45 +0000 (15:44 +0200)]
Missing link to fips_config documentation

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

2 years agocoverity #1486532: fix potential NULL dereference in test_mk_file_path()
Tomas Mraz [Mon, 28 Jun 2021 15:13:31 +0000 (17:13 +0200)]
coverity #1486532: fix potential NULL dereference in test_mk_file_path()

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15942)

2 years agocoverity #1486531: return error properly from x509_pubkey_ex_new_ex()
Tomas Mraz [Mon, 28 Jun 2021 15:09:08 +0000 (17:09 +0200)]
coverity #1486531: return error properly from x509_pubkey_ex_new_ex()

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15942)

2 years agoEVP: Have EVP_PKCS82PKEY_ex() pass a correct selection to OSSL_DECODER
Richard Levitte [Mon, 28 Jun 2021 05:08:51 +0000 (07:08 +0200)]
EVP: Have EVP_PKCS82PKEY_ex() pass a correct selection to OSSL_DECODER

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

2 years agoDECODER & ENCODER: Make sure to pass around the original selection bits
Richard Levitte [Mon, 28 Jun 2021 03:52:42 +0000 (05:52 +0200)]
DECODER & ENCODER: Make sure to pass around the original selection bits

When decoding a key and asking the keymgmt to import the key data, it
was told that the key data includes everything.  This may not be true,
since the user may have specified a different selection, and some
keymgmts may want to be informed.

Our key decoders' export function, on the other hand, didn't care
either, and simply export anything they could, regardless.

In both cases, the selection that was specified by the user is now
passed all the way.

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

2 years agoossl_cmp_error_new(): Fix Coverity issue 1486534, and consequently also issues 148653...
Dr. David von Oheimb [Mon, 28 Jun 2021 10:17:25 +0000 (12:17 +0200)]
ossl_cmp_error_new(): Fix Coverity issue 1486534, and consequently also issues 1486536 and 1486533

The issues are due to an integer overflow that may happen on '(ERR_SYSTEM_FLAG << 1)'.

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

2 years agodoc: make error checking in ticket handling code explicit
Hubert Kario [Fri, 25 Jun 2021 11:34:31 +0000 (13:34 +0200)]
doc: make error checking in ticket handling code explicit

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

2 years agodarwin platform replacing getentropy usage by platform api instead.
David CARLIER [Sat, 26 Jun 2021 13:12:38 +0000 (14:12 +0100)]
darwin platform replacing getentropy usage by platform api instead.

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

2 years agoOSSL_STORE: Fix crash when tracing STORE
Richard Levitte [Mon, 28 Jun 2021 02:36:33 +0000 (04:36 +0200)]
OSSL_STORE: Fix crash when tracing STORE

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

2 years agoENCODER & DECODER: Make a tighter coupling between en/decoders and keymgmt
Richard Levitte [Mon, 28 Jun 2021 03:37:22 +0000 (05:37 +0200)]
ENCODER & DECODER: Make a tighter coupling between en/decoders and keymgmt

If there are keymgmts and en/decoders from the same provider, try to
combine them first.

This avoids unnecessary export/import dances, and also tries to avoid
issues where the keymgmt doesn't fully support exporting and importing,
which we can assume will be the case for HSM protected keys.

Fixes #15932

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

2 years agoPROV: Have our PEM->DER decoder only recognise our PEM names
Richard Levitte [Mon, 28 Jun 2021 02:29:17 +0000 (04:29 +0200)]
PROV: Have our PEM->DER decoder only recognise our PEM names

This is to avoid creating confusion where other PEM decoder
implementations may know better what PEM names that are unknown to us
actually mean.

Fixes #15929

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

2 years agoEnsure ordinals are created during release process
Matt Caswell [Thu, 24 Jun 2021 15:07:03 +0000 (16:07 +0100)]
Ensure ordinals are created during release process

We introduce a new makefile target "make release-update" that forces
ordinal file renumbering, and also does the fips checksum updates. We
then call that  from the release script.

Fixes #15806

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

2 years agoUpdate config.pm
Lőrinczy, Zsigmond [Fri, 25 Jun 2021 05:28:56 +0000 (07:28 +0200)]
Update config.pm

Missing '(' added into a PowerPC-specific command

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

2 years agoevp_test: use correct size in memory clear
Pauli [Fri, 25 Jun 2021 13:18:28 +0000 (23:18 +1000)]
evp_test: use correct size in memory clear

Fixes #15917

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

2 years agoDOC: Clarify the role of EKUs including defaults for TLS client and server use
Dr. David von Oheimb [Tue, 16 Feb 2021 10:17:07 +0000 (11:17 +0100)]
DOC: Clarify the role of EKUs including defaults for TLS client and server use

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

2 years agoFix 'openssl req' to correctly use the algorithm from '-newkey algo:nnnn'
Richard Levitte [Fri, 25 Jun 2021 06:36:30 +0000 (08:36 +0200)]
Fix 'openssl req' to correctly use the algorithm from '-newkey algo:nnnn'

We used the original string, which meant fetching for, for example,
'rsa:2048'.  That was, of course, doomed to fail.

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

2 years agoENCODER & DECODER: Allow en/decoders to have multiple names
Richard Levitte [Thu, 24 Jun 2021 16:44:26 +0000 (18:44 +0200)]
ENCODER & DECODER: Allow en/decoders to have multiple names

We had prepared for this a little bit, but apparently not completed it.

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

2 years agodoc: update up call documentation
Pauli [Fri, 25 Jun 2021 00:51:45 +0000 (10:51 +1000)]
doc: update up call documentation

Some of the BIO functions weren't included in the provider-base documentation.

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

2 years agotest/recipes/90-test_includes_data/vms-includes.cnf: correct the directory
Richard Levitte [Tue, 22 Jun 2021 09:08:24 +0000 (11:08 +0200)]
test/recipes/90-test_includes_data/vms-includes.cnf: correct the directory

... to mimic includes.cnf

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

2 years agoapps/CA.pl.in: restore the quotes around -CAfile, they were there for a reason
Richard Levitte [Tue, 22 Jun 2021 08:52:09 +0000 (10:52 +0200)]
apps/CA.pl.in: restore the quotes around -CAfile, they were there for a reason

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

2 years agotest/recipes/80-test_ca.t: Don't force quotes around the config file in $cnf
Richard Levitte [Tue, 22 Jun 2021 08:38:55 +0000 (10:38 +0200)]
test/recipes/80-test_ca.t: Don't force quotes around the config file in $cnf

However, when passing it through the OPENSSL_CONFIG environment
variable, we still need the quotes, just to make sure.

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

2 years agotest/recipes/66-test_ossl_store.t: ensure native paths
Richard Levitte [Tue, 22 Jun 2021 06:04:12 +0000 (08:04 +0200)]
test/recipes/66-test_ossl_store.t: ensure native paths

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

2 years agotestutil: teach test_mk_file_path() how to merge VMS file specs
Richard Levitte [Tue, 22 Jun 2021 06:03:47 +0000 (08:03 +0200)]
testutil: teach test_mk_file_path() how to merge VMS file specs

This isn't a full solution, it only handles current use cases.

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

2 years agotest/ossl_store_test.c: Adapt the use of datadir for VMS paths
Richard Levitte [Tue, 22 Jun 2021 05:28:26 +0000 (07:28 +0200)]
test/ossl_store_test.c: Adapt the use of datadir for VMS paths

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

2 years agoUTF-8 not easily supported on VMS command line yet
Richard Levitte [Wed, 16 Jun 2021 04:47:58 +0000 (06:47 +0200)]
UTF-8 not easily supported on VMS command line yet

Some tests are designed to test UTF-8 on the command line.
We simply disable those on VMS.

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

2 years agoFix test_errstr for VMS
Richard Levitte [Wed, 16 Jun 2021 04:46:45 +0000 (06:46 +0200)]
Fix test_errstr for VMS

Occasionally, we get an error code on VMS that doesn't translate
into POSIX, and the error string reflects that

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

2 years agoFix segfault in openssl x509 -modulus
Christian Heimes [Thu, 24 Jun 2021 15:47:30 +0000 (17:47 +0200)]
Fix segfault in openssl x509 -modulus

The command ``openssl x509 -noout -modulus -in cert.pem`` used to segfaults
sometimes because an uninitialized variable was passed to
``BN_lebin2bn``. The bug triggered an assertion in bn_expand_internal().

Fixes: https://github.com/openssl/openssl/issues/15899
Signed-off-by: Christian Heimes <christian@python.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15900)

2 years agoAdd wrap.pl to .gitignore
Matt Caswell [Thu, 24 Jun 2021 10:24:07 +0000 (11:24 +0100)]
Add wrap.pl to .gitignore

This file is now auto-generated from a template (wrap.pl.in). Therefore
it should be ignored by git.

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

2 years agoFix two typos in OSSL_trace_enabled.pod
Theo Buehler [Thu, 24 Jun 2021 09:37:04 +0000 (11:37 +0200)]
Fix two typos in OSSL_trace_enabled.pod

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

2 years agotest: check for NULL returns better
Pauli [Fri, 25 Jun 2021 02:57:53 +0000 (12:57 +1000)]
test: check for NULL returns better

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agotest: avoid memory leaks on errors
Pauli [Fri, 25 Jun 2021 02:57:37 +0000 (12:57 +1000)]
test: avoid memory leaks on errors

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agoevp_test: address NULL pointer dereference and return failure better
Pauli [Fri, 25 Jun 2021 02:56:57 +0000 (12:56 +1000)]
evp_test: address NULL pointer dereference and return failure better

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agoui: address potential memory leak
Pauli [Fri, 25 Jun 2021 02:56:01 +0000 (12:56 +1000)]
ui: address potential memory leak

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agoapps: address potential memory leaks
Pauli [Fri, 25 Jun 2021 02:55:28 +0000 (12:55 +1000)]
apps: address potential memory leaks

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agox509: address NULL dereference and memory leaks
Pauli [Fri, 25 Jun 2021 02:54:43 +0000 (12:54 +1000)]
x509: address NULL dereference and memory leaks

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

2 years agoapps: properly initialise arguments to EVP_PKEY_get_bn_param()
Pauli [Thu, 24 Jun 2021 23:28:26 +0000 (09:28 +1000)]
apps: properly initialise arguments to EVP_PKEY_get_bn_param()

This avoids use of uninitialised memory.

Follow on to #15900

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15908)

2 years agoUpdate fips sources and checksums
Tomas Mraz [Thu, 24 Jun 2021 16:09:40 +0000 (18:09 +0200)]
Update fips sources and checksums

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

2 years agoOnly the fips module dependencies are relevant for fips.module.sources
Tomas Mraz [Thu, 24 Jun 2021 16:08:18 +0000 (18:08 +0200)]
Only the fips module dependencies are relevant for fips.module.sources

Fixes #15639

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

2 years agoFix file_name_check() in storemgmt/file_store.c and e_loader_attic.c
Dr. David von Oheimb [Thu, 24 Jun 2021 09:08:10 +0000 (11:08 +0200)]
Fix file_name_check() in storemgmt/file_store.c and e_loader_attic.c

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

2 years agoenable getauxval on android 10
yunh [Wed, 23 Jun 2021 01:46:42 +0000 (09:46 +0800)]
enable getauxval on android 10

Fixes #9498

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

(cherry picked from commit b2dea4d5f22ec146373324c282fb1bcecd5a7d90)

2 years agoppccap.c: Split out algorithm-specific functions
Tomas Mraz [Fri, 18 Jun 2021 15:35:40 +0000 (17:35 +0200)]
ppccap.c: Split out algorithm-specific functions

Fixes #13336

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

2 years agoCMP: Improve reporting of error codes and related strings via 'error' msg
Dr. David von Oheimb [Wed, 23 Jun 2021 12:47:57 +0000 (14:47 +0200)]
CMP: Improve reporting of error codes and related strings via 'error' msg

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

2 years agoossl_sk_ASN1_UTF8STRING2text(): Minor generalization and refactoring for readability
Dr. David von Oheimb [Wed, 23 Jun 2021 12:26:22 +0000 (14:26 +0200)]
ossl_sk_ASN1_UTF8STRING2text(): Minor generalization and refactoring for readability

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

2 years agoCMP: Clean up internal message creation API and its documentation
Dr. David von Oheimb [Wed, 23 Jun 2021 11:40:50 +0000 (13:40 +0200)]
CMP: Clean up internal message creation API and its documentation

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

2 years agotest: add EVP_Q_mac tests to evp_test
Pauli [Thu, 24 Jun 2021 01:47:48 +0000 (11:47 +1000)]
test: add EVP_Q_mac tests to evp_test

Fixes #15837

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/15888)

2 years agotest: add EVP_Q_digest tests to evp_test
Pauli [Thu, 24 Jun 2021 01:32:50 +0000 (11:32 +1000)]
test: add EVP_Q_digest tests to evp_test

Fixes #15837

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/15888)

2 years agoOpenSSL::Util::fixup_cmd_elements(): Include '!' among the VMS chars to process
Richard Levitte [Thu, 24 Jun 2021 04:54:14 +0000 (06:54 +0200)]
OpenSSL::Util::fixup_cmd_elements(): Include '!' among the VMS chars to process

! is the DCL character that starts a comment, and therefore acts as a
cut-off if not quoted.

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

2 years agoBIO_new_from_core_bio: Fix heap-use-after-free after attach
Petr Gotthard [Wed, 5 May 2021 16:32:55 +0000 (18:32 +0200)]
BIO_new_from_core_bio: Fix heap-use-after-free after attach

The providers have to call up_ref to keep the cbio pointer, just like
the internal bio_prov.c does.

OSSL_STORE_attach passes a cbio pointer to the provider and then calls
ossl_core_bio_free(cbio). If up_ref is not called, the cbio gets
freed way too early.

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

2 years agotrace: Do not produce dead code calling BIO_printf if disabled
Tomas Mraz [Wed, 23 Jun 2021 15:16:36 +0000 (17:16 +0200)]
trace: Do not produce dead code calling BIO_printf if disabled

Fixes #15880

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

2 years agoFix a race in ossl_provider_add_to_store()
Matt Caswell [Tue, 22 Jun 2021 14:39:40 +0000 (15:39 +0100)]
Fix a race in ossl_provider_add_to_store()

If two threads both attempt to load the same provider at the same time,
they will first both check to see if the provider already exists. If it
doesn't then they will both then create new provider objects and call the
init function. However only one of the threads will be successful in adding
the provider to the store. For the "losing" thread we should still return
"success", but we should deinitialise and free the no longer required
provider object, and return the object that exists in the store.

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

2 years agoMove OPENSSL_add_builtin back into provider.c
Matt Caswell [Tue, 22 Jun 2021 11:07:48 +0000 (12:07 +0100)]
Move OPENSSL_add_builtin back into provider.c

An earlier stage of the refactor in the last few commits moved this
function out of provider.c because it needed access to the provider
structure internals. The final version however no longer needs this so
it is moved back again.

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

2 years agoUpdate documentation following updates to the provider code
Matt Caswell [Mon, 21 Jun 2021 16:09:32 +0000 (17:09 +0100)]
Update documentation following updates to the provider code

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

2 years agomake struct provider_info_st a full type
Matt Caswell [Mon, 21 Jun 2021 14:59:41 +0000 (15:59 +0100)]
make struct provider_info_st a full type

Create the OSSL_PROVIDER_INFO to replace struct provider_info_st.

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

2 years agoDon't skip the current provider in ossl_provider_register_child_cb
Matt Caswell [Mon, 21 Jun 2021 14:37:48 +0000 (15:37 +0100)]
Don't skip the current provider in ossl_provider_register_child_cb

This restriction was in place to avoid problems with recursive attempts
to aquire the flag lock/store lock from within a provider's init function.
Since those locks are no longer held when calling the init function there
is no reason for the restriction any more.

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

2 years agoAdd a test to check that RAND_bytes_ex() works with a child lib ctx
Matt Caswell [Mon, 21 Jun 2021 12:01:57 +0000 (13:01 +0100)]
Add a test to check that RAND_bytes_ex() works with a child lib ctx

Previously, when locks were held while calling a provider init function,
then RAND_bytes_ex() would fail if called from the init function and
used in conjunction with a child lib ctx. We add an explicit test of that.

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

2 years agoDon't hold any locks while calling the provider init function
Matt Caswell [Mon, 21 Jun 2021 11:49:59 +0000 (12:49 +0100)]
Don't hold any locks while calling the provider init function

Previously providers were added to the store first, and then subsequently
initialised. This meant that during initialisation the provider object
could be shared between multiple threads and hence the locks needed to be
held. However this causes problems because the provider init function is
essentially a user callback and could do virtually anything. There are
many API calls that could be invoked that could subsequently attempt to
acquire the locks. This will fail because the locks are already held.

However, now we have refactored things so that the provider is created and
initialised before being added to the store. Therefore at the point of
initialisation the provider object is not shared with other threads and so
no locks need to be held.

Fixes #15793
Fixes #15712

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

2 years agoOnly associate a provider with a store once it has been added to it
Matt Caswell [Mon, 21 Jun 2021 11:13:31 +0000 (12:13 +0100)]
Only associate a provider with a store once it has been added to it

This means we can distinguish providers that have been added to the
store, and those which haven't yet been.

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

2 years agoMerge ossl_provider_activate() and ossl_provider_activate_child()
Matt Caswell [Mon, 21 Jun 2021 11:08:39 +0000 (12:08 +0100)]
Merge ossl_provider_activate() and ossl_provider_activate_child()

These 2 functions have become so close to each other that they may as well
be just one function.

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

2 years agoSet use_fallbacks to zero when we add a provider to the store
Matt Caswell [Mon, 21 Jun 2021 10:34:04 +0000 (11:34 +0100)]
Set use_fallbacks to zero when we add a provider to the store

Update use_fallbacks to zero when we add a provider to the store rather
than when we activate it. Its only at the point that we add it to the store
that it is actually usable and visible to other threads.

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

2 years agoRemove flag_couldbechild
Matt Caswell [Mon, 21 Jun 2021 10:06:12 +0000 (11:06 +0100)]
Remove flag_couldbechild

Now that a provider is no longer put into the store until after it has
been activated we don't need flag_couldbechild any more. This flag was
used to indicate whether a provider was eligible for conversion into a
child provider or not. This was only really interesting for predefined
providers that were automatically created.

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

2 years agoAdd a new provider to the store only after we activate it
Matt Caswell [Mon, 21 Jun 2021 08:23:30 +0000 (09:23 +0100)]
Add a new provider to the store only after we activate it

Rather than creating the provider, adding to the store and then activating
it, we do things the other way around, i.e. activate first and then add to
the store. This means that the activation should occur before other threads
are aware of the provider.

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

2 years agoInstantiate configuration supplied providers when we need them
Matt Caswell [Fri, 18 Jun 2021 14:56:54 +0000 (15:56 +0100)]
Instantiate configuration supplied providers when we need them

If provider specified in a config file are not "activated" then we defer
instantiating the provider object until it is actually needed.

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

2 years agoInstantiate user-added builtin providers when we need them
Matt Caswell [Fri, 18 Jun 2021 11:28:40 +0000 (12:28 +0100)]
Instantiate user-added builtin providers when we need them

Previously we created the provider object for builtin providers at the
point that OPENSSL_add_builtin() was called. Instead we delay that until
the provider is actually loaded.

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

2 years agoInstantiate predefined providers just-in-time
Matt Caswell [Fri, 18 Jun 2021 09:08:23 +0000 (10:08 +0100)]
Instantiate predefined providers just-in-time

Previously we instantiated all the predefined providers at the point that
we create the provider store. Instead we move them to be instantiated as we
need them.

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

2 years agoOSSL_DECODER_from_bio: Avoid spurious decoder error
Tomas Mraz [Wed, 23 Jun 2021 11:53:58 +0000 (13:53 +0200)]
OSSL_DECODER_from_bio: Avoid spurious decoder error

If there are any new errors reported we avoid raising the
OSSL_DECODER_from_bio:unsupported error.

Fixes #14566

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

2 years agoepki2pki_decode: passphrase callback failure is fatal error
Tomas Mraz [Wed, 23 Jun 2021 11:53:53 +0000 (13:53 +0200)]
epki2pki_decode: passphrase callback failure is fatal error

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

2 years agoossl_pw_get_passphrase: No ui method does not necessarily mean internal error
Tomas Mraz [Wed, 23 Jun 2021 11:52:10 +0000 (13:52 +0200)]
ossl_pw_get_passphrase: No ui method does not necessarily mean internal error

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

2 years agoDocumentation: SM2 keys can use only the SM2 curve
Tomas Mraz [Wed, 23 Jun 2021 07:40:56 +0000 (09:40 +0200)]
Documentation: SM2 keys can use only the SM2 curve

Fixes #14411

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

2 years agosimpledynamic: Add missing include for AIX builds
Tomas Mraz [Wed, 23 Jun 2021 07:23:53 +0000 (09:23 +0200)]
simpledynamic: Add missing include for AIX builds

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

2 years agoTEST: Modify simpledynamic.[ch] to allow use on VMS as well
Richard Levitte [Wed, 23 Jun 2021 06:21:04 +0000 (08:21 +0200)]
TEST: Modify simpledynamic.[ch] to allow use on VMS as well

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

2 years agotest/recipes/90-test_shlibload.t: Modify to work with known file names
Richard Levitte [Wed, 23 Jun 2021 06:10:37 +0000 (08:10 +0200)]
test/recipes/90-test_shlibload.t: Modify to work with known file names

Using File::Temp::tempfile() is admirable, but isn't necessary for the
sort of thing we use it for.

Furthermore, since tempfile() returns an opened file handle for
reading for the file in question, it may have effect that the file
becomes unwritable.  This is the default on VMS, and since tempfile()
doesn't seem to have any option to affect this, it means that
test/shlibloadtest.c can't write the magic line to that file.

Also, if we consider forensics, to be able to see what a test produced
to determine what went wrong, it's better to use specific and known
file names.

Therefore, this test is modified to use well known file names, and to
open them for reading after the shlibloadtest program has been run
instead of before.

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

2 years agoproperty: remove spurious incorrect comments
Pauli [Wed, 23 Jun 2021 04:18:25 +0000 (14:18 +1000)]
property: remove spurious incorrect comments

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

2 years agoproperty: add locking for the property string database
Pauli [Wed, 23 Jun 2021 04:18:07 +0000 (14:18 +1000)]
property: add locking for the property string database

This previously relied on the caller locking the property store correctly.
This is no longer the case so the string database now requires locking.

Fixes #15866

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

2 years agoerr: add unable to get lock errors
Pauli [Wed, 23 Jun 2021 04:17:59 +0000 (14:17 +1000)]
err: add unable to get lock errors

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

2 years agodoc: Document that the OBJ creation functions don't lock.
Pauli [Tue, 22 Jun 2021 23:46:42 +0000 (09:46 +1000)]
doc: Document that the OBJ creation functions don't lock.

Neither OBJ_create() nor OBJ_add_sigid() use locks.  They are not thread safe.
They can and will cause the other OBJ_ query functions to fail in mysterious
ways if called concurrently with them.

There is no problem calling multiple query functions concurrently.

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