openssl.git
2 years agoFix the build file templates where uplink matters
Richard Levitte [Fri, 10 Sep 2021 04:42:24 +0000 (06:42 +0200)]
Fix the build file templates where uplink matters

We changed the manner in which a build needing applink is detected,
but forgot to change the installation targets accordingly.

Fixes #16570

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

2 years agolinux-x86-clang target: Add -latomic
Tomas Mraz [Fri, 10 Sep 2021 08:45:01 +0000 (10:45 +0200)]
linux-x86-clang target: Add -latomic

Fixes #16572

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

(cherry picked from commit 7ea01f521d08d6585a62c7cfd9358c0f191bd903)

2 years agoFix nc_email to check ASN1 strings with NULL byte in the middle
Nikita Ivanov [Tue, 7 Sep 2021 08:31:17 +0000 (11:31 +0300)]
Fix nc_email to check ASN1 strings with NULL byte in the middle

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

(cherry picked from commit 485d0790ac1a29a0d4e7391d804810d485890376)

2 years agoinstall_fips: Create the OPENSSLDIR as it might not exist
Tomas Mraz [Thu, 9 Sep 2021 07:19:58 +0000 (09:19 +0200)]
install_fips: Create the OPENSSLDIR as it might not exist

Fixes #16564

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

(cherry picked from commit 85efdaab4d068f7de354b0a18f70f1737941dc7f)

2 years agoFix 'openssl speed' information printout
Richard Levitte [Wed, 8 Sep 2021 19:58:19 +0000 (21:58 +0200)]
Fix 'openssl speed' information printout

Most of all, this reduces the following:

    built on: built on: Wed Sep  8 19:41:55 2021 UTC

to:

    built on: Wed Sep  8 19:41:55 2021 UTC

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

2 years agodh_ameth: Fix dh_cmp_parameters to really compare the params
Tomas Mraz [Thu, 9 Sep 2021 07:12:22 +0000 (09:12 +0200)]
dh_ameth: Fix dh_cmp_parameters to really compare the params

This is legacy DH PKEY only code.

Fixes #16562

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

(cherry picked from commit cf1a231d44db81f8565ecae5498a4f1f6f0168c9)

2 years agoVMS: Fix descrip.mms template
Richard Levitte [Wed, 8 Sep 2021 18:16:37 +0000 (20:16 +0200)]
VMS: Fix descrip.mms template

away the use of $(DEFINES), which does get populated with defines
given through configuration.  This makes it impossible to configure
with extra defines on VMS.  Uncommenting and moving $(DEFINES) to a
more proper spot gives the users back that ability.

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

2 years agoFixed state transitions for the HTML version of the life_cycle-kdf.pod.
astraujums [Wed, 8 Sep 2021 12:55:39 +0000 (15:55 +0300)]
Fixed state transitions for the HTML version of the life_cycle-kdf.pod.
The MAN version was fine and so are kdf.dot and lifecycles.ods from doc/life-cycles

CLA: trivial

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

(cherry picked from commit e82fc27bcd34f246e1acd42a61e8ba62907e1d19)

2 years agoOpenSSL::Ordinals::set_version() should only be given the short version
Richard Levitte [Wed, 8 Sep 2021 07:40:37 +0000 (09:40 +0200)]
OpenSSL::Ordinals::set_version() should only be given the short version

This function tried to shave off the pre-release and build metadata
text from the the version number it gets, but didn't do that quite
right.  Since this isn't even a documented behaviour, the easier, and
arguably more correct path is for that function not to try to shave
off anything, and for the callers to feed it the short version number,
"{MAJOR}.{MINOR}.{PATCH}", nothing more.

The build file templates are adjusted accordingly.

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

(cherry picked from commit 435981cbadad2c58c35bacd30ca5d8b4c9bea72f)

2 years agoRemove end of line whitespace to appease CI checks
Pauli [Thu, 9 Sep 2021 04:39:37 +0000 (14:39 +1000)]
Remove end of line whitespace to appease CI checks

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

2 years agoFix some documentation errors
PW Hu [Wed, 8 Sep 2021 01:13:20 +0000 (09:13 +0800)]
Fix some documentation errors

CLA: trivial

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

(cherry picked from commit 5ecf10a0d2fb1c858b25afd5e48eafe6ef76edd4)

2 years agoFix the example SSH KDF code.
Pauli [Tue, 7 Sep 2021 23:28:57 +0000 (09:28 +1000)]
Fix the example SSH KDF code.

A salt was being set instead of a session ID.

Fixes #16525

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

(cherry picked from commit 81280137a1f33685d7d7fc531ea8fbac38e9a4b7)

2 years agoFix test/recipes/90-test_fipsload.t to use bldtop_file for the FIPS module
Richard Levitte [Tue, 7 Sep 2021 10:48:52 +0000 (12:48 +0200)]
Fix test/recipes/90-test_fipsload.t to use bldtop_file for the FIPS module

It used bldtop_dir(), which is incorrect for files.

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

(cherry picked from commit c6ee5d5b42e27b407dfc1fc8845e08c5a75e2221)

2 years agoDOCS: Update the page for 'openssl passwd' to not duplicate some info
Richard Levitte [Tue, 7 Sep 2021 09:48:07 +0000 (11:48 +0200)]
DOCS: Update the page for 'openssl passwd' to not duplicate some info

The options -1 and -apr1 were mentioned in DESCRIPTION, not mentioning
any other options or even mentioning that there are more algorithms.
The simple fix is to remove that sentence and let the OPTIONS section
speak for itself.

Fixes #16529

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

(cherry picked from commit 116799ff6a8fc803ec4685fc432c7329d0511e23)

2 years agoPrepare for 3.0.1
Richard Levitte [Tue, 7 Sep 2021 11:47:29 +0000 (13:47 +0200)]
Prepare for 3.0.1

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2 years agoPrepare for release of 3.0.0 openssl-3.0.0
Richard Levitte [Tue, 7 Sep 2021 11:46:32 +0000 (13:46 +0200)]
Prepare for release of 3.0.0

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2 years agomake update
Richard Levitte [Tue, 7 Sep 2021 11:46:24 +0000 (13:46 +0200)]
make update

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2 years agodev/release.sh: Adjust release branch names to votes
Richard Levitte [Tue, 31 Aug 2021 10:07:33 +0000 (12:07 +0200)]
dev/release.sh: Adjust release branch names to votes

The OTC voted today that the release branch for OpenSSL 3.0 should be
openssl-3.0 rather than openssl-3.0.x.  The release script is changed
accordingly.

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

(cherry picked from commit 8e706c8ae5d6abf69b1b0aa0c4ab3517607522d0)

2 years agoUpdate copyright year
Richard Levitte [Tue, 7 Sep 2021 11:29:33 +0000 (13:29 +0200)]
Update copyright year

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

2 years agoLast minute NEWS and CHANGES entries for the 3.0 release
Tomas Mraz [Tue, 7 Sep 2021 11:18:22 +0000 (13:18 +0200)]
Last minute NEWS and CHANGES entries for the 3.0 release

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

(cherry picked from commit 95a444c9adcad04035704ab3b5d749a185ef0960)

2 years agoMention the concept of providers in NEWS.md and CHANGES.md
Richard Levitte [Tue, 7 Sep 2021 09:28:12 +0000 (11:28 +0200)]
Mention the concept of providers in NEWS.md and CHANGES.md

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

2 years agofix documentation error caused by commit 6882652e65d39310c98ba506ceb55a87c702d419
PW Hu [Fri, 3 Sep 2021 07:18:02 +0000 (15:18 +0800)]
fix documentation error caused by commit 6882652e65d39310c98ba506ceb55a87c702d419

CLA:trivial

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

(cherry picked from commit 6d55d27b2da7a84c9f4b872060be979b5f64af2c)

2 years ago fix documentation error caused by commit 9067cf6ccdce0a73922f06937e54c2fce2752038
PW Hu [Fri, 3 Sep 2021 07:09:54 +0000 (15:09 +0800)]
 fix documentation error caused by commit 9067cf6ccdce0a73922f06937e54c2fce2752038

CLA:trivial

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

(cherry picked from commit 48b3ad05680ba3e3668bcb6491bf4447033464ed)

2 years ago imporve documentation
PW Hu [Fri, 3 Sep 2021 06:40:17 +0000 (14:40 +0800)]
 imporve documentation

CLA:trivial

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

(cherry picked from commit b9f96f30eea550650a8d9f8000cea940c6ee8150)

2 years agoAdded a NEWS entry about the enhanced 'openssl list'
Richard Levitte [Tue, 7 Sep 2021 07:44:58 +0000 (09:44 +0200)]
Added a NEWS entry about the enhanced 'openssl list'

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

2 years agoAdd missing OSSL_DECODER entry in NEWS.md and CHANGES.md
Richard Levitte [Tue, 7 Sep 2021 07:33:16 +0000 (09:33 +0200)]
Add missing OSSL_DECODER entry in NEWS.md and CHANGES.md

The text in CHANGES.md got fleshed out a bit more as well.

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

2 years agoCorrect the "Out of memory" EVP tests
Richard Levitte [Tue, 7 Sep 2021 05:27:01 +0000 (07:27 +0200)]
Correct the "Out of memory" EVP tests

This affects test/recipes/30-test_evp_data/evpkdf_scrypt.txt and
test/recipes/30-test_evp_data/evppkey_kdf_scrypt.txt, where the "Out
of memory" stanza weren't up to the task, as they didn't hit the
default scrypt memory limit like they did in OpenSSL 1.1.1.

We solve this by setting the |n| value to the next power of two, and
correcting the expected result.

Fixes #16519

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

2 years agoFix a few tests that fail on VMS
Richard Levitte [Mon, 6 Sep 2021 19:49:34 +0000 (21:49 +0200)]
Fix a few tests that fail on VMS

In one spot, files aren't properly closed, so the sub-process program
that's supposed to read them can't, because it's locked out.

In another spot, srctop_file() was used where srctop_dir() should be
used to properly format a directory specification.

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

2 years agoConfiguration: support building for OpenVMS for x86_64
Richard Levitte [Mon, 26 Jul 2021 10:40:01 +0000 (12:40 +0200)]
Configuration: support building for OpenVMS for x86_64

OpenVMS for x86_64 is currently out on a field test.  Building
programs for it is currently done with cross compilation on Itanium.
The cross compilation tools are made available by running a script,
which makes cross-compilation variants of most commands available, and
adds the cross-compilation C compiler XCC.

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

(cherry picked from commit 6929c8fb5b46c9c2a383a7c212ee052e0dcef021)

2 years agotest/recipes/25-test_verify.t: Add a couple of tests of mixed PEM files
Richard Levitte [Fri, 3 Sep 2021 13:00:47 +0000 (15:00 +0200)]
test/recipes/25-test_verify.t: Add a couple of tests of mixed PEM files

Fixes #16224

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

(cherry picked from commit d4458e59f62b0d102069e53da41f1d5305a66912)

2 years agoENCODER PROV: Add encoders with EncryptedPrivateKeyInfo output
Richard Levitte [Wed, 1 Sep 2021 20:18:45 +0000 (22:18 +0200)]
ENCODER PROV: Add encoders with EncryptedPrivateKeyInfo output

Since EncryptedPrivateKeyInfo is a recognised structure, it's
reasonable to think that someone might want to specify it.

To be noted is that if someone specifies the structure PrivateKeyInfo
but has also passed a passphrase callback, the result will still
become a EncryptedPrivateKeyInfo structure.

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

(cherry picked from commit 0195cdd28fde7d0897e368fdcd4e92509425faad)

2 years agoAdjust test/endecoder_test.c
Richard Levitte [Wed, 1 Sep 2021 15:34:38 +0000 (17:34 +0200)]
Adjust test/endecoder_test.c

The protected tests need to specify the structure EncryptedPrivateKeyInfo
rather than PrivateKeyInfo, since that's the outermost structure.

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

(cherry picked from commit 602bfb8b98125f6745cd40dbc5fce9614ae5e418)

2 years agoOSSL_STORE 'file:' scheme: Set input structure for certificates and CRLs
Richard Levitte [Mon, 30 Aug 2021 11:22:18 +0000 (13:22 +0200)]
OSSL_STORE 'file:' scheme: Set input structure for certificates and CRLs

When the user expects to load a certificate or a CRL through the
OSSL_STORE loading function, the 'file:' implementation sets the
corresponding structure names in the internal decoder context.
This is especially geared for PEM files, which often contain a mix of
objects, and password prompting should be avoided for objects that
need them, but aren't what the caller is looking for.

Fixes #16224

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

(cherry picked from commit 821b3956ec698927281a5b29c55cd87eb7b2793d)

2 years agoPEM to DER decoder: Specify object type and data structure more consistently
Richard Levitte [Mon, 30 Aug 2021 11:19:30 +0000 (13:19 +0200)]
PEM to DER decoder: Specify object type and data structure more consistently

The data structure wasn't given for recognised certificates or CRLs.
It's better, though, to specify it for those objects as well, so they
can be used to filter what actually gets decoded, which will be
helpful for our OSSL_STORE 'file:' scheme implementation.

Fixes #16224

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

(cherry picked from commit 98408852c167d895a662dcda824fd5170cad3f7d)

2 years agoDECODER: check the first decoded structure name against user given structure
Richard Levitte [Mon, 30 Aug 2021 11:16:42 +0000 (13:16 +0200)]
DECODER: check the first decoded structure name against user given structure

In a chain of decoders, the first that specifies an input structure
gets it compared with the structure specified by the user, if there is
one.  If they aren't the same, that decoder is skipped.

Because the first structure can appear anywhere along a chain of
decoders, not just the decoders associated with the resulting OpenSSL
type, the code that checked the structure name when building up the
chain of decoders is removed.

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

(cherry picked from commit 73dd5d67c506cfeb9bf6183f0c19832c7d3f174d)

2 years agoAdd KEM dupctx test
slontis [Thu, 2 Sep 2021 06:50:45 +0000 (16:50 +1000)]
Add KEM dupctx test

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

(cherry picked from commit d7b5f06ede163851d39f5a8b507bd0670deeaa21)

2 years agoFix dh dupctx refcount error
slontis [Thu, 2 Sep 2021 06:49:37 +0000 (16:49 +1000)]
Fix dh dupctx refcount error

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

(cherry picked from commit 21a0d9f3edda78d27d12cd7704de9e32976393ba)

2 years agoFix double free in EVP_PKEY_CTX_dup()
slontis [Thu, 2 Sep 2021 06:39:21 +0000 (16:39 +1000)]
Fix double free in EVP_PKEY_CTX_dup()

If the internal operations dupctx() fails then a free is done (e.g. EVP_KEYEXCH_free()). If this is not set to NULL the EVP_PKEY_CTX_free() will do a double free.
This was found by testing kdf_dupctx() in kdf_exch.c (Note this always
fails since the internal KDF's do not have a dup method).

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

(cherry picked from commit 85407b77543a2d4330dbb40f6b8520ea0894a716)

2 years agoEVP_PKEY_gettable_params.pod: Update argument names
PW Hu [Thu, 2 Sep 2021 04:02:06 +0000 (12:02 +0800)]
EVP_PKEY_gettable_params.pod: Update argument names

CLA: trivial

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

(cherry picked from commit 6f2f59944826b5b7e033af438f5831493d0362c9)

2 years agoVMS: Compensate for x86_64 cross compiler type incompatibility
Richard Levitte [Thu, 2 Sep 2021 11:10:33 +0000 (13:10 +0200)]
VMS: Compensate for x86_64 cross compiler type incompatibility

The x86_64 cross compiler says that 'unsigned long long' isn't the
same as 'unsigned __int64'.  Sure, and considering that
providers/implementations/rands/seeding/rand_vms.c is specific VMS
only code, it's easy to just change the type to the exact same as
what's specified in the system headers.

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

2 years agoFix indentation of tls13_hkdf_expand parameters
Daniel Bevenius [Wed, 1 Sep 2021 09:45:45 +0000 (11:45 +0200)]
Fix indentation of tls13_hkdf_expand parameters

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

(cherry picked from commit 1b9e467887d7852d79270c73cb88383c50460b0a)

2 years agoCI: add last run-checker fuzzing CIs to Actions
Pauli [Fri, 27 Aug 2021 00:37:35 +0000 (10:37 +1000)]
CI: add last run-checker fuzzing CIs to Actions

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

(cherry picked from commit f92bfddc1d4c4957c57337d7f4192c586cc09a5c)

2 years agoalways use the same perl in $PATH
a1346054 [Thu, 19 Aug 2021 11:05:15 +0000 (11:05 +0000)]
always use the same perl in $PATH

Different tests may use unexpectedly different versions of perl,
depending on whether they hardcode the path to the perl executable or if
they resolve the path from the environment. This fixes it so that the
same perl is always used.

Fix some trailing whitespace and spelling mistakes as well.

CLA: trivial

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

(cherry picked from commit 473664aafdff1f60db99929bdd43c2a9b26d14cd)

2 years agoOpenssl fails to compile on Debian with kfreebsd kernels
Mattias Ellert [Tue, 31 Aug 2021 06:26:06 +0000 (08:26 +0200)]
Openssl fails to compile on Debian with kfreebsd kernels
(kfreebsd-amd64, kfreebsd-i386). The error reported by the compiler
is:

../crypto/uid.c: In function 'OPENSSL_issetugid':
../crypto/uid.c:50:22: error: 'AT_SECURE' undeclared (first use in this function)
   50 |     return getauxval(AT_SECURE) != 0;
      |                      ^~~~~~~~~

This commit changes the code to use the freebsd code in this case.
This fixes the compilation.

CLA: trivial

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

(cherry picked from commit 3a1fa0116a92235ba200228e4bb60d6a3a7f4113)

2 years agoAdd a test for verifying an email with a bad othername type
Matt Caswell [Thu, 26 Aug 2021 09:03:51 +0000 (10:03 +0100)]
Add a test for verifying an email with a bad othername type

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

2 years agoEnsure that we check the ASN.1 type of an "otherName" before using it
Matt Caswell [Thu, 26 Aug 2021 08:43:50 +0000 (09:43 +0100)]
Ensure that we check the ASN.1 type of an "otherName" before using it

We should not assume that the type of an ASN.1 value is UTF8String as
expected. We must actually check it, otherwise we could get a NULL ptr
deref, or worse memory errors.

Reported by David Benjamin.

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

2 years agoAdd the self test type OSSL_SELF_TEST_TYPE_PCT_SIGNATURE
slontis [Sun, 29 Aug 2021 23:59:54 +0000 (09:59 +1000)]
Add the self test type OSSL_SELF_TEST_TYPE_PCT_SIGNATURE

Fixes #16457

The ECDSA and DSA signature tests use Pairwise tests instead of KATS.
Note there is a seperate type used by the keygen for conditional Pairwise Tests.

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

2 years agoAdd a warning about locking in the child provider callback docs
Matt Caswell [Mon, 30 Aug 2021 14:54:22 +0000 (15:54 +0100)]
Add a warning about locking in the child provider callback docs

The child provider callbacks can hold the store lock. In order to avoid
deadlocks we require that the callback implementations don't themselves
call functions that may aquire those locks.

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

2 years agoAdd additional test to thread sanitizer build
Pauli [Mon, 16 Aug 2021 02:20:56 +0000 (12:20 +1000)]
Add additional test to thread sanitizer build

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

2 years agoRefactor provider_core.c to adhere to the locking rules
Matt Caswell [Mon, 30 Aug 2021 12:04:31 +0000 (13:04 +0100)]
Refactor provider_core.c to adhere to the locking rules

The previous commit provided some guidelines and some rules for using
locking in order to avoid deadlocks. This commit refactors the code in
order to adhere to those guidelines and rules.

Fixes #16312

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

2 years agoAdd commentary about lock usage in provider_core.c
Matt Caswell [Mon, 30 Aug 2021 14:33:07 +0000 (15:33 +0100)]
Add commentary about lock usage in provider_core.c

Provide some guidelines, as well as some rules for using the locks in
provider_core.c, in order to avoid the introduction of deadlocks.

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

2 years agoCI: add builds covering a number of different compiler versions
Pauli [Mon, 30 Aug 2021 06:06:49 +0000 (16:06 +1000)]
CI: add builds covering a number of different compiler versions

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

2 years agoapps/pkcs12: Do not assume null termination of ASN1_UTF8STRING
Tomas Mraz [Tue, 31 Aug 2021 07:05:59 +0000 (09:05 +0200)]
apps/pkcs12: Do not assume null termination of ASN1_UTF8STRING

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/16433)

2 years agoci: Add -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to asan build
Tomas Mraz [Thu, 26 Aug 2021 13:13:58 +0000 (15:13 +0200)]
ci: Add -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to asan build

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/16433)

2 years agoMake the -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION pass tests
Tomas Mraz [Thu, 26 Aug 2021 13:08:15 +0000 (15:08 +0200)]
Make the -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION pass tests

Fixes #16428

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/16433)

2 years agoDocument that EVP_get_cipherbyname() does not work for some new algorithm names.
slontis [Wed, 25 Aug 2021 01:50:20 +0000 (11:50 +1000)]
Document that EVP_get_cipherbyname() does not work for some new algorithm names.

These algorithms were added to providers but have no const EVP_CIPHER*
mapping. Ciphers for SIV and CTS were previously only available via low level
function calls that are deprecated.

Reported by @reaperhulk.

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

2 years agoTypo correction.
Jaime Hablutzel [Mon, 30 Aug 2021 18:18:48 +0000 (13:18 -0500)]
Typo correction.

CLA: trivial

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

2 years agoUse applink to fix windows tests
Nicola Tuveri [Sat, 21 Aug 2021 01:04:51 +0000 (04:04 +0300)]
Use applink to fix windows tests

(readapted from 5c69c66a6972f84d56160c9ea4b30bab8fc2d3d4 by @bernd-edlinger)

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

2 years ago[ec] Do not default to OPENSSL_EC_NAMED_CURVE for curves without OID
Nicola Tuveri [Thu, 16 Jul 2020 00:23:26 +0000 (03:23 +0300)]
[ec] Do not default to OPENSSL_EC_NAMED_CURVE for curves without OID

Some curves don't have an associated OID: for those we should not
default to `OPENSSL_EC_NAMED_CURVE` encoding of parameters and instead
set the ASN1 flag to `OPENSSL_EC_EXPLICIT_CURVE`.

This is a follow-up to https://github.com/openssl/openssl/pull/12312

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

2 years agoFix d2i_ECPKParameters_fp and i2d_ECPKParameters_fp macros
Nicola Tuveri [Wed, 15 Jul 2020 23:02:16 +0000 (02:02 +0300)]
Fix d2i_ECPKParameters_fp and i2d_ECPKParameters_fp macros

These functions are part of the public API but we don't have tests
covering their usage.
They are actually implemented as macros and the absence of tests has
caused them to fall out-of-sync with the latest changes to ASN1 related
functions and cause compilation warnings.

This commit fixes the public headers to reflect these changes.

Fixes #12443

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

2 years agoAdd tests for i2d_TYPE_fp and d2i_TYPE_fp
Nicola Tuveri [Wed, 15 Jul 2020 22:57:09 +0000 (01:57 +0300)]
Add tests for i2d_TYPE_fp and d2i_TYPE_fp

These functions are part of the public API but we don't have tests
covering their usage.
They are actually implemented as macros and the absence of tests has
caused them to fall out-of-sync with the latest changes to ASN1 related
functions and cause compilation warnings.

@@ Note: This commit limits to ECPKParameters as a type.

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

2 years agoEnsure that _GNU_SOURCE is defined for bss_dgram.c
Daniel Krügler [Fri, 27 Aug 2021 16:32:20 +0000 (18:32 +0200)]
Ensure that _GNU_SOURCE is defined for bss_dgram.c

This fixes the following error with gcc10 under strict ANSI conditions:

.../crypto/bio/bss_dgram.c:373:20: error: 'const struct in6_addr' has no member named 's6_addr32'

CLA: trivial
Fixes #16449

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/16451)

2 years agoAdjust the list of default provider's algorithms
Dmitry Belyavskiy [Fri, 27 Aug 2021 16:03:15 +0000 (18:03 +0200)]
Adjust the list of default provider's algorithms

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

2 years agoFix the "Out of memory" EVP KDF scrypt test
Bernd Edlinger [Fri, 27 Aug 2021 11:11:39 +0000 (13:11 +0200)]
Fix the "Out of memory" EVP KDF scrypt test

This test did not really execute, since usually
the OPENSSL_malloc(0) will fail and prevent the
execution of the KDF.

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

2 years agoYet another doc-nits fix
Rich Salz [Thu, 26 Aug 2021 20:03:15 +0000 (16:03 -0400)]
Yet another doc-nits fix

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

2 years agocms: fix memleaks in cms_env.c
zhaozg [Tue, 24 Aug 2021 14:43:18 +0000 (22:43 +0800)]
cms: fix memleaks in cms_env.c

CLA: trivial

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

(cherry picked from commit 58e1e397c6774be11b903c0f88e85bd2b8c4206f)

2 years agoFix libdir path on darwin
Xiaofei Bai [Wed, 18 Aug 2021 07:57:26 +0000 (07:57 +0000)]
Fix libdir path on darwin

In current Configure script, libdir can be specified either an absolute
path or relative, while in Configurations/shared-info.pl, on darwin
system "-install_name" only accepts relative libdir path, and the
program fails when receiving absolute libdir path. This PR is to fix
this and match requirements of scripts.

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

2 years agoDarwin platform allows to build on releases before Yosemite/ios 8.
David Carlier [Wed, 25 Aug 2021 07:54:38 +0000 (08:54 +0100)]
Darwin platform allows to build on releases before Yosemite/ios 8.

backport #16409

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

2 years agodoc: Add note about operation parameters validation
Tomas Mraz [Wed, 25 Aug 2021 15:06:47 +0000 (17:06 +0200)]
doc: Add note about operation parameters validation

Fixes #16394

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

2 years agoAdd a test for running the config twice
Matt Caswell [Wed, 25 Aug 2021 13:39:29 +0000 (14:39 +0100)]
Add a test for running the config twice

Make sure there are no leaks from running the config file twice.

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

2 years agoAdd locking for the provider_conf.c
Matt Caswell [Tue, 24 Aug 2021 16:41:39 +0000 (17:41 +0100)]
Add locking for the provider_conf.c

Avoid races where 2 threads attempt to configure activation of providers
at the same time. E.g. via an explicit and an implict load of the config
file at the same time.

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

2 years agoWhen activating providers via config check we've not already activated them
Matt Caswell [Tue, 17 Aug 2021 09:32:49 +0000 (10:32 +0100)]
When activating providers via config check we've not already activated them

We skip the activation if we already configured them.

Fixes #16250

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

2 years agoAPPS/req: Fix AKID generation in case -CA option is used
Dr. David von Oheimb [Wed, 25 Aug 2021 10:21:06 +0000 (12:21 +0200)]
APPS/req: Fix AKID generation in case -CA option is used

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

2 years agoAPPS/req: Fix misconceptions on -CA, -CAkey, and -key options. -CA now implies -x509
Dr. David von Oheimb [Wed, 25 Aug 2021 10:11:38 +0000 (12:11 +0200)]
APPS/req: Fix misconceptions on -CA, -CAkey, and -key options. -CA now implies -x509

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

2 years agoAPPS/x509: fix -extfile option, which was ignored with -x509toreq
Dr. David von Oheimb [Wed, 25 Aug 2021 06:35:40 +0000 (08:35 +0200)]
APPS/x509: fix -extfile option, which was ignored with -x509toreq

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

2 years agoEVP_DigestSign/VerifyFinal: Duplicate the pctx to allow multiple calls
Tomas Mraz [Wed, 25 Aug 2021 11:50:40 +0000 (13:50 +0200)]
EVP_DigestSign/VerifyFinal: Duplicate the pctx to allow multiple calls

The legacy implementation duplicates the pctx before creating/verifying
the signature unless EVP_MD_CTX_FLAG_FINALISE is set. We have to do the
same with provided implementations.

Fixes #16321

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

2 years agots: fix memleaks caused by TS_VERIFY_CTX_set_imprint
zhaozg [Wed, 18 Aug 2021 07:40:22 +0000 (15:40 +0800)]
ts: fix memleaks caused by TS_VERIFY_CTX_set_imprint

CLA: trivial

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

2 years agodoc: document the rsa_oaep_md: pkeyopt
Pauli [Wed, 25 Aug 2021 00:06:11 +0000 (10:06 +1000)]
doc: document the rsa_oaep_md: pkeyopt

This was missing but essential for using non-SHA1 digests with OAEP.

Fixes #15998

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

2 years agoaes-wrap: improve error handling
Pauli [Mon, 23 Aug 2021 23:40:52 +0000 (09:40 +1000)]
aes-wrap: improve error handling

The AES wrap cipher was return -1 on error from the provider rather than 0.
This is fixed.

There was a problem with the error handling in AES wrap which fell back to a
default "final error".  This adds a fix for the error and more specific errors
for the different failure possibilities.

Fixes #16387

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

2 years agoAdd invalid input length error
Pauli [Mon, 23 Aug 2021 23:40:28 +0000 (09:40 +1000)]
Add invalid input length error

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

2 years agoCMS app: Fix new -wrap option
Dr. David von Oheimb [Tue, 24 Aug 2021 10:15:41 +0000 (12:15 +0200)]
CMS app: Fix new -wrap option

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

2 years agochanges: add note about 3DES key wrap matching the standard
Pauli [Tue, 24 Aug 2021 09:07:18 +0000 (19:07 +1000)]
changes: add note about 3DES key wrap matching the standard

Also note that it is no longer interoperable with 1.1.1.

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

2 years agotest: add unit tests for TDES key wrap
Pauli [Wed, 18 Aug 2021 01:58:11 +0000 (11:58 +1000)]
test: add unit tests for TDES key wrap

This functionality was completely untested.

Doesn't fix #16002 since that's a bug against 1.1.1.

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

2 years agoAvoid using undefined value in generate_stateless_cookie_callback
Bernd Edlinger [Mon, 23 Aug 2021 09:11:29 +0000 (11:11 +0200)]
Avoid using undefined value in generate_stateless_cookie_callback

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

2 years agoAvoid invoking memcpy if size is zero or the supplied buffer is NULL
Paul Dreik [Fri, 29 Nov 2019 18:23:35 +0000 (19:23 +0100)]
Avoid invoking memcpy if size is zero or the supplied buffer is NULL

This allows for passing a NULL pointer with zero max_len.

Invoking memcpy on NULL is undefined behaviour, even if the size is zero.

https://en.cppreference.com/w/c/string/byte/memcpy

The function can now be queried for the necessary buffer length.

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

2 years agoFix the array size of dtlsseq in tls1_enc
Bernd Edlinger [Mon, 23 Aug 2021 12:03:20 +0000 (14:03 +0200)]
Fix the array size of dtlsseq in tls1_enc

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

2 years agoAdd multilib to the NonStop configuration definitions.
Richard Levitte [Tue, 24 Aug 2021 11:45:27 +0000 (13:45 +0200)]
Add multilib to the NonStop configuration definitions.

Fixes: #16373
Co-authored-by: Randall S. Becker <rsbecker@nexbridge.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16398)

2 years agoVMS: Correct faulty source directory specification
Richard Levitte [Mon, 23 Aug 2021 12:12:28 +0000 (14:12 +0200)]
VMS: Correct faulty source directory specification

$(SRCDIR)/doc doesn't work right on VMS.

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

2 years agoapps/ciphers: Fix wrong return value when using -convert parameter
Tianjia Zhang [Mon, 23 Aug 2021 09:40:22 +0000 (17:40 +0800)]
apps/ciphers: Fix wrong return value when using -convert parameter

Command 'openssl ciphers -convert <name>' always returns failure,
this patch set the correct return value.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16383)

2 years agoAPPS: Fix result type of dump_cert_text() and behavior of print_name() on out==NULL
Dr. David von Oheimb [Tue, 17 Aug 2021 17:57:08 +0000 (19:57 +0200)]
APPS: Fix result type of dump_cert_text() and behavior of print_name() on out==NULL

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

2 years agonews/changes: fix formatting nits
Pauli [Wed, 25 Aug 2021 00:44:01 +0000 (10:44 +1000)]
news/changes: fix formatting nits

The news/changes files are being nitted causing CI failure.  This addresses the
issues.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16413)

2 years agocpp: fix included files to avoid failure in no-deprecated builds
Pauli [Wed, 25 Aug 2021 00:32:12 +0000 (10:32 +1000)]
cpp: fix included files to avoid failure in no-deprecated builds

A header file was missing but only in no-deprecated builds.
Also add some ending comments for #if preprocessor statements.
Move function declaration inside #ifdef guard for header.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16412)

2 years agosm2: fix error raise to not fail make update
Pauli [Wed, 25 Aug 2021 00:12:17 +0000 (10:12 +1000)]
sm2: fix error raise to not fail make update

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16411)

2 years agorsa: Try legacy encoding functions for pubkey
Tomas Mraz [Wed, 11 Aug 2021 11:09:09 +0000 (13:09 +0200)]
rsa: Try legacy encoding functions for pubkey

If there are no suitable encoders it might mean the key is in
an engine and thus it is a legacy key. Try legacy encoding
routines to encode the public key. We do not attempt encoding
a private key as it would be in most cases impossible anyway.

Fixes #16256

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

2 years agoUpdates CHANGES.md and NEWS.md for new 1.1.1 release
Matt Caswell [Tue, 24 Aug 2021 12:37:49 +0000 (13:37 +0100)]
Updates CHANGES.md and NEWS.md for new 1.1.1 release

Reviewed-by: Richard Levitte <levitte@openssl.org>
2 years agoCheck the plaintext buffer is large enough when decrypting SM2
Matt Caswell [Fri, 13 Aug 2021 15:58:21 +0000 (16:58 +0100)]
Check the plaintext buffer is large enough when decrypting SM2

Previously there was no check that the supplied buffer was large enough.
It was just assumed to be sufficient. Instead we should check and fail if
not.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
2 years agoExtend tests for SM2 decryption
Matt Caswell [Fri, 13 Aug 2021 13:49:47 +0000 (14:49 +0100)]
Extend tests for SM2 decryption

Check the case where C1y < 32 bytes in length (i.e. short overhead), and
also the case with longer plaintext and C1x and C1y > 32 bytes in length
(i.e. long overhead)

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
2 years agoCorrectly calculate the length of SM2 plaintext given the ciphertext
Matt Caswell [Fri, 13 Aug 2021 13:14:51 +0000 (14:14 +0100)]
Correctly calculate the length of SM2 plaintext given the ciphertext

Previously the length of the SM2 plaintext could be incorrectly calculated.
The plaintext length was calculated by taking the ciphertext length and
taking off an "overhead" value.

The overhead value was assumed to have a "fixed" element of 10 bytes.
This is incorrect since in some circumstances it can be more than 10 bytes.
Additionally the overhead included the length of two integers C1x and C1y,
which were assumed to be the same length as the field size (32 bytes for
the SM2 curve). However in some cases these integers can have an additional
padding byte when the msb is set, to disambiguate them from negative
integers. Additionally the integers can also be less than 32 bytes in
length in some cases.

If the calculated overhead is incorrect and larger than the actual value
this can result in the calculated plaintext length being too small.
Applications are likely to allocate buffer sizes based on this and therefore
a buffer overrun can occur.

CVE-2021-3711

Issue reported by John Ouyang.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
2 years agoFix the error handling in i2v_AUTHORITY_KEYID
Matt Caswell [Fri, 20 Aug 2021 14:23:32 +0000 (15:23 +0100)]
Fix the error handling in i2v_AUTHORITY_KEYID

Previously if an error path is entered a leak could result.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David Benjamin <davidben@google.com>
2 years agoAllow fuzz builds to detect string overruns
Matt Caswell [Thu, 19 Aug 2021 14:25:04 +0000 (15:25 +0100)]
Allow fuzz builds to detect string overruns

If FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is defined then we don't NUL
terminate ASN1_STRING datatypes. This shouldn't be necessary but we add it
any for safety in normal builds.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David Benjamin <davidben@google.com>