oweals/openssl.git
5 years agoChange the DRBG HASH implementation to lookup all allowed algorithm names
Matt Caswell [Thu, 20 Jun 2019 10:51:08 +0000 (11:51 +0100)]
Change the DRBG HASH implementation to lookup all allowed algorithm names

We use the new function ossl_prov_util_nid_to_name() to look up the
algorithm and unify the FIPS_MODE and non-FIPS_MODE handling.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9035)

5 years agoAdd a nid 2 algorithm name mapping capability
Matt Caswell [Thu, 20 Jun 2019 10:48:50 +0000 (11:48 +0100)]
Add a nid 2 algorithm name mapping capability

Providers that link against libcrypto can just use OBJ_nid2sn() to look
up the name of an algorithm given a NID. However that doesn't work for the
FIPS provider because OBJ_nid2sn() is not available there (due to the
reliance of the code on ASN.1 types). Therefore we provider a new function
to do this mapping. For providers linking against libcrypto the new function
just wraps OBJ_nid2sn(). For the FIPS provider it has a look up for all the
NIDs known there.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9035)

5 years agoCall RAND_DRBG_bytes from inside the FIPS provider
Matt Caswell [Tue, 28 May 2019 10:26:17 +0000 (11:26 +0100)]
Call RAND_DRBG_bytes from inside the FIPS provider

Insert a dummy call to RAND_DRBG_bytes from inside the FIPS provider to
demonstrate that it is possible to use the RAND code from inside the
module. This is temporary and will be removed once real uses of the RAND
code are available inside the module.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9035)

5 years agoFix NULL pointer dereference in the ex_data code
Matt Caswell [Tue, 28 May 2019 10:28:16 +0000 (11:28 +0100)]
Fix NULL pointer dereference in the ex_data code

In some circumstances the global data held in the "global" variable can
be NULL, so we should error out in the circumstance instead of crashing.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9035)

5 years agoMake the RAND code available from inside the FIPS module
Matt Caswell [Thu, 23 May 2019 13:35:42 +0000 (14:35 +0100)]
Make the RAND code available from inside the FIPS module

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9035)

5 years agoDocument EVP_CIPHER_up_ref()
Matt Caswell [Mon, 24 Jun 2019 16:47:04 +0000 (17:47 +0100)]
Document EVP_CIPHER_up_ref()

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

5 years agoRename EVP_MD_upref/EVP_CIPHER_upref to EVP_MD_up_ref/EVP_CIPHER_up_ref
Matt Caswell [Mon, 24 Jun 2019 16:38:01 +0000 (17:38 +0100)]
Rename EVP_MD_upref/EVP_CIPHER_upref to EVP_MD_up_ref/EVP_CIPHER_up_ref

All the other upref functions are spelled as "up_ref". These new functions
should be consistent.

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

5 years agoAdd documentation for EVP_CIPHER_fetch
Matt Caswell [Mon, 24 Jun 2019 16:34:14 +0000 (17:34 +0100)]
Add documentation for EVP_CIPHER_fetch

We extend the EVP_MD_fetch documentation to be more generic and to also
cover EVP_CIPHER_fetch. We expect this to be further expanded with other
"fetch" functions in the future.

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

5 years agoman: clarify the 'random number generator must be seeded' requirement
Dr. Matthias St. Pierre [Thu, 27 Jun 2019 08:12:08 +0000 (10:12 +0200)]
man: clarify the 'random number generator must be seeded' requirement

The manual pages require for some API functions that the 'random number
generator must be seeded' before calling the function.  Initially, this
was meant literally, i.e. the OpenSSL CSPRNG had to be seeded manually
before calling these functions.

Since version 1.1.1, the CSPRNG is seeded automatically on first use,
so it's not the responsibility of the programmer anymore.  Still, he
needs to be aware that the seeding might fail.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9257)

5 years agoman: fix documentation for RSA_generate_key()
Dr. Matthias St. Pierre [Thu, 27 Jun 2019 10:50:26 +0000 (12:50 +0200)]
man: fix documentation for RSA_generate_key()

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9260)

5 years agoMove the public SIV mode functions from public headers to internal ones
Matt Caswell [Mon, 24 Jun 2019 15:07:30 +0000 (16:07 +0100)]
Move the public SIV mode functions from public headers to internal ones

SIV mode is accessible via EVP. There should be no reason to make the low
level SIV functions from the modes directory part of the public API. Since
these functions do not exist in 1.1.1 we are still able to make this change.

This also reduces the list of newly added undocumented symbols from
issue #9095.

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

5 years agoMove 'shared_sigalgs' from cert_st to ssl_st
Benjamin Kaduk [Thu, 13 Jun 2019 19:26:12 +0000 (12:26 -0700)]
Move 'shared_sigalgs' from cert_st to ssl_st

It was only ever in cert_st because ssl_st was a public structure
and could not be modified without breaking the API.  However, both
structures are now opaque, and thus we can freely change their layout
without breaking applications.  In this case, keeping the shared
sigalgs in the SSL object prevents complications wherein they would
inadvertently get cleared during SSL_set_SSL_CTX() (e.g., as run
during a cert_cb).

Fixes #9099

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

5 years agoRevert "Delay setting the sig algs until after the cert_cb has been called"
Benjamin Kaduk [Thu, 13 Jun 2019 19:04:52 +0000 (12:04 -0700)]
Revert "Delay setting the sig algs until after the cert_cb has been called"

This reverts commit 524006dd1b80c1a86a20119ad988666a80d8d8f5.

While this change did prevent the sigalgs from getting inadvertently
clobbered by SSL_set_SSL_CTX(), it also caused the sigalgs to not be
set when the cert_cb runs.  This, in turn, caused significant breakage,
such as SSL_check_chain() failing to find any valid chain.  An alternate
approach to fixing the issue from #7244 will follow.

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

5 years agoAdd regression test for #9099
Benjamin Kaduk [Thu, 13 Jun 2019 19:02:03 +0000 (12:02 -0700)]
Add regression test for #9099

Augment the cert_cb sslapitest to include a run that uses
SSL_check_chain() to inspect the certificate prior to installing
it on the SSL object.  If the check shows the certificate as not
valid in that context, we do not install a certificate at all, so
the handshake will fail later on in processing (tls_choose_sigalg()),
exposing the indicated regression.

Currently it fails, since we have not yet set the shared sigalgs
by the time the cert_cb runs.

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

5 years agoKeep the externally visible macro BIO_FLAGS_UPLINK in bio.h
Bernd Edlinger [Mon, 24 Sep 2018 11:15:22 +0000 (13:15 +0200)]
Keep the externally visible macro BIO_FLAGS_UPLINK in bio.h
and rename the internally used macro to BIO_FLAGS_UPLINK_INTERNAL.

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

5 years agoFix incorrect usage of a test case
Paul Yang [Wed, 26 Jun 2019 09:36:56 +0000 (17:36 +0800)]
Fix incorrect usage of a test case

test/x509_check_cert_pkey_test.c has incorrect usage description.

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

5 years agoThe params_test uses wrong size for BN check.
Pauli [Mon, 24 Jun 2019 15:37:07 +0000 (01:37 +1000)]
The params_test uses wrong size for BN check.

Before the return size was included in the OSSL_PARAM structure, the size
global was updated via a pointer.  The size global variable has been removed
and the in structure return size used instead.

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

5 years agoEC only uses approved curves in FIPS mode.
Shane Lontis [Tue, 4 Jun 2019 22:24:16 +0000 (08:24 +1000)]
EC only uses approved curves in FIPS mode.

Once there are buildable fips tests, some tests that are data driven
from files will need to be modified to exclude non approved curves in
fips mode.

These changes were tested by temporarily adding #define FIPS_MODE 1 to
all the modified source files.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9081)

5 years agoFix s390x build errors and warnings
Patrick Steuer [Mon, 24 Jun 2019 22:10:20 +0000 (00:10 +0200)]
Fix s390x build errors and warnings

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9236)

5 years agoOSSL_TRACE: enhance documentation and fix doc-nit errors
Dr. Matthias St. Pierre [Sun, 23 Jun 2019 17:25:50 +0000 (19:25 +0200)]
OSSL_TRACE: enhance documentation and fix doc-nit errors

- Add the following macros to the NAME section:

  - with synopsis
        OSSL_TRACE_CANCEL, OSSL_TRACE, OSSL_TRACE_ENABLED
  - without synopsis
        OSSL_TRACEV (helper macro, not intended for public use)
        OSSL_TRACE[3-8] (omitted on purpose)

- Revise the NOTES section

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

5 years agoCross-linked the man(1) pages of kdf & pkeyutl.
Santhosh Rameshwarapu [Mon, 24 Jun 2019 08:20:55 +0000 (13:50 +0530)]
Cross-linked the man(1) pages of kdf & pkeyutl.

Fixes #8784

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

5 years agoOSSL_NAMEMAP: make names case insensitive
Richard Levitte [Wed, 5 Jun 2019 06:59:13 +0000 (08:59 +0200)]
OSSL_NAMEMAP: make names case insensitive

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

5 years agoAdd a namemap test
Richard Levitte [Thu, 23 May 2019 14:00:05 +0000 (16:00 +0200)]
Add a namemap test

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

5 years agoReplumbing: add support for multiple names per algorithm
Richard Levitte [Thu, 23 May 2019 01:18:04 +0000 (03:18 +0200)]
Replumbing: add support for multiple names per algorithm

Algorithms may have multiple names, as seen in the legacy names
database.  We need to support that as well.

This implementations modifies ossl_namemap to support multiple names
for the same identifier.

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

5 years agoAllow AES XTS decryption using duplicate keys.
Pauli [Mon, 24 Jun 2019 07:54:47 +0000 (17:54 +1000)]
Allow AES XTS decryption using duplicate keys.

This feature is enabled by default outside of FIPS builds
which ban such actions completely.

Encryption is always disallowed and will generate an error.

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

5 years agoEnhance and update the docs of the internal ossl_provider API
Richard Levitte [Thu, 20 Jun 2019 15:55:36 +0000 (17:55 +0200)]
Enhance and update the docs of the internal ossl_provider API

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

5 years agoChange OSSL_PARAM return size to not be a pointer.
Pauli [Mon, 24 Jun 2019 04:43:55 +0000 (14:43 +1000)]
Change OSSL_PARAM return size to not be a pointer.

Instead of referencing the return size from the OSSL_PARAM structure, make the
size a field within the structure.

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

5 years agoAdd documentation for CRYPTO_memcmp.
Pauli [Sun, 23 Jun 2019 23:18:48 +0000 (09:18 +1000)]
Add documentation for CRYPTO_memcmp.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9225)

5 years agocrypto/trace.c: Remove unexisting categories
Richard Levitte [Sat, 22 Jun 2019 08:08:05 +0000 (10:08 +0200)]
crypto/trace.c: Remove unexisting categories

Reverts an inadvertent change from commit
fe26f798526c14a3f8c9bb55d0eaf8eaa0d086e1

Fixes #9220

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9218)

5 years agoOSSL_TRACE: ensure it's initialised
Richard Levitte [Fri, 21 Jun 2019 09:20:15 +0000 (11:20 +0200)]
OSSL_TRACE: ensure it's initialised

When OSSL_TRACE functionality is called before anything else, it finds
itself uninitialised, i.e. its global lock hasn't been created yet.

Fortunately, we have an internal general setup function for the trace
functionality, that makes for a perfect spot to trigger initialisation.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9212)

5 years agoHandle CTRL-C as non-redoable abort signal
Bernd Edlinger [Mon, 17 Jun 2019 14:57:25 +0000 (16:57 +0200)]
Handle CTRL-C as non-redoable abort signal

This is a bit annoying, if for instance "openssl genrsa -aes128"
tries to read a 4+ character size password, but CTRL-C does no longer
work after a RETURN key, since the flag UI_FLAG_REDOABLE is set by
UI_set_result_ex, together with the error "You must type in 4 to 1023 characters".
Thus remove the REDOABLE flag to allow CTRL-C to work.

[extended tests]

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

5 years agoRemove OPENSSL_memcmp.
Pauli [Thu, 20 Jun 2019 23:27:48 +0000 (09:27 +1000)]
Remove OPENSSL_memcmp.

After avoiding OPENSSL_memcmp for EC curve comparison, there are no remaining
uses in the source code.  The function is only defined in an internal header
and thus should be safe to remove for 3.0.0.

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

5 years agoPrint thread IDs nicely.
Pauli [Thu, 20 Jun 2019 01:24:17 +0000 (11:24 +1000)]
Print thread IDs nicely.

Remove the union that effectively cast thread IDs to long integers before
display and instead print a hex dump of the entire object.

Refer #9191

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

5 years agotest/testutil/init.c, apps/openssl.c: add trace cleanup handle earlier
Richard Levitte [Thu, 20 Jun 2019 08:38:46 +0000 (10:38 +0200)]
test/testutil/init.c, apps/openssl.c: add trace cleanup handle earlier

It turned out that the internal trace cleanup handler was added too
late, so it would be executed before OPENSSL_cleanup().
This results in address errors, as the trace code that's executed in
OPENSSL_cleanup() itself tries to reach for data that's been freed at
that point.

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

5 years agoUpdate test/README
Frederik Wedel-Heinen [Thu, 13 Jun 2019 12:13:42 +0000 (14:13 +0200)]
Update test/README

Changed a bad reference: test/Makefile -> test/build.info

Add ../apps/include as include path to include opt.h used by test/testutil.h.

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

5 years agoAdd SSL_shutdown to SSL_get_error's documentation
Miquel Ruiz [Mon, 22 Oct 2018 21:34:57 +0000 (22:34 +0100)]
Add SSL_shutdown to SSL_get_error's documentation

SSL_shutdown can fail if called during initialization, and in such case, it'll
add an error to the error queue. This adds SSL_shutdown to the list of functions
that should preceed the call to SSL_get_error.

CLA: trivial

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

5 years agoFix UEFI build on FreeBSD by not including system headers
Rebecca Cran [Wed, 12 Jun 2019 20:03:36 +0000 (14:03 -0600)]
Fix UEFI build on FreeBSD by not including system headers

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9149)

5 years agoFix a doc-nits failure
Matt Caswell [Wed, 19 Jun 2019 12:13:55 +0000 (13:13 +0100)]
Fix a doc-nits failure

We need blank lines on each side of a section heading.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9192)

5 years agoFix and document BIO_FLAGS_NONCLEAR_RST behavior on memory BIO
Tomas Mraz [Tue, 18 Jun 2019 14:41:48 +0000 (16:41 +0200)]
Fix and document BIO_FLAGS_NONCLEAR_RST behavior on memory BIO

The BIO_FLAGS_NONCLEAR_RST flag behavior was not properly documented
and it also caused the length to be incorrectly set after the reset
operation.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9179)

5 years agoAdd some internal documentation for some thread related functions
Matt Caswell [Wed, 19 Jun 2019 09:31:39 +0000 (10:31 +0100)]
Add some internal documentation for some thread related functions

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

5 years agoProvide an ability to deregister thread stop handlers
Matt Caswell [Tue, 18 Jun 2019 17:37:38 +0000 (18:37 +0100)]
Provide an ability to deregister thread stop handlers

If a provider gets unloaded then any thread stop handlers that it had
registered will be left hanging. We should clean them up before tearing
down the provider.

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

5 years agoAdd tracing capability in test utilities
Richard Levitte [Wed, 19 Jun 2019 06:44:20 +0000 (08:44 +0200)]
Add tracing capability in test utilities

If a test program goes wrong, it's sometimes helpful to be able to
trace what goes on in libcrypto and libssl.

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

5 years agoAdd extra error text in the property parser
Richard Levitte [Wed, 19 Jun 2019 06:37:19 +0000 (08:37 +0200)]
Add extra error text in the property parser

With properties being specified in all kinds of places, including hard
coded in providers, it's not always easy to figure out exactly what
string was incorrect when the parser would just say something like
'parse failed' with no more details.

Adding extra data to the error, showing exactly what string is
incorrect, helps a bit.  At the very least, this gives anyone
interested something to grep for.

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

5 years agoDon't create an OPENSSL_CTX twice
Matt Caswell [Tue, 18 Jun 2019 17:36:36 +0000 (18:36 +0100)]
Don't create an OPENSSL_CTX twice

The fips provider was creating the OPENSSL_CTX twice due to a previous
merge error.

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

5 years agoARIA documentation titled itself AES
Pauli [Wed, 19 Jun 2019 00:20:49 +0000 (10:20 +1000)]
ARIA documentation titled itself AES

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

5 years agoChange ERR_add_error_[v]data to append
Rich Salz [Tue, 18 Jun 2019 16:06:17 +0000 (12:06 -0400)]
Change ERR_add_error_[v]data to append

The "add error data" functions now append to the current error.
Add a test for this.
Cleanup some of the ERR_put functions.
In the FIPS module, always append "(in the FIPS module)" to any errors.

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

5 years agocrypto/modes/build.conf: Fix MODES asm mistakes
Richard Levitte [Tue, 18 Jun 2019 14:23:06 +0000 (16:23 +0200)]
crypto/modes/build.conf: Fix MODES asm mistakes

The old rule in Configure was that if the asm source had a file name
with 'ghash-' as part of the name, GHASH_ASM should be defined.  Since
none of the aarch64 asm files has such a name, that macro shouldn't
have been defined.

Fixes #9173

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

5 years agocrypto/aes/build.info: Fix AES assembler specs
Richard Levitte [Tue, 18 Jun 2019 14:04:12 +0000 (16:04 +0200)]
crypto/aes/build.info: Fix AES assembler specs

Two mistakes were made:

1. AES_ASM for x86 was misplaced
2. sse2 isn't applicable for x86_64 code

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

5 years agoFollowing the previous 2 commits also move ecpointformats out of session
Matt Caswell [Tue, 18 Jun 2019 10:45:26 +0000 (11:45 +0100)]
Following the previous 2 commits also move ecpointformats out of session

The previous 2 commits moved supported groups and ciphers out of the
session object to avoid race conditions. We now also move ecpointformats
for consistency. There does not seem to be a race condition with access
to this data since it is only ever set in a non-resumption handshake.
However, there is no reason for it to be in the session.

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

5 years agoFix a race condition in ciphers handling
Matt Caswell [Fri, 14 Jun 2019 13:06:55 +0000 (14:06 +0100)]
Fix a race condition in ciphers handling

Similarly to the previous commit we were storing the peer offered list
of ciphers in the session. In practice there is no need for this
information to be avilable from one resumption to the next since this
list is specific to a particular handshake. Since the session object is
supposed to be immutable we should not be updating it once we have decided
to resume. The solution is to remove the session list out of the session
object.

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

5 years agoFix a race condition in supported groups handling
Matt Caswell [Fri, 14 Jun 2019 11:46:13 +0000 (12:46 +0100)]
Fix a race condition in supported groups handling

In TLSv1.3 the supported groups can be negotiated each time a handshake
occurs, regardless of whether we are resuming or not. We should not store
the supported groups information in the session because session objects
can be shared between multiple threads and we can end up with race
conditions. For most users this won't be seen because, by default, we
use stateless tickets in TLSv1.3 which don't get shared. However if you
use SSL_OP_NO_TICKET (to get stateful tickets in TLSv1.3) then this can
happen.

The answer is to move the supported the supported group information into
the SSL object instead.

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

5 years agoFix error handling at openssl_strerror_r
Bernd Edlinger [Fri, 14 Jun 2019 12:48:37 +0000 (14:48 +0200)]
Fix error handling at openssl_strerror_r

When bufsize == 0, openssl_strerror_r should return 0 (if _GNU_SOURCE is defined),
to be consistent with non-_GNU_SOURCE variants, which exhibit the same behavior.
Fix a few cases, where the return value of openssl_strerror_r was ignored.

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

5 years ago Swap #if blocks in uid.c so target platform gets checked before host
Rebecca Cran [Tue, 18 Jun 2019 03:02:32 +0000 (13:02 +1000)]
 Swap #if blocks in uid.c so target platform gets checked before host

This avoids the case where a UEFI build on FreeBSD tries to call the system
issetugid function instead of returning 0 as it should do.

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from #9158)

5 years agoStandardise the function naming conventions in initthread.c
Matt Caswell [Mon, 17 Jun 2019 14:16:36 +0000 (15:16 +0100)]
Standardise the function naming conventions in initthread.c

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

5 years agoDocument OPENSSL_thread_stop_ex()
Matt Caswell [Wed, 29 May 2019 15:04:17 +0000 (16:04 +0100)]
Document OPENSSL_thread_stop_ex()

This new function works in the same way as OPENSSL_thread_stop() but
for a specified OPENSSL_CTX.

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

5 years agoAdd the function OPENSSL_thread_stop_ex()
Matt Caswell [Tue, 28 May 2019 15:21:19 +0000 (16:21 +0100)]
Add the function OPENSSL_thread_stop_ex()

This adds the ability to clean up a thread on a per OPENSSL_CTX basis.

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

5 years agoTell the FIPS provider about thread stop events
Matt Caswell [Mon, 27 May 2019 15:31:27 +0000 (16:31 +0100)]
Tell the FIPS provider about thread stop events

The RAND code needs to know about threads stopping in order to cleanup
local thread data. Therefore we add a callback for libcrypto to tell
providers about such events.

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

5 years agoProvide a version of ossl_init_thread_start that works in FIPS mode
Matt Caswell [Fri, 24 May 2019 17:20:49 +0000 (18:20 +0100)]
Provide a version of ossl_init_thread_start that works in FIPS mode

This will need to be hooked up in a later commit with an event sent to
the FIPS provider informing it of thread stop events.

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

5 years agoSplit thread intialisation and handling out of init.c
Matt Caswell [Fri, 24 May 2019 16:52:17 +0000 (17:52 +0100)]
Split thread intialisation and handling out of init.c

We're going to need some of these functions in the FIPS module, but most
of the rest of the code in init.c is not needed. Therefore we split it out.

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

5 years agoConvert thread stop handling into a publish/subscribe model
Matt Caswell [Fri, 24 May 2019 10:45:48 +0000 (11:45 +0100)]
Convert thread stop handling into a publish/subscribe model

In later commits this will allow providers to subscribe to thread stop
events. We will need this in the FIPS module. We also make thread stop
handling OPENSSL_CTX aware (different OPENSSL_CTXs may have different
thread local data that needs cleaning up).

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

5 years agoAdd the function openssl_ctx_get_concrete()
Matt Caswell [Tue, 28 May 2019 14:58:08 +0000 (15:58 +0100)]
Add the function openssl_ctx_get_concrete()

This adds the ability to take an OPENSSL_CTX parameter and either return it
as is (unchanged), or if it is NULL return a pointer to the default ctx.

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

5 years agoConfigure: final cleanup of asm related things
Richard Levitte [Sun, 16 Jun 2019 21:01:10 +0000 (23:01 +0200)]
Configure: final cleanup of asm related things

Remove the *_asm templates in Configurations/00-base-templates.conf,
all attempts to inherit them, and the asm() perl function.

[extended tests]

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

5 years agoMove padlock_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:39:19 +0000 (22:39 +0200)]
Move padlock_asm_src file information to build.info files

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

5 years agoMove keccak1600_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:34:09 +0000 (22:34 +0200)]
Move keccak1600_asm_src file information to build.info files

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

5 years agoMove poly1305_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:28:32 +0000 (22:28 +0200)]
Move poly1305_asm_src file information to build.info files

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

5 years agoMove chacha_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:21:50 +0000 (22:21 +0200)]
Move chacha_asm_src file information to build.info files

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

5 years agoMove modes_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:17:26 +0000 (22:17 +0200)]
Move modes_asm_src file information to build.info files

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

5 years agoMove cmll_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:06:43 +0000 (22:06 +0200)]
Move cmll_asm_src file information to build.info files

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

5 years agoMove wp_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 20:03:00 +0000 (22:03 +0200)]
Move wp_asm_src file information to build.info files

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

5 years agoMove rc5_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:57:13 +0000 (21:57 +0200)]
Move rc5_asm_src file information to build.info files

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

5 years agoMove rmd160_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:54:35 +0000 (21:54 +0200)]
Move rmd160_asm_src file information to build.info files

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

5 years agoMove rc4_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:50:39 +0000 (21:50 +0200)]
Move rc4_asm_src file information to build.info files

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

5 years agoMove cast_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:46:38 +0000 (21:46 +0200)]
Move cast_asm_src file information to build.info files

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

5 years agoMove sha1_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:46:10 +0000 (21:46 +0200)]
Move sha1_asm_src file information to build.info files

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

5 years agoMove md5_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:25:52 +0000 (21:25 +0200)]
Move md5_asm_src file information to build.info files

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

5 years agoMove bf_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:20:43 +0000 (21:20 +0200)]
Move bf_asm_src file information to build.info files

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

5 years agoMove aes_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 19:03:07 +0000 (21:03 +0200)]
Move aes_asm_src file information to build.info files

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

5 years agoMove des_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 18:21:48 +0000 (20:21 +0200)]
Move des_asm_src file information to build.info files

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

5 years agoMove ec_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 17:57:52 +0000 (19:57 +0200)]
Move ec_asm_src file information to build.info files

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

5 years agoMove cpuid_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 17:35:08 +0000 (19:35 +0200)]
Move cpuid_asm_src file information to build.info files

Also took away the internal 'debug-linux-ia32-aes' config target, as
it's broken (refers to files that no longer exist).

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

5 years agoMove bn_asm_src file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 14:56:25 +0000 (16:56 +0200)]
Move bn_asm_src file information to build.info files

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

5 years agoConfigure: add mechanism to specify asm target architecture
Richard Levitte [Sun, 16 Jun 2019 11:32:58 +0000 (13:32 +0200)]
Configure: add mechanism to specify asm target architecture

As preparation for moving asm file specs to build.info files, we must
make sure there is still some base information to help select the
correct files.

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

5 years agoMove uplink file information to build.info files
Richard Levitte [Sun, 16 Jun 2019 10:56:21 +0000 (12:56 +0200)]
Move uplink file information to build.info files

This file information was hidden in config target files, when they
should really be part of build.info like any other file we build
from.  With build.info variables, the task became much easier.

We take the opportunity to move apps_init_src and apps_aux_src to
apps/build.info as well, and to clean up apps/build.info.

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

5 years agoConfigure: add mechanism to specify uplink target architecture
Richard Levitte [Sun, 16 Jun 2019 10:37:21 +0000 (12:37 +0200)]
Configure: add mechanism to specify uplink target architecture

As preparation for moving uplink file specs to build.info files, we
must make sure there is still some base information to help select the
correct files.

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

5 years agoConfigure: allow conditions and variable values to have variable references
Richard Levitte [Sun, 16 Jun 2019 09:38:30 +0000 (11:38 +0200)]
Configure: allow conditions and variable values to have variable references

This will allow building variables on other variables, and to have
conditions based on variable contents.

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

5 years agoConfigure: AIX needs a specific DSO extension function
Richard Levitte [Sat, 25 May 2019 09:02:59 +0000 (11:02 +0200)]
Configure: AIX needs a specific DSO extension function

DSO extensions are normally derived from platform->shlibextsimple() on
Unix.  This isn't the case for AIX, so it needs to define its own DSO
extension specifically.

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

5 years agoFix no-ec with no-dh
Matt Caswell [Thu, 13 Jun 2019 18:34:37 +0000 (19:34 +0100)]
Fix no-ec with no-dh

Make sure that the combination of no-ec with no-dh builds successfully.
If neither ec or dh are available then TLSv1.3 is not possible.

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

5 years agoAllow TLSv1.3 in a no-ec build
Matt Caswell [Thu, 13 Jun 2019 10:06:12 +0000 (11:06 +0100)]
Allow TLSv1.3 in a no-ec build

Now that we have TLSv1.3 FFDHE support there is no reason why we should
not allow TLSv1.3 to be used in a no-ec build. This commit enables that
to happen.

It also fixes no-ec which was previously broken.

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

5 years agoReplumbing: Adapt the default and legacy providers to use library context upcall
Richard Levitte [Fri, 14 Jun 2019 09:41:32 +0000 (11:41 +0200)]
Replumbing: Adapt the default and legacy providers to use library context upcall

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

5 years agoReplumbing: Adapt the FIPS module to use the library context upcall
Richard Levitte [Fri, 14 Jun 2019 08:27:30 +0000 (10:27 +0200)]
Replumbing: Adapt the FIPS module to use the library context upcall

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

5 years agoReplumbing: offer a core upcall to get the provider object's library context
Richard Levitte [Fri, 14 Jun 2019 08:19:56 +0000 (10:19 +0200)]
Replumbing: offer a core upcall to get the provider object's library context

The FIPS module currently has "magic" support to have the library
context become the provider context within the core code, for the FIPS
module's inner provider.

We replace that with a core upcall that returns the library context
associated with a provider object.  That way, the FIPS module can
handle the assignment of the inner provider context itself.  This
allows the FIPS module (and any other provider module that wishes to
use a similar mechanism) to define for itself what the provider
context is.  It's currently simply a pointer to a library context,
but may contain other stuff as well in the future.

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

5 years agocrypto/ppccap.c: Fix FIPS build on PPC
Richard Levitte [Mon, 17 Jun 2019 06:14:57 +0000 (08:14 +0200)]
crypto/ppccap.c: Fix FIPS build on PPC

Some code was temporarly disabled in the FIPS module because SHA other
SHA1 hadn't been ported.  Now that they have, we must enable this code
again.

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

5 years agoBetter document specific OSSL_PARAM symbols.
Pauli [Mon, 17 Jun 2019 01:34:09 +0000 (11:34 +1000)]
Better document specific OSSL_PARAM symbols.

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

5 years agoAdd documentation for X509_cmp and related APIs
Paul Yang [Thu, 6 Jun 2019 03:42:02 +0000 (11:42 +0800)]
Add documentation for X509_cmp and related APIs

Fixes: #9088

Functions documented in this commit: X509_cmp, X509_NAME_cmp,
X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp,
X509_CRL_cmp, X509_CRL_match

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

5 years agoUse variables in build.info files where it's worth the while
Richard Levitte [Wed, 12 Jun 2019 10:10:00 +0000 (12:10 +0200)]
Use variables in build.info files where it's worth the while

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

5 years agoConfigure: Add support for variables in build.info files
Richard Levitte [Wed, 12 Jun 2019 10:03:31 +0000 (12:03 +0200)]
Configure: Add support for variables in build.info files

Variables have the syntax defined with this regular expression:

    \$([[:alpha:]_][[:alnum:]_]*)

They are always local to the build.info they are defined in, and are
defined like this:

    $VAR=text

Expansion is done very simply, any reference to the variable (with the
exact same variable syntax) is replaced with its defined value.

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

5 years agoFix building with enable-trace
Matt Caswell [Fri, 14 Jun 2019 08:07:29 +0000 (09:07 +0100)]
Fix building with enable-trace

Tracing doesn't work in the FIPS module. Ensure we switch it off there.

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

5 years agoFix no-dh
Matt Caswell [Thu, 13 Jun 2019 09:21:46 +0000 (10:21 +0100)]
Fix no-dh

The recent TLSv1.3 FFDHE support missed a few OPENSSL_NO_DH guards.

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

5 years agoUpdate the d2i docs to reflect reality
Matt Caswell [Wed, 12 Jun 2019 11:12:07 +0000 (12:12 +0100)]
Update the d2i docs to reflect reality

The d2i docs state that if an error occurs then |*a| is not freed. This
is not correct. On error it is freed and set to NULL. We update the docs
to say this, and also discuss the fact that this behaviour was inconsistent
prior to OpenSSL 1.1.0.

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

5 years agots: Fix awkward sentences in the documentation and the default digest
Tomas Mraz [Wed, 12 Jun 2019 10:01:19 +0000 (12:01 +0200)]
ts: Fix awkward sentences in the documentation and the default digest

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