oweals/openssl.git
4 years agoAdd S390 support for provider based X25519/X448
Matt Caswell [Tue, 4 Feb 2020 16:41:19 +0000 (16:41 +0000)]
Add S390 support for provider based X25519/X448

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoAdd X25519/X448 Key Exchange to the default provider
Matt Caswell [Fri, 24 Jan 2020 17:13:40 +0000 (17:13 +0000)]
Add X25519/X448 Key Exchange to the default provider

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoImplement Provider side Key Management for X25519 and X448
Matt Caswell [Mon, 27 Jan 2020 16:57:03 +0000 (16:57 +0000)]
Implement Provider side Key Management for X25519 and X448

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoImplement a stricter ECX_KEY type
Matt Caswell [Mon, 27 Jan 2020 16:50:47 +0000 (16:50 +0000)]
Implement a stricter ECX_KEY type

Add ref counting and control how we allocate storage for the private key.
We will need this type in following commits where we move the ecx code
to be provider aware.

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoCheck that ed25519 and ed448 are allowed by the security level
Kurt Roeckx [Sun, 9 Feb 2020 18:28:15 +0000 (19:28 +0100)]
Check that ed25519 and ed448 are allowed by the security level

Signature algorithms not using an MD weren't checked that they're
allowed by the security level.

Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #10785

4 years agoGenerate new Ed488 certificates
Kurt Roeckx [Thu, 2 Jan 2020 22:16:30 +0000 (23:16 +0100)]
Generate new Ed488 certificates

Create a whole chain of Ed488 certificates so that we can use it at security
level 4 (192 bit). We had an 2048 bit RSA (112 bit, level 2) root sign the
Ed488 certificate using SHA256 (128 bit, level 3).

Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #10785

4 years agoAdd a minimal build target for Travis and Appveyor
Bernd Edlinger [Fri, 13 Sep 2019 07:24:53 +0000 (09:24 +0200)]
Add a minimal build target for Travis and Appveyor

[extended tests]

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

4 years agoX509_PUBKEY_set(): Fix memory leak
Richard Levitte [Fri, 7 Feb 2020 08:13:21 +0000 (09:13 +0100)]
X509_PUBKEY_set(): Fix memory leak

With the provided method of creating the new X509_PUBKEY, an extra
EVP_PKEY is created and needs to be properly cleaned away.

(note: we could choose to keep it just as well, but there are
consequences, explained in a comment in the code)

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/11038)

4 years agoGeneralize the HTTP client so far implemented mostly in crypto/ocsp/ocsp_ht.c
Dr. David von Oheimb [Wed, 30 Oct 2019 22:39:35 +0000 (23:39 +0100)]
Generalize the HTTP client so far implemented mostly in crypto/ocsp/ocsp_ht.c
The new client has become an independent libcrpyto module in crypto/http/ and
* can handle any types of requests and responses (ASN.1-encoded and plain)
* does not include potentially busy loops when waiting for responses but
* makes use of a new timeout mechanism integrated with socket-based BIO
* supports the use of HTTP proxies and TLS, including HTTPS over proxies
* supports HTTP redirection via codes 301 and 302 for GET requests
* returns more useful diagnostics in various error situations
Also adapts - and strongly simplifies - hitherto uses of HTTP in crypto/ocsp/,
crypto/x509/x_all.c, apps/lib/apps.c, and apps/{ocsp,s_client,s_server}.c

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/10667)

4 years agoadd BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() improving timeout support
Dr. David von Oheimb [Tue, 4 Feb 2020 08:55:35 +0000 (09:55 +0100)]
add BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() improving timeout support

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/10667)

4 years agoPROV: Ensure the AlgorithmIdentifier registers in DSA signature impl
Richard Levitte [Fri, 7 Feb 2020 08:09:50 +0000 (09:09 +0100)]
PROV: Ensure the AlgorithmIdentifier registers in DSA signature impl

When setting up the hash function for DSA signature, the encoded
AlgorithmIdentifier for the DSA+hash combination is queried, but not
stored, which leads to problems when signing ASN.1 items in libcrypto.

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

4 years agoMemory allocator code cleanup
Davide Galassi [Mon, 10 Feb 2020 06:49:10 +0000 (16:49 +1000)]
Memory allocator code cleanup

Typedefs of CRYPTO malloc, realloc and free.

MEM_CHECK "modes" are used only as a CRYPTO_mem_ctrl() parameter

The CRYPTO_mem_ctrl is defined only if OPENSSL_NO_CRYPTO_MDEBUG is
defined, thus define the MEM_CHECK modes under the same condition.

Maybe the macros can be removed at all since:
1. CRYPTO_mem_ctrl() just returns -1 and ignores the parameter
2. CRYPTO_mem_ctr() is declared as DEPRECATED by 3.0

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

4 years agox86: Always generate .note.gnu.property section for ELF outputs
H.J. Lu [Sat, 14 Dec 2019 17:48:18 +0000 (09:48 -0800)]
x86: Always generate .note.gnu.property section for ELF outputs

We should always generate .note.gnu.property section in x86 assembly
codes for ELF outputs to mark Intel CET support since all input files
must be marked with Intel CET support in order for linker to mark output
with Intel CET support.

Verified with

$ CC="gcc -Wl,-z,cet-report=error" ./Configure shared linux-x86 -fcf-protection
$ make
$ make test

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

4 years agoDon't compile AESNI code if we're not AESNI capable
Matt Caswell [Wed, 5 Feb 2020 17:42:40 +0000 (17:42 +0000)]
Don't compile AESNI code if we're not AESNI capable

Compile failures were occuring on systems that weren't AESNI capable
because the detection wasn't quite right in a couple of files.

This fixes a run-checker build failure for the 386 compile option.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11022)

4 years agoFix no-des
Matt Caswell [Thu, 6 Feb 2020 16:59:49 +0000 (16:59 +0000)]
Fix no-des

Don't attempt to self-test DES in the FIPS provider if we have been built
without FIPS support.

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

4 years agoFix no-engine
Matt Caswell [Thu, 6 Feb 2020 15:54:09 +0000 (15:54 +0000)]
Fix no-engine

We don't need to check if an engine has a cipher/digest in a no-engine
build.

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

4 years agoFix no-dh
Matt Caswell [Thu, 6 Feb 2020 15:30:24 +0000 (15:30 +0000)]
Fix no-dh

Don't use DH specific macros that might need to be used in a no-dh build.

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

4 years agoFix no-ec
Matt Caswell [Thu, 6 Feb 2020 15:17:28 +0000 (15:17 +0000)]
Fix no-ec

Recent SM2 related changes were not properly guarded with OPENSSL_NO_EC

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

4 years agoUse swapcontext for Intel CET
H.J. Lu [Sat, 14 Dec 2019 00:46:07 +0000 (16:46 -0800)]
Use swapcontext for Intel CET

When Intel CET is enabled, makecontext will create a different shadow
stack for each context.  async_fibre_swapcontext cannot use _longjmp.
It must call swapcontext to swap shadow stack as well as normal stack.

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

4 years agoAdapt all build.info and test recipes to the new $disabled{'deprecated-x.y'}
Richard Levitte [Thu, 6 Feb 2020 10:31:41 +0000 (11:31 +0100)]
Adapt all build.info and test recipes to the new $disabled{'deprecated-x.y'}

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

4 years agoConfigure: Add easy to use disabled deprecated functionality indicators
Richard Levitte [Thu, 6 Feb 2020 10:26:22 +0000 (11:26 +0100)]
Configure: Add easy to use disabled deprecated functionality indicators

In C, we have macros like OPENSSL_NO_DEPRECATED_3_0 to check if some
section of code should be disabled to simulate a removal of things
deprecated in the version.

In perl, we had to check $disabled{deprecated} and compare
$config{api} with the proper version code, which is doable but tedious
and error prone.

This change adds $disabled{'deprecated-x.y'} (x.y being a version
number) which directly corresponds to OPENSSL_NO_DEPRECATED_x_y, for
use in build.info conditions, test recipes and other perl stuff.

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

4 years agotests/drbgtest: use new RAND_DRBG callback_data API instead of ex_data
Dr. Matthias St. Pierre [Fri, 31 Jan 2020 12:32:11 +0000 (13:32 +0100)]
tests/drbgtest: use new RAND_DRBG callback_data API instead of ex_data

It took me a little while to realize why the test_rand_drbg_reseed test
kept crashing after replacing the RAND_DRBG_{gs}et_ex_data() calls by
RAND_DRBG_{gs}et_callback_data().

The reason was that the ex_data API prohibits modifying the callbacks
or callback data of chained DRBGs and returned an error which was
ignored by the `test_rand_drbg_reseed` test, for good reasons.

The `test_rand_drbg_reseed` test is special in this respect, because
it needs to install callbacks for all DRBGs, in order to intercept
and count the reseeding events.

Since the drbgtest module has access to the internal structures of
the DRBG anyway, the problem could be solved by accessing the members
directly. I added a warning comment in hook_drbg().

[extended tests]

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

4 years agoRAND_DRBG: add a callback data for entropy and nonce callbacks
Dr. Matthias St. Pierre [Sun, 26 Jan 2020 21:18:23 +0000 (22:18 +0100)]
RAND_DRBG: add a callback data for entropy and nonce callbacks

The callback data allows passing context specific data from the
application of the DRBG to to the entropy callbacks.
This a rather specialized feature which is useful for implementing
known answer tests (KATs) or deterministic signatures (RFC6979),
which require passing a specified entropy and nonce for instantiating
the DRBG.

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

4 years agoAppveyor: update to Visual Studio 2017.
FdaSilvaYY [Sat, 19 Oct 2019 16:24:49 +0000 (18:24 +0200)]
Appveyor: update to Visual Studio 2017.

Default image was currently "Visual Studio 2015"

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10327)

4 years agoKEYMGMT: Require both get_params and gettable_params, or none
Richard Levitte [Tue, 4 Feb 2020 16:49:28 +0000 (17:49 +0100)]
KEYMGMT: Require both get_params and gettable_params, or none

The same go for the pairs import + import_types and export + export_types.

This required some additional changes in our KEYMGMT implementations.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoAdapt existing SERIALIZER implementations to the redesigned interface
Richard Levitte [Mon, 3 Feb 2020 15:36:24 +0000 (16:36 +0100)]
Adapt existing SERIALIZER implementations to the redesigned interface

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoAdapt test/keymgmt_internal_test.c to the redesigned interface
Richard Levitte [Mon, 3 Feb 2020 14:36:15 +0000 (15:36 +0100)]
Adapt test/keymgmt_internal_test.c to the redesigned interface

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoAdapt existing KEYMGMT implementations to the redesigned interface
Richard Levitte [Mon, 3 Feb 2020 11:00:53 +0000 (12:00 +0100)]
Adapt existing KEYMGMT implementations to the redesigned interface

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoRedesign the KEYMGMT libcrypto <-> provider interface - the basics
Richard Levitte [Sun, 2 Feb 2020 17:56:07 +0000 (18:56 +0100)]
Redesign the KEYMGMT libcrypto <-> provider interface - the basics

The KEYMGMT libcrypto <-> provider interface currently makes a few
assumptions:

1.  provider side domain parameters and key data isn't mutable. In
    other words, as soon as a key has been created in any (loaded,
    imported data, ...), it's set in stone.
2.  provider side domain parameters can be strictly separated from the
    key data.

This does work for the most part, but there are places where that's a
bit too rigid for the functionality that the EVP_PKEY API delivers.
Key data needs to be mutable to allow the flexibility that functions
like EVP_PKEY_copy_parameters promise, as well as to provide the
combinations of data that an EVP_PKEY is generally assumed to be able
to hold:

- domain parameters only
- public key only
- public key + private key
- domain parameters + public key
- domain parameters + public key + private key

To remedy all this, we:

1.  let go of the distinction between domain parameters and key
    material proper in the libcrypto <-> provider interface.

    As a consequence, functions that still need it gain a selection
    argument, which is a set of bits that indicate what parts of the
    key object are to be considered in a specific call.  This allows
    a reduction of very similar functions into one.

2.  Rework the libcrypto <-> provider interface so provider side key
    objects are created and destructed with a separate function, and
    get their data filled and extracted in through import and export.

(future work will see other key object constructors and other
functions to fill them with data)

Fixes #10979

squash! Redesign the KEYMGMT libcrypto <-> provider interface - the basics

Remedy 1 needs a rewrite:

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoReorganize the internal evp_keymgmt functions
Richard Levitte [Mon, 3 Feb 2020 04:42:48 +0000 (05:42 +0100)]
Reorganize the internal evp_keymgmt functions

Some of the evp_keymgmt_ functions are just wrappers around the
EVP_KEYMGMT function pointers.  We move those from keymgmt_lib.c to
keymgmt_meth.c.

Other evp_keymgmt_ functions are utility functions to help the rest of
the EVP functions.  Since their names are easily confused with the
functions that were moved to keymgmt_meth.c, we rename them so they
all start with evp_keymgmt_util_.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)

4 years agoTemporariy add ASN1_item_verify_ctx() missingcrypto.txt
Matt Caswell [Tue, 4 Feb 2020 14:33:21 +0000 (14:33 +0000)]
Temporariy add ASN1_item_verify_ctx() missingcrypto.txt

PR #10942 introduced the new function ASN1_item_verify_ctx(), but did
not document it with the promise that documentation would follow soon.
We temporarily add this function to missingcrypto.txt until it has been
done.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10980)

4 years agoDon't ignore ASN1 when checking for undocumented symbols
Matt Caswell [Fri, 31 Jan 2020 09:43:35 +0000 (09:43 +0000)]
Don't ignore ASN1 when checking for undocumented symbols

When we run "make doc-nits" (which happens during travis runs) it will
complain if we add any new symbols that aren't documented. However it
was suppressing anything starting with ASN1. There's no reason why we
should allow ASN1 symbols to go undocumented any more than any others.
Therefore we remove that exception.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10980)

4 years agoRemove unused HAS_LFN_SUPPORT
Rich Salz [Mon, 27 Jan 2020 20:39:17 +0000 (15:39 -0500)]
Remove unused HAS_LFN_SUPPORT

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

4 years agoFix misspelling errors and typos reported by codespell
Dr. Matthias St. Pierre [Sun, 2 Feb 2020 21:54:01 +0000 (22:54 +0100)]
Fix misspelling errors and typos reported by codespell

Fixes #10998

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

4 years agoMore accurate doc of -ssl_config option
Rich Salz [Mon, 3 Feb 2020 21:06:42 +0000 (16:06 -0500)]
More accurate doc of -ssl_config option

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10972)

4 years agoUpdate command list
Rich Salz [Thu, 30 Jan 2020 17:19:13 +0000 (12:19 -0500)]
Update command list

Add -standard-commands option to list command (documented)
Update standard commands list in openssl.pod

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10972)

4 years agoAdd cmd-nits to travis build
Rich Salz [Wed, 29 Jan 2020 16:18:39 +0000 (11:18 -0500)]
Add cmd-nits to travis build

Update CHANGES to have a complete and uniform description.

Fixes #9730

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10972)

4 years agoThe -hmac option to speed is now #ifdef'd
Rich Salz [Wed, 29 Jan 2020 18:21:19 +0000 (13:21 -0500)]
The -hmac option to speed is now #ifdef'd

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10972)

4 years agoAdd missing s_client options
Rich Salz [Wed, 29 Jan 2020 16:18:24 +0000 (11:18 -0500)]
Add missing s_client options

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10972)

4 years agoPrevent compiler warning for unused static function.
Davide Galassi [Sat, 25 Jan 2020 11:56:44 +0000 (12:56 +0100)]
Prevent compiler warning for unused static function.

Prepend missing ossl_unused in front of lh_type_new to make the compiler
happy.

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10946)

4 years agoRemoved unused ssl_dane struct declaration.
Davide Galassi [Sat, 25 Jan 2020 11:50:41 +0000 (12:50 +0100)]
Removed unused ssl_dane struct declaration.

The actually used structure is named ssl_dane_st.

CLA: trivial

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10945)

4 years agodoc: Fix typo in EVP_DigestSignInit manpage
Jakub Jelen [Tue, 14 Jan 2020 15:03:23 +0000 (16:03 +0100)]
doc: Fix typo in EVP_DigestSignInit manpage

CLA: trivial

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10841)

4 years agoFix small misspelling in doc for OCSP_response_status
thekuwayama [Sat, 11 Jan 2020 11:20:20 +0000 (20:20 +0900)]
Fix small misspelling in doc for OCSP_response_status

CLA: trivial

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10810)

4 years agoFix no-sm2
Matt Caswell [Tue, 4 Feb 2020 17:29:37 +0000 (17:29 +0000)]
Fix no-sm2

Fix ecdsatest to not run the SM2 test if SM2 has been disabled.

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

4 years agoAdd FFC param/key generation
Shane Lontis [Thu, 6 Feb 2020 12:28:36 +0000 (22:28 +1000)]
Add FFC param/key generation

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

4 years agoFix no-tls1_3
Matt Caswell [Tue, 4 Feb 2020 17:11:07 +0000 (17:11 +0000)]
Fix no-tls1_3

The hostname_cb in sslapitest.c was originally only defined if TLSv1.3
was enabled. A recently added test now uses this unconditionally, so we
move the function implementation earlier in the file, and always compile
it in.

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

4 years agoFix builds with no-dh
Matt Caswell [Fri, 31 Jan 2020 23:28:45 +0000 (23:28 +0000)]
Fix builds with no-dh

The various functions in bn_const.c return primes that are
specified for use in DH. However they were not being excluded from
a no-dh build - and was therefore causing the build to fail.

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

4 years agoAdd a test for SSL_CTX_new_with_libctx()
Matt Caswell [Wed, 15 Jan 2020 14:48:57 +0000 (14:48 +0000)]
Add a test for SSL_CTX_new_with_libctx()

We test that SSL_CTX_new_with_libctx() can be used to control the libctx
that is in use for SSL operations.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10854)

4 years agoUse the OPENSSL_CTX and property query string in EVP_PKEY_CTX
Matt Caswell [Wed, 15 Jan 2020 11:20:58 +0000 (11:20 +0000)]
Use the OPENSSL_CTX and property query string in EVP_PKEY_CTX

When we use an EVP_PKEY_CTX in libssl we should be doing so with the
OPENSSL_CTX and property query string that were specified when the
SSL_CTX object was first created.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10854)

4 years agoExplicitly fetch ciphers and digests in libssl
Matt Caswell [Thu, 16 Jan 2020 12:14:27 +0000 (12:14 +0000)]
Explicitly fetch ciphers and digests in libssl

We modify libssl to use explicitly fetched ciphers, digests and other
algorithms as required based on the configured library context and
property query string for the SSL_CTX that is being used.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10854)

4 years agoParams: change UTF8 construct calls to avoid explicit strlen(3) calls.
Pauli [Wed, 5 Feb 2020 05:13:49 +0000 (15:13 +1000)]
Params: change UTF8 construct calls to avoid explicit strlen(3) calls.

It is better, safer and smaller to let the library routine handle the
strlen(3) call.

Added a note to the documentation suggesting this.

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

4 years agoStop accepting certificates signed using SHA1 at security level 1
Kurt Roeckx [Thu, 2 Jan 2020 22:25:27 +0000 (23:25 +0100)]
Stop accepting certificates signed using SHA1 at security level 1

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
GH: #10786

4 years agoCreate a new embeddedSCTs1 that's signed using SHA256
Kurt Roeckx [Wed, 22 Jan 2020 23:24:35 +0000 (00:24 +0100)]
Create a new embeddedSCTs1 that's signed using SHA256

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
GH: #10786

4 years agoFix no-multiblock
Matt Caswell [Mon, 3 Feb 2020 15:30:05 +0000 (15:30 +0000)]
Fix no-multiblock

Minor fixes to resolve compilation errors with the no-multiblock
Configure option.

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

4 years agoAuthor: Ross Kinsey <RossIKinsey@gmail.com>
Ross Kinsey [Wed, 5 Feb 2020 03:47:05 +0000 (13:47 +1000)]
Author: Ross Kinsey <RossIKinsey@gmail.com>
Date:   Wed Jan 29 00:19:40 2020 -0500

Removed unnecessary switch statements from bio/bf_* callback_ctrl functions

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10967)

4 years agox86: Add endbranch to indirect branch targets for Intel CET
H.J. Lu [Fri, 31 Jan 2020 13:07:01 +0000 (05:07 -0800)]
x86: Add endbranch to indirect branch targets for Intel CET

To support Intel CET, all indirect branch targets must start with
endbranch.  Here is a patch to add endbranch to all function entries
in x86 assembly codes which are indirect branch targets as discovered
by running openssl testsuite on Intel CET machine and visual inspection.

Since x86 cbc.pl uses indirect branch with a jump table, we also need
to add endbranch to all jump targets.

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

4 years agoMake minimum size for secure memory a size_t.
Pauli [Tue, 4 Feb 2020 23:09:29 +0000 (09:09 +1000)]
Make minimum size for secure memory a size_t.

The minimum size argument to CRYPTO_secure_malloc_init() was an int but ought
to be a size_t since it is a size.

From an API perspective, this is a change.  However, the minimum size is
verified as being a positive power of two and it will typically be a small
constant.

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from #11003)

4 years agoEVP_MD_CTX_ctrl(): Remove unnecessary control
Richard Levitte [Sun, 2 Feb 2020 12:09:29 +0000 (13:09 +0100)]
EVP_MD_CTX_ctrl(): Remove unnecessary control

A check was present as to what operation is performed with this
context.  It may have been useful at some point, but isn't any more.

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

4 years agoPROV: Fix the DSA SIGNATURE implementation for better digests handling
Richard Levitte [Sun, 2 Feb 2020 12:09:23 +0000 (13:09 +0100)]
PROV: Fix the DSA SIGNATURE implementation for better digests handling

Refactor the DSA SIGNATURE digest setup to be uniform, and to happen
in two places:

1. when given through the digestsign and digestverify inits
2. when given through the set_ctx_params function.

When setting up the digest, we also check that the digest is one of
the officially accepted for DSA.

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

4 years agoPROV: Implement padding mode words in the RSA ASYM_CIPHER implementation
Richard Levitte [Sun, 2 Feb 2020 12:09:09 +0000 (13:09 +0100)]
PROV: Implement padding mode words in the RSA ASYM_CIPHER implementation

Because the libcrypto code has relinquished control of exact words to
express padding mode choices, we re-implement them in the appropriate
provider implementation.

For the sake of legacy controls, we maintain support for the numeric
form of the padding mode, but leave that support otherwise undeclared.

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

4 years agoDon't pass a digest-size to signature implementations
Richard Levitte [Sun, 2 Feb 2020 11:55:05 +0000 (12:55 +0100)]
Don't pass a digest-size to signature implementations

It turns out this was never necessary, as the implementation should
always check the default digest size anyway.

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

4 years agoDecentralize legacy_ctrl_str_to_param()
Richard Levitte [Sat, 25 Jan 2020 11:27:47 +0000 (12:27 +0100)]
Decentralize legacy_ctrl_str_to_param()

This function did a bit too much in terms of central control, actually
more so than the legacy counterpart, where all the string processing
is done in the diverse *_pmeth.c.  Furthermore, there was no room
whatsoever for control keys that libcrypto isn't centrally aware of.

This function is changed to simply translating keys and values to
OSSL_PARAM form and then sent on their merry way to the provider
implementations through EVP_PKEY_CTX_set_params().  It translates
selected well known legacy names to their core name counterpart, and
that's as far as centralized control should extend.

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

4 years agoTeach more BIOs how to handle BIO_CTRL_EOF
Matt Caswell [Fri, 24 Jan 2020 16:07:51 +0000 (16:07 +0000)]
Teach more BIOs how to handle BIO_CTRL_EOF

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10907)

4 years agoDetect EOF while reading in libssl
Matt Caswell [Fri, 17 Jan 2020 17:39:19 +0000 (17:39 +0000)]
Detect EOF while reading in libssl

If we hit an EOF while reading in libssl then we will report an error
back to the application (SSL_ERROR_SYSCALL) but errno will be 0. We add
an error to the stack (which means we instead return SSL_ERROR_SSL) and
therefore give a hint as to what went wrong.

Contains a partial fix for #10880

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10907)

4 years agoDeprecate the ECDSA and EV_KEY_METHOD functions.
Pauli [Tue, 28 Jan 2020 05:14:18 +0000 (15:14 +1000)]
Deprecate the ECDSA and EV_KEY_METHOD functions.

Use of the low level ECDSA and EC_KEY_METHOD functions has been informally discouraged for a
long time. We now formally deprecate them.

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

4 years agoDeprecate the ECDH functions.
Pauli [Tue, 28 Jan 2020 02:38:47 +0000 (12:38 +1000)]
Deprecate the ECDH functions.

Use of the low level ECDH functions has been informally discouraged for a
long time. We now formally deprecate them.

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

4 years agoec.h: fix preprocessor indentation
Pauli [Tue, 28 Jan 2020 02:37:28 +0000 (12:37 +1000)]
ec.h: fix preprocessor indentation

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

4 years agoFix coverity issues CID 1457745...1457752, 1457853, 1457854
Shane Lontis [Tue, 4 Feb 2020 03:50:51 +0000 (13:50 +1000)]
Fix coverity issues CID 1457745...145775214578531457854

CID 1457854 - keymgmt_lib.c : OVERRUN
CID 1457853 - self_test_kats.c : UNINT
CID 1457752 - fipsprov.c RESOURCE_LEAK (code change in another PR removed this)
CID 1457751 - apps/pkcs12.c CHECKED_RETURN
CID 1457750 - dsa_ossl.c RESOURCE_LEAK (marked as false positive since tmp can not be NULL)
CID 1457749 - apps/nseq.c : CHECKED_RETURN
CID 1457748 - cipher_aes_cbc_hmac_sha.c : SIZEOF_MISMATCH
CID 1457747 - cipher_aes_cbc_hmac_sha.c : SIZEOF_MISMATCH
CID 1457746 - same as 1457752
CID 1457745 - apps/ocsp  : CHECKED_RETURN

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

4 years agoFix krb5 external test failure
Richard Levitte [Mon, 3 Feb 2020 15:34:58 +0000 (15:34 +0000)]
Fix krb5 external test failure

The krb5 test requires the legacy module to be loaded in order to work.
It also seems to be senstive to using relative paths, so we use absolute
ones instead.

[extended tests]

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10992)

4 years agoMissing "obj_mac" header file in "dh_lib"
Davide Galassi [Sun, 2 Feb 2020 09:11:29 +0000 (10:11 +0100)]
Missing "obj_mac" header file in "dh_lib"

Usage of `NID_undef` symbol without including its definition was causing
a build fail

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

4 years agoDon't complain about documented symbols with find-doc-nits -d -o
Matt Caswell [Fri, 31 Jan 2020 10:08:33 +0000 (10:08 +0000)]
Don't complain about documented symbols with find-doc-nits -d -o

find-doc-nits can give a list of symbols that were added since 1.1.1 and
are undocumented (using -o). To do this it uses the missingcrypto111.txt
and missingssl111.txt files which give a snapshot of the undocumented
symbols at the time of the 1.1.1 release. Currently it complains about
symbols that are in those files that have subsequently been documented.
This isn't particularly helpful so we suppress that feature when "-o"
is being used.

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

4 years agoFix common test framework options
Matt Caswell [Thu, 30 Jan 2020 15:30:17 +0000 (15:30 +0000)]
Fix common test framework options

PR#6975 added the ability to our test framework to have common options to
all tests. For example providing the option "-test 5" to one of our test
programs will just run test number 5. This can be useful when debugging
tests.

Unforuntately this does not work well for a number of tests. In particular
those tests that call test_get_argument() without first skipping over these
common test options will not get the expected value. Some tests did this
correctly but a large number did not.

A helper function is introduced, test_skip_common_options(), to make this
easier for those tests which do not have their own specialised test option
handling, but yet still need to call test_get_argument(). This function
call is then added to all those tests that need it.

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

4 years agoFix no-ec
Matt Caswell [Fri, 31 Jan 2020 23:58:53 +0000 (23:58 +0000)]
Fix no-ec

The cmp_protect_test cert chain tests use some EC certs which breaks in
a no-ec build. The fix is to just skip those tests if no-ec has been
configured.

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

4 years agoRevert "Legacy digests can have custom control values"
Matt Caswell [Fri, 31 Jan 2020 22:44:56 +0000 (22:44 +0000)]
Revert "Legacy digests can have custom control values"

This reverts commit 1f457256ce6a1b2fd7e3f62eee8faa74cd5c835e.

This is causing Travis failures.

[extended tests]

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10989)

4 years agoCHANGES: Add note about the refactoring of SM2 EVP_PKEYs
Richard Levitte [Thu, 30 Jan 2020 15:02:49 +0000 (16:02 +0100)]
CHANGES: Add note about the refactoring of SM2 EVP_PKEYs

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

4 years agoAdapt some 'openssl' commands for SM2 changes.
Richard Levitte [Fri, 24 Jan 2020 17:45:23 +0000 (18:45 +0100)]
Adapt some 'openssl' commands for SM2 changes.

There's no longer any need to make an EVP_PKEY type change for SM2
keys, so we trim away that code.

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

4 years agoAdapt tests for SM2 changes.
Richard Levitte [Fri, 24 Jan 2020 17:14:53 +0000 (18:14 +0100)]
Adapt tests for SM2 changes.

With test/ecdsatest.c, we test all the curves once for each EC key
type we have, i.e. one round trip with EVP_PKEY_EC and one with
EVP_PKEY_SM2.  This shows that we can use "normal" EC computations on
keys with the SM2 curve (which have the type EVP_PKEY_SM2 by default)
and SM2 computations with any other curve (which have the type
EVP_PKEY_EC by default)

test/evp_test.c, on the other hand, doesn't need to explicitly set the
EVP_PKEY_SM2 alias type, as that now happens automatically.

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

4 years agoMake SM3 a mandatory hash function for SM2.
Richard Levitte [Fri, 24 Jan 2020 17:14:06 +0000 (18:14 +0100)]
Make SM3 a mandatory hash function for SM2.

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

4 years agoX509: Refactor X509_verify() and X509_REQ_verify() for better streamlining
Richard Levitte [Fri, 24 Jan 2020 17:04:19 +0000 (18:04 +0100)]
X509: Refactor X509_verify() and X509_REQ_verify() for better streamlining

The solution to incorporate the SM2 identity processing was an off
the side hack that more or less duplicated the ASN1_item_verify()
code with just a few lines being different.  We replace this with
a new function ASN1_item_verify_ctx(), which takes an EVP_MD_CTX
pointer instead of an EVP_PKEY pointer, just like its sibling
ASN1_item_sign_ctx().

This allows us to refactor X509_verify() and X509_REQ_verify() to
simply create a local EVP_MD_CTX and an attached EVP_PKEY_CTX,
which gets to hold the SM2 identity, if there is one, and then let
ASN1_item_verify_ctx() to its job.

This will also make it easier to adapt ASN1_item_verify_ctx() for
provider based keys.

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

4 years agoAdd SM2 specific parameter and key generation
Richard Levitte [Fri, 24 Jan 2020 16:59:03 +0000 (17:59 +0100)]
Add SM2 specific parameter and key generation

This makes it possible to generate SM2 parameters and keys like this:

    EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SM2);
    EVP_PKEY *pkey = EVP_PKEY_new();

    EVP_PKEY_keygen_init(pctx);
    EVP_PKEY_keygen(pctx, pkey);

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

4 years agoEVP_PKEY_assign_EC_KEY(): detect SM2 curve and set EVP_PKEY type accordingly
Richard Levitte [Fri, 24 Jan 2020 16:51:39 +0000 (17:51 +0100)]
EVP_PKEY_assign_EC_KEY(): detect SM2 curve and set EVP_PKEY type accordingly

This means that when loaded or created, EC EVP_PKEYs with the SM2
curve will be regarded as EVP_PKEY_SM2 type keys by default.
Applications are no longer forced to check and fix this.

It's still possible, for those who want this, to set the key type to
EVP_PKEY_EC and thereby run the normal EC computations with the SM2
curve.  This has to be done explicitly.

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

4 years agoEVP: Small refactor of keymgmt library code
Richard Levitte [Tue, 28 Jan 2020 15:51:01 +0000 (16:51 +0100)]
EVP: Small refactor of keymgmt library code

Some functions went directly on keymgmt function pointers instead of
going through the internal KEYMGMT API, which makes for a confusing
read.

Related to #10962

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

4 years agoconfig: ensure the perl Configure run is the last statement
Richard Levitte [Mon, 27 Jan 2020 07:42:20 +0000 (08:42 +0100)]
config: ensure the perl Configure run is the last statement

Running any statement after Configure means we lose its exit code

Fixes #10951

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/10953)

4 years agoFix "ts" no-XXX options, document two TLS options
Rich Salz [Fri, 24 Jan 2020 17:33:05 +0000 (12:33 -0500)]
Fix "ts" no-XXX options, document two TLS options

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10191)

4 years agoUpdate the SSL/TLS connection options
Rich Salz [Sat, 12 Oct 2019 21:45:56 +0000 (17:45 -0400)]
Update the SSL/TLS connection options

Refactor common flags for SSL/TLS connection options.
Update SSL_CONF_cmd.pod to match ordering.
Rewrite much of the documentation.

Fixes #10160

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10191)

4 years agoevp_pmeth: free the MD reference correctly.
Pauli [Wed, 29 Jan 2020 23:35:37 +0000 (09:35 +1000)]
evp_pmeth: free the MD reference correctly.

The code was calling EVP_MD_meth_free which is incorrect.  It should call
EVP_MD_free.  It happened to work but by luck rather than design.

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

4 years agoscrypt: free the MD reference correctly.
Pauli [Wed, 29 Jan 2020 23:04:14 +0000 (09:04 +1000)]
scrypt: free the MD reference correctly.

The code was calling EVP_MD_meth_free which is incorrect.  It should call
EVP_MD_free.  It happened to work but by luck rather than design.

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

4 years agoAdd support for DH 'modp' group parameters (RFC 3526)
Shane Lontis [Thu, 30 Jan 2020 22:18:46 +0000 (08:18 +1000)]
Add support for DH 'modp' group parameters (RFC 3526)

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

4 years agoDon't acknowledge a servername following warning alert in servername cb
Matt Caswell [Mon, 2 Dec 2019 17:29:21 +0000 (17:29 +0000)]
Don't acknowledge a servername following warning alert in servername cb

If the servername cb decides to send back a warning alert then the
handshake continues, but we should not signal to the client that the
servername has been accepted.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/10018)

4 years agoProvide better documentation for SSL_get_servername()
Matt Caswell [Thu, 28 Nov 2019 12:03:00 +0000 (12:03 +0000)]
Provide better documentation for SSL_get_servername()

The behaviour of SSL_get_servername() is quite complicated and depends on
numerous factors such as whether it is called on the client or the server,
whether it is called before or after the handshake, what protocol version
was negotiated, and whether a resumption was attempted or was successful.

We attempt to document the behavior more clearly.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/10018)

4 years agoTest that SSL_get_servername returns what we expect
Matt Caswell [Thu, 26 Sep 2019 15:16:06 +0000 (16:16 +0100)]
Test that SSL_get_servername returns what we expect

Test this on both the client and the server after a normal handshake,
and after a resumption handshake. We also test what happens if an
inconsistent SNI is set between the original handshake and the resumption
handshake. Finally all of this is also tested in TLSv1.2 and TLSv1.3.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/10018)

4 years agoFix SSL_get_servername() and SNI behaviour
Matt Caswell [Wed, 25 Sep 2019 16:06:06 +0000 (17:06 +0100)]
Fix SSL_get_servername() and SNI behaviour

The SNI behaviour for TLSv1.3 and the behaviour of SSL_get_servername()
was not quite right, and not entirely consistent with the RFC.

The TLSv1.3 RFC explicitly says that SNI is negotiated on each handshake
and the server is not required to associate it with the session. This was
not quite reflected in the code so we fix that.

Additionally there were some additional checks around early_data checking
that the SNI between the original session and this session were
consistent. In fact the RFC does not require any such checks, so they are
removed.

Finally the behaviour of SSL_get_servername() was not quite right. The
behaviour was not consistent between resumption and normal handshakes,
and also not quite consistent with historical behaviour. We clarify the
behaviour in various scenarios and also attempt to make it match historical
behaviour as closely as possible.

Fixes #8822

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/10018)

4 years agoFix type name typo in d2i/i2d documentation.
David Makepeace [Thu, 23 Jan 2020 01:07:18 +0000 (11:07 +1000)]
Fix type name typo in d2i/i2d documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10933)

4 years agoAdd -issuer_checks to verify options
Rich Salz [Fri, 24 Jan 2020 18:32:34 +0000 (13:32 -0500)]
Add -issuer_checks to verify options

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10873)

4 years agoDocument most missing options
Rich Salz [Thu, 16 Jan 2020 18:40:52 +0000 (13:40 -0500)]
Document most missing options

Add cmd-nits make target.

Listing options should stop when it hits the "parameters" separator.

Add missing .pod.in files to doc/man1/build.info

Tweak find-doc-nits to try openssl-XXX before XXX for POD files and
change an error messavge to be more useful.

Fix the following pages: ca, cms, crl, dgst, enc,
engine, errstr, gendsa, genrsa, list, ocsp, passwd, pkcs7, pkcs12, rand,
rehash, req, rsautil, s_server, speed, s_time,
sess_id, smime, srp, ts, x509.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10873)

4 years agoAdd more generated man1 doc files
Rich Salz [Mon, 20 Jan 2020 14:45:27 +0000 (09:45 -0500)]
Add more generated man1 doc files

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10873)

4 years agoAdd RSA key validation to default provider
Shane Lontis [Wed, 29 Jan 2020 10:32:32 +0000 (20:32 +1000)]
Add RSA key validation to default provider

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

4 years agoTLS: use EVP for HMAC throughout libssl.
Pauli [Fri, 24 Jan 2020 00:41:38 +0000 (10:41 +1000)]
TLS: use EVP for HMAC throughout libssl.

Backwards compatibility with the old ticket key call back is maintained.
This will be removed when the low level HMAC APIs are finally removed.

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

4 years agoDeprecate the low level HMAC functions
Pauli [Tue, 14 Jan 2020 02:11:50 +0000 (12:11 +1000)]
Deprecate the low level HMAC functions

Use of the low level HMAC functions has been informally discouraged for a
long time.  We now formally deprecate them.

Applications should instead use EVP_MAC_CTX_new(3), EVP_MAC_CTX_free(3),
EVP_MAC_init(3), EVP_MAC_update(3) and EVP_MAC_final(3).

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

4 years agohmac: preprocessor indentation fixes
Pauli [Tue, 14 Jan 2020 00:49:28 +0000 (10:49 +1000)]
hmac: preprocessor indentation fixes

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