oweals/openssl.git
6 years agoImprove error handling in pk7_doit
Matt Caswell [Mon, 12 Mar 2018 13:56:34 +0000 (13:56 +0000)]
Improve error handling in pk7_doit

If a mem allocation failed we would ignore it. This commit fixes it to
always check.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5596)

6 years agoAdd OIDs for DSTU-4145
gmile [Mon, 12 Mar 2018 00:52:13 +0000 (20:52 -0400)]
Add OIDs for DSTU-4145

Original source:
https://github.com/dstucrypt/openssl-dstu/commit/2c5fc4c92b8244c5026f4f871eb9497f9c28d5af

Full list of OIDs is available on related enactment page
at http://zakon2.rada.gov.ua/laws/show/z0423-17

CLA: trivial

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

6 years agoDon't negotiate TLSv1.3 with the ossl_shim
Matt Caswell [Mon, 12 Mar 2018 11:42:00 +0000 (11:42 +0000)]
Don't negotiate TLSv1.3 with the ossl_shim

The ossl_shim doesn't know about TLSv1.3 so we should disable that
protocol version for all tests for now.

This fixes the current Travis failures.

[extended tests]

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5593)

6 years agoSession Ticket app data
Todd Short [Wed, 15 Mar 2017 17:25:55 +0000 (13:25 -0400)]
Session Ticket app data

Adds application data into the encrypted session ticket

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

6 years agomem_sec.c: portability fixup.
Andy Polyakov [Sat, 10 Mar 2018 18:38:28 +0000 (19:38 +0100)]
mem_sec.c: portability fixup.

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoFix propotype to include the const qualifier
Kurt Roeckx [Sat, 10 Mar 2018 15:32:55 +0000 (16:32 +0100)]
Fix propotype to include the const qualifier

Reviewed-by: Andy Polyakov <appro@openssl.org>
GH: #5582

6 years agoFixed a handful of typos
Alex Gaynor [Sat, 10 Mar 2018 18:13:23 +0000 (13:13 -0500)]
Fixed a handful of typos

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5583)

6 years agoConfigurations/10-main.conf: VC-<target> cleanups.
Andy Polyakov [Fri, 9 Mar 2018 16:28:06 +0000 (17:28 +0100)]
Configurations/10-main.conf: VC-<target> cleanups.

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

6 years agoConfigurations/unix-Makefile.tmpl: overhaul assembler make rules.
Andy Polyakov [Fri, 9 Mar 2018 12:57:38 +0000 (13:57 +0100)]
Configurations/unix-Makefile.tmpl: overhaul assembler make rules.

So far assembly modules were built as .pl->.S->.s followed by .s->.o.
This posed a problem in build_all_generated rule if it was executed
on another computer. So we change rule sequence to .pl->.S and then
.S->.s->.o.

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

6 years agoConfigurations/descrip.mms.tmpl: Fix small errors
Richard Levitte [Fri, 9 Mar 2018 21:58:32 +0000 (22:58 +0100)]
Configurations/descrip.mms.tmpl: Fix small errors

A missing parenthesis here, a missing comma there...

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5579)

6 years agoConfigure: catch the build tree configdata.pm
Richard Levitte [Thu, 8 Mar 2018 11:01:28 +0000 (12:01 +0100)]
Configure: catch the build tree configdata.pm

There are things depending on configdata.pm.  However, it's perfectly
possible that there is one in the source directory from a previous
build, and that might disrupt an out of source build.  To avoid this
conflict, make sure never to use the source tree configdata.pm in that
case, i.e. make the hard assumption that it's a generated file in the
build tree, which it is.

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

6 years agoConfigure: don't mangle the directory again when checking DEPEND inclusion
Richard Levitte [Wed, 7 Mar 2018 14:58:04 +0000 (15:58 +0100)]
Configure: don't mangle the directory again when checking DEPEND inclusion

When generating the correct inclusion directory for DEPEND, we mangled
it to be relative to the build or the source directory.  However, the
value we handle already come with a correct directory, so we only need
to use it as is.

Fixes #5543

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

6 years agoRAND_DRBG: add a function for setting the reseeding defaults
Dr. Matthias St. Pierre [Fri, 9 Mar 2018 17:24:23 +0000 (18:24 +0100)]
RAND_DRBG: add a function for setting the reseeding defaults

The introduction of thread local public and private DRBG instances (#5547)
makes it very cumbersome to change the reseeding (time) intervals for
those instances. This commit provides a function to set the default
values for all subsequently created DRBG instances.

 int RAND_DRBG_set_reseed_defaults(
                                   unsigned int master_reseed_interval,
                                   unsigned int slave_reseed_interval,
                                   time_t master_reseed_time_interval,
                                   time_t slave_reseed_time_interval
                                   );

The function is intended only to be used during application initialization,
before any threads are created and before any random bytes are generated.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5576)

6 years agoAttempt to fix boringssl tests
Ben Kaduk [Fri, 9 Mar 2018 18:58:39 +0000 (12:58 -0600)]
Attempt to fix boringssl tests

Commit abe256e7951e6d57f8f6b4364ea696eb4ead3852 changed the config target
element from 'cxx' to 'CXX'; catch up accordingly.
Also use a space to offset the template boundary, per convention.

[extended tests]

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

6 years agoDocument more X509_STORE functions
Benjamin Kaduk [Mon, 17 Jul 2017 17:44:03 +0000 (12:44 -0500)]
Document more X509_STORE functions

X509_STORE_set_verify_cb_func.pod has documentation for various callbacks
and function pointers that can be set and retrieved, but neither it nor
X509_STORE_new has much documentation for the actual purpose and usage
of X509_STORE objects.  Remedy this disparity with new documentation
for adding certificates and CRLs, expected usage, and for modifying
the default verifification behavior.

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

6 years agoFix doc-nits
Ben Kaduk [Fri, 9 Mar 2018 16:33:19 +0000 (10:33 -0600)]
Fix doc-nits

Remove a space from a whitespace-only line.

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

6 years agoReuse extension_is_relevant() in should_add_extension()
Benjamin Kaduk [Tue, 14 Mar 2017 19:41:08 +0000 (14:41 -0500)]
Reuse extension_is_relevant() in should_add_extension()

At the core of things is the concept that each extension is only
defined in certain context(s) -- the ClientHello, EncryptedExtensions,
etc., and sometimes only for a specific protocol or protocol range;
we want to enforce that we only parse or generate extensions in the
context(s) for which they are defined.  There is some subtlety here,
in that the protocol version in use is not known when generating the
ClientHello (but it is known when the ClientHello extensions are
being parsed!), so the SSL_IS_TLS13() macro must be used with caution.
Nonetheless, by making assertions about whether we are acting in a
server role and whether the current context is (not) a ClientHello,
we can consolidate almost all of the logic for determining whether
an extension is permitted in a given protocol message, whether we
are generating or parsing that message.

The only logic that remains separate relates to generating the ClientHello,
as it depends on an external factor (the maximum permitted TLS version) that
is not defined in the parsing context.

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

6 years agoFix type error in PEM processing
Benjamin Kaduk [Tue, 30 Jan 2018 18:55:44 +0000 (12:55 -0600)]
Fix type error in PEM processing

The get_name() helper was using a variable of type size_t to hold the
result of BIO_gets(), but BIO_gets() returns int and makes use of negative
values to indicate error conditions.

Change the type of the local variable to match, and propagate that
through to other places in the file to avoid -Wsign-compare issues.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5211)

6 years agoAdd SSL/SSL_CTX_use_cert_and_key()
Todd Short [Mon, 28 Dec 2015 14:13:20 +0000 (09:13 -0500)]
Add SSL/SSL_CTX_use_cert_and_key()

Add functions that will do the work of assigning certificate, privatekey
and chain certs to an SSL or SSL_CTX. If no privatekey is given, use the
publickey. This will permit the keys to pass validation for both ECDSA
and RSA. If a private key has already been set for the certificate, it
is discarded. A real private key can be set later.

This is an all-or-nothing setting of these parameters. Unlike the
SSL/SSL_CTX_use_certificate() and SSL/SSL_CTX_use_PrivateKey() functions,
the existing cert or privatekey is not modified (i.e. parameters copied).
This permits the existing cert/privatekey to be replaced.

It replaces the sequence of:
* SSL_use_certificate()
* SSL_use_privatekey()
* SSL_set1_chain()
And may actually be faster, as multiple checks are consolidated.

The private key can be NULL, if so an ENGINE module needs to contain the
actual private key that is to be used.

Note that ECDH (using the certificate's ECDSA key) ciphers do not work
without the private key being present, based on how the private key is
used in ECDH. ECDH does not offer PFS; ECDHE ciphers should be used instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/1130)

6 years agoConfigurations/50-win-onecore.conf: add Windows 10 OneCore targets.
Andy Polyakov [Sat, 3 Mar 2018 22:09:52 +0000 (23:09 +0100)]
Configurations/50-win-onecore.conf: add Windows 10 OneCore targets.

This includes even ARM targets.

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

6 years agoConfigurations/windows-makefile.tmpl: simplify install-path "flavour"-ing.
Andy Polyakov [Sat, 3 Mar 2018 21:26:45 +0000 (22:26 +0100)]
Configurations/windows-makefile.tmpl: simplify install-path "flavour"-ing.

$target{build_scheme} consists of fixed number of elements with 3rd
element denoting VC install-path "flavour", i.e. where to install things.
Instead of looking at 3rd, let's look at last. This allows to override
flavour from template in a simple way.

Configurations/10-main.conf: define generic "flavour" in VC-common
template. Since VC-W32 was the only recognized "flavour", remove
"flavour" definitions from all targets/templates, but VC-WIN32. And
rename VC-W32 to VC-WOW.

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

6 years agoConfigurations/10-main.conf: amend out-dated comments.
Andy Polyakov [Thu, 8 Mar 2018 20:11:12 +0000 (21:11 +0100)]
Configurations/10-main.conf: amend out-dated comments.

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

6 years agoRestore the display of options with 'openssl version -a'
Richard Levitte [Fri, 9 Mar 2018 13:28:51 +0000 (14:28 +0100)]
Restore the display of options with 'openssl version -a'

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5572)

6 years agoDisplay the library building flags
Richard Levitte [Fri, 9 Mar 2018 11:39:01 +0000 (12:39 +0100)]
Display the library building flags

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5560)

6 years agoConfigure et al: Move the definition of library only flags
Richard Levitte [Tue, 6 Mar 2018 20:09:05 +0000 (21:09 +0100)]
Configure et al: Move the definition of library only flags

We're currently using the attributes 'defines', 'cppflags', 'cflags'
etc quite liberally, with no regard for where that ends up.  Quite a
few of those flags are actually only relevant for the libraries
(mostly libcrypto), so it's safe to say that those could be applied to
the libraries only.

So, we move some of those flags to 'lib_defines', 'lib_cppflags',
'lib_cflags', etc.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5560)

6 years agospeed: add ecdhx448 to ecdh choices
Steven Noonan [Fri, 9 Mar 2018 12:15:20 +0000 (07:15 -0500)]
speed: add ecdhx448 to ecdh choices

CLA: trivial
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5551)

6 years agoFixed a spelling mistake in ASN1_TIME_set.pod
Alex Gaynor [Fri, 9 Mar 2018 12:11:13 +0000 (07:11 -0500)]
Fixed a spelling mistake in ASN1_TIME_set.pod

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

6 years agoGive more information in the SSL_stateless return code
Matt Caswell [Thu, 8 Mar 2018 17:44:12 +0000 (17:44 +0000)]
Give more information in the SSL_stateless return code

Allow users to distinguish between an error occurring and an HRR being
issued.

Fixes #5549

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5562)

6 years agoTest the new PSK behaviour
Matt Caswell [Thu, 8 Mar 2018 13:45:22 +0000 (13:45 +0000)]
Test the new PSK behaviour

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5554)

6 years agoUpdate documentation for the new PSK behaviour
Matt Caswell [Thu, 8 Mar 2018 08:20:23 +0000 (08:20 +0000)]
Update documentation for the new PSK behaviour

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5554)

6 years agoFallback on old style PSK callbacks if the new style ones aren't present
Matt Caswell [Tue, 6 Mar 2018 16:41:51 +0000 (16:41 +0000)]
Fallback on old style PSK callbacks if the new style ones aren't present

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5554)

6 years agoTolerate TLSv1.3 PSKs that are a different size to the hash size
Matt Caswell [Tue, 6 Mar 2018 14:12:10 +0000 (14:12 +0000)]
Tolerate TLSv1.3 PSKs that are a different size to the hash size

We also default to SHA256 as per the spec if we do not have an explicit
digest defined.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5554)

6 years agoMake OCSP "multi" compatible with "no-sock" builds.
Viktor Dukhovni [Thu, 8 Mar 2018 15:51:46 +0000 (10:51 -0500)]
Make OCSP "multi" compatible with "no-sock" builds.

Reviewed-by: Matt Caswell <matt@openssl.org>
6 years agoRemove useless -D_ENDIAN from MPE/iX-gcc config
Richard Levitte [Thu, 8 Mar 2018 21:03:01 +0000 (22:03 +0100)]
Remove useless -D_ENDIAN from MPE/iX-gcc config

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5564)

6 years agoReduce travis-ci log output
Michael Richardson [Tue, 6 Mar 2018 19:18:43 +0000 (14:18 -0500)]
Reduce travis-ci log output

Travis-ci log output is huge and overflows internal travis-ci view,
which makes it hard to find errors.
Redirect some output to a file and dump it only if it fails.
Remove "v" option from tar that builds and extracts the srcdist.
While running the tests manually, some non-POSIX (bashisms) with ==
vs = came to light.

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

6 years agoConfigure: correct the check of env vars vs command line flags
Richard Levitte [Thu, 8 Mar 2018 17:49:37 +0000 (18:49 +0100)]
Configure: correct the check of env vars vs command line flags

The check to detect if env / make variables conflicted with compiler /
linker flags on the configure command line went a little too far, and
would stop the configuration process if any such command line flag was
given, with no regard for the env / make variables at all.

This change refines the check so the stop only gets triggered if any
such flags were given AND any of the corresponding variables are set.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5561)

6 years agoMake a few more asm modules conform: last argument is output file
Richard Levitte [Sat, 10 Feb 2018 07:47:51 +0000 (08:47 +0100)]
Make a few more asm modules conform: last argument is output file

Fixes #5310

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5315)

6 years agoConfigure: disallow the mixture of compiling flags and env / make variables
Richard Levitte [Thu, 8 Mar 2018 13:16:18 +0000 (14:16 +0100)]
Configure: disallow the mixture of compiling flags and env / make variables

Note that this might give surprising results if someone forgets an environment
variable that has been set previously.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoConfigurations/README: update documentation on flags
Richard Levitte [Wed, 7 Mar 2018 23:17:29 +0000 (00:17 +0100)]
Configurations/README: update documentation on flags

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoConfigure et al: get rid of last traces of plib_lflags / PLIB_LDFLAGS
Richard Levitte [Wed, 7 Mar 2018 23:16:47 +0000 (00:16 +0100)]
Configure et al: get rid of last traces of plib_lflags / PLIB_LDFLAGS

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoconfig: Pass diverse flags to Configure via the environment
Richard Levitte [Wed, 7 Mar 2018 21:44:59 +0000 (22:44 +0100)]
config: Pass diverse flags to Configure via the environment

Passing flags "discovered" by 'config' on the command line to
'Configure' mixes them up with flags given by the user.  That is
contrary to their intention, so they need to be passed in a different
manner.

Enter the environment variables __CNF_CPPDEFINES, __CNF_CPPINCLUDES,
__CNF_CPPFLAGS, __CNF_CFLAGS, __CNF_CXXFLAGS, __CNF_LDFLAGS, and
__CNF_LDLIBS, initialised by 'config', and then used by Configure to
initialise these %config values: defines, includes, cppflags, cflags,
cxxflags, lflags, and ex_libs.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoConfigurations/10-main.conf: Duplicate cflags to cxxflags
Richard Levitte [Wed, 7 Mar 2018 12:29:41 +0000 (13:29 +0100)]
Configurations/10-main.conf: Duplicate cflags to cxxflags

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoAdd space to asoutflag value where appropriate
Richard Levitte [Wed, 7 Mar 2018 12:29:04 +0000 (13:29 +0100)]
Add space to asoutflag value where appropriate

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoMake "make variables" config attributes for overridable flags
Richard Levitte [Tue, 6 Mar 2018 19:35:30 +0000 (20:35 +0100)]
Make "make variables" config attributes for overridable flags

With the support of "make variables" comes the possibility for the
user to override them.  However, we need to make a difference between
defaults that we use (and that should be overridable by the user) and
flags that are crucial for building OpenSSL (should not be
overridable).

Typically, overridable flags are those setting optimization levels,
warnings levels, that kind of thing, while non-overridable flags are,
for example, macros that indicate aspects of how the config target
should be treated, such as L_ENDIAN and B_ENDIAN.

We do that differentiation by allowing upper case attributes in the
config targets, named exactly like the "make variables" we support,
and reserving the lower case attributes for non-overridable project
flags.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoConfigure et al: rename all dso_* to module_* in shared-info.pl
Richard Levitte [Wed, 7 Mar 2018 19:31:15 +0000 (20:31 +0100)]
Configure et al: rename all dso_* to module_* in shared-info.pl

Because there are already attributes with the dso_ prefix that are
used instead of the corresponding lib_ attributes rather than in
addition to them, it gets confusing to have similar or exactly the
same attributes working with different semantics on Unix.

So we rename those by changing the prefix dso_ to module_, and having
those work just like the shared_ attributes, but for DSOs.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

6 years agoDuplicate entries ssl_handshake_tbl trace entries...
FdaSilvaYY [Thu, 8 Mar 2018 15:32:34 +0000 (10:32 -0500)]
Duplicate entries ssl_handshake_tbl trace entries...

... and add some missing known values.
Sort ssl/tls extension array list

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

6 years agoFix issues in ia32 RDRAND asm leading to reduced entropy
Bryan Donlan [Wed, 7 Mar 2018 21:01:06 +0000 (16:01 -0500)]
Fix issues in ia32 RDRAND asm leading to reduced entropy

This patch fixes two issues in the ia32 RDRAND assembly code that result in a
(possibly significant) loss of entropy.

The first, less significant, issue is that, by returning success as 0 from
OPENSSL_ia32_rdrand() and OPENSSL_ia32_rdseed(), a subtle bias was introduced.
Specifically, because the assembly routine copied the remaining number of
retries over the result when RDRAND/RDSEED returned 'successful but zero', a
bias towards values 1-8 (primarily 8) was introduced.

The second, more worrying issue was that, due to a mixup in registers, when a
buffer that was not size 0 or 1 mod 8 was passed to OPENSSL_ia32_rdrand_bytes
or OPENSSL_ia32_rdseed_bytes, the last (n mod 8) bytes were all the same value.
This issue impacts only the 64-bit variant of the assembly.

This change fixes both issues by first eliminating the only use of
OPENSSL_ia32_rdrand, replacing it with OPENSSL_ia32_rdrand_bytes, and fixes the
register mixup in OPENSSL_ia32_rdrand_bytes. It also adds a sanity test for
OPENSSL_ia32_rdrand_bytes and OPENSSL_ia32_rdseed_bytes to help catch problems
of this nature in the future.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5342)

6 years agoFixed several readability issues in DH_generate_parameters.pod
Alex Gaynor [Thu, 8 Mar 2018 12:59:50 +0000 (07:59 -0500)]
Fixed several readability issues in DH_generate_parameters.pod

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

6 years agoCorrected two typos in a man page
Alex Gaynor [Wed, 7 Mar 2018 19:01:05 +0000 (14:01 -0500)]
Corrected two typos in a man page

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

6 years agoAdd GOST OIDs for Edwards parameter sets
Sergey Zhuravlev [Wed, 7 Mar 2018 17:58:38 +0000 (12:58 -0500)]
Add GOST OIDs for Edwards parameter sets

Add OIDs for parameter sets of Edwards elliptic curves.

CLA: trivial

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

6 years agoRemove OPENSSL_USE_NODELETE guards in shlibloadtest
Matt Caswell [Tue, 6 Mar 2018 10:41:47 +0000 (10:41 +0000)]
Remove OPENSSL_USE_NODELETE guards in shlibloadtest

PR #3399 converted shlibloadtest to the new test framework. It also
seemed to add some `OPENSSL_USE_NODELETE` guards to the library
unloading part of the test. This part was added in a commit with this
description:

    Review feedback; use single main, #ifdef ADD_TEST

    Suppose OPENSSL_USE_NODELETE (via Nick Reilly)

Strangely though there doesn't seem to be any relevant review feedback
in that PR that could justify the addition of those guards. The guards
do not appear in 1.1.0.

Having the guards changes the nature of the test, so that we only test
library unloading on platforms where OPENSSL_USE_NODELETE is set (Linux
and Windows). I can't think of any good reason for this and as it doesn't
seem to be necessary in 1.1.0 so I think we should remove them.

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

6 years agoImplement multi-process OCSP responder.
Viktor Dukhovni [Mon, 5 Mar 2018 20:18:04 +0000 (15:18 -0500)]
Implement multi-process OCSP responder.

With "-multi" the OCSP responder forks multiple child processes,
and respawns them as needed.  This can be used as a long-running
service, not just a demo program.  Therefore the index file is
automatically re-read when changed.  The responder also now optionally
times out client requests.

Reviewed-by: Matt Caswell <matt@openssl.org>
6 years agoPrepare to detect index changes in OCSP responder.
Viktor Dukhovni [Mon, 5 Mar 2018 19:40:02 +0000 (14:40 -0500)]
Prepare to detect index changes in OCSP responder.

Retain open file handle and previous stat data for the CA index
file, enabling detection and index reload (upcoming commit).

Check requirements before entering accept loop.

Reviewed-by: Matt Caswell <matt@openssl.org>
6 years agoConfigurations/unix-Makefile.tmpl: remove assignment of AS and ASFLAGS
Richard Levitte [Wed, 7 Mar 2018 13:52:47 +0000 (14:52 +0100)]
Configurations/unix-Makefile.tmpl: remove assignment of AS and ASFLAGS

We have never used these variables with the Unix Makefile, and there's
no reason for us to change this, so to avoid confusion, we remove them.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5545)

6 years agoBIO_s_mem.pod: fix indirection for out parameter **pp
Dr. Matthias St. Pierre [Wed, 7 Mar 2018 13:37:23 +0000 (14:37 +0100)]
BIO_s_mem.pod: fix indirection for out parameter **pp

BIO_get_mem_data() and BIO_get_mem_ptr() assign to *pp, not pp

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5544)

6 years agocrypto/armcap.c: mask SHA512 hardware detection on iOS.
Andy Polyakov [Mon, 5 Mar 2018 16:10:03 +0000 (17:10 +0100)]
crypto/armcap.c: mask SHA512 hardware detection on iOS.

When running iOS application from command line it's impossible to
get past the failing capability detection. This is because it's
executed under debugger and iOS debugger is impossible to deal with.
[If Apple implements SHA512 in silicon, it would have to be detected
with sysctlbyname.]

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoConfigurations/10-main.conf: add -fno-common back to darwin-ppc-cc.
Andy Polyakov [Mon, 5 Mar 2018 15:55:48 +0000 (16:55 +0100)]
Configurations/10-main.conf: add -fno-common back to darwin-ppc-cc.

-fno-common was removed for all Darwin targets in
0c8734198d4282f6997965a03cd2e0ceaf207549 with rationale "it's either
'ranlib -c' or '-fno-common'." However, it's still absolutely required
in 32-bit darwin-ppc-cc. And when trying things out I didn't quite
see why it was formulated as one-or-another choice, as 'ranlib -c'
shouldn't [and doesn't] have problems with object modules without
commons. [Well, to be frank, I didn't manage to reproduce the problem
the modification was meaning to resolve either...]

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoutil/dofile.pl: only quote stuff that actually needs quoting
Richard Levitte [Tue, 6 Mar 2018 20:05:16 +0000 (21:05 +0100)]
util/dofile.pl: only quote stuff that actually needs quoting

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5533)

6 years agoopensslconf.h.in: Use all the "openssl_api_defines"
Richard Levitte [Tue, 6 Mar 2018 20:04:11 +0000 (21:04 +0100)]
opensslconf.h.in: Use all the "openssl_api_defines"

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5533)

6 years agoConfigure: fix small spelling error
Richard Levitte [Tue, 6 Mar 2018 20:03:21 +0000 (21:03 +0100)]
Configure: fix small spelling error

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5533)

6 years agoAvoid unconditional store in CRYPTO_malloc.
knekritz [Tue, 6 Mar 2018 18:21:49 +0000 (13:21 -0500)]
Avoid unconditional store in CRYPTO_malloc.

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

6 years agoFix a typo in the s_client man page
Alex Gaynor [Tue, 6 Mar 2018 18:07:33 +0000 (13:07 -0500)]
Fix a typo in the s_client man page

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5525)

6 years agoFix a bunch of gcc warnings in packettest.c
Bernd Edlinger [Mon, 5 Mar 2018 18:27:47 +0000 (19:27 +0100)]
Fix a bunch of gcc warnings in packettest.c

Had been observed with recent gcc-8 snapshot and
$ ./config --strict-warnings enable-asan

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5519)

6 years agoCheck the parent DRBG's strength
Kurt Roeckx [Sun, 4 Mar 2018 12:23:05 +0000 (13:23 +0100)]
Check the parent DRBG's strength

We currently don't support the algorithm from NIST SP 800-90C
10.1.2 to use a weaker DRBG as source

Reviewed-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
GH: #5506

6 years agobnrand_range: Always call bnrand() with the correct flag
Kurt Roeckx [Sun, 4 Mar 2018 23:29:21 +0000 (00:29 +0100)]
bnrand_range: Always call bnrand() with the correct flag

It was calling the BN_rand() when it should have call BN_priv_rand()

Reviewed-by: Tim Hudson <tjh@openssl.org>
GH: #5514

6 years agoAdd support for .include directive in config files
Tomas Mraz [Tue, 27 Feb 2018 12:55:35 +0000 (13:55 +0100)]
Add support for .include directive in config files

Either files or directories of *.cnf or *.conf files
can be included.
Recursive inclusion of directories is not supported.

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

6 years agoIf not sending key_share (no TLSv1.3), return appropriately.
Todd Short [Fri, 2 Mar 2018 14:36:28 +0000 (09:36 -0500)]
If not sending key_share (no TLSv1.3), return appropriately.

This fixes an issue raised in PR #4964 by kaduk.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5491)

6 years agoFix status_request and SCT extensions
Matt Caswell [Fri, 2 Mar 2018 15:02:11 +0000 (15:02 +0000)]
Fix status_request and SCT extensions

They are valid for use in a CertificateRequest message, but we did not
allow it. If a server sent such a message using either of those two
extensions then the handshake would abort.

This corrects that error, but does not add support for actually processing
the extensions. They are simply ignored, and a TODO is inserted to add
support at a later time.

This was found during interoperability testing with btls:
https://gitlab.com/ilari_l/btls

Prompted by these errors I reviewed the complete list of extensions and
compared them with the latest table in draft-24 to confirm there were no
other errors of a similar type. I did not find any.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5490)

6 years agoUpdate CHANGES for X448/Ed448 support in libssl
Matt Caswell [Tue, 27 Feb 2018 17:40:15 +0000 (17:40 +0000)]
Update CHANGES for X448/Ed448 support in libssl

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5470)

6 years agoUpdate tests for TLS Ed448
Matt Caswell [Tue, 27 Feb 2018 13:02:00 +0000 (13:02 +0000)]
Update tests for TLS Ed448

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5470)

6 years agoAdd X448/Ed448 support to libssl
Matt Caswell [Tue, 27 Feb 2018 10:12:02 +0000 (10:12 +0000)]
Add X448/Ed448 support to libssl

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5470)

6 years agoFixed a typo in a man page
Alex Gaynor [Sun, 4 Mar 2018 23:57:24 +0000 (18:57 -0500)]
Fixed a typo in a man page

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5508)

6 years agoFix credit for SRP code
Rich Salz [Sun, 4 Mar 2018 23:51:57 +0000 (18:51 -0500)]
Fix credit for SRP code

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

6 years agoWindows makefile: Don't quote generator arguments
Richard Levitte [Sat, 3 Mar 2018 22:07:14 +0000 (23:07 +0100)]
Windows makefile: Don't quote generator arguments

Rely on the build.info constructor to do the right thing.

Fixes #5500

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

6 years agotest/ctype_internal_test.c: portability fixup.
Andy Polyakov [Fri, 2 Mar 2018 15:50:41 +0000 (16:50 +0100)]
test/ctype_internal_test.c: portability fixup.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5493)

6 years agomem_sec.c: portability fixup.
Andy Polyakov [Fri, 2 Mar 2018 15:50:11 +0000 (16:50 +0100)]
mem_sec.c: portability fixup.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5493)

6 years agoec/curve448/f_generic.c: fix VC-WIN32 debug build failure.
Andy Polyakov [Fri, 2 Mar 2018 21:16:29 +0000 (22:16 +0100)]
ec/curve448/f_generic.c: fix VC-WIN32 debug build failure.

Debugging asserts had implicit casts that triggered the warnings.
However, instead of making the casts explicit it's more appropriate
to perform checks that ensure that implicit casts were safe.

ec/curve448/scalar.c: size_t-fy scalar_decode_short.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5494)

6 years agoec/curve448/curve448.c: fix undefined behaviour sanitizer failure.
Andy Polyakov [Fri, 2 Mar 2018 16:25:31 +0000 (17:25 +0100)]
ec/curve448/curve448.c: fix undefined behaviour sanitizer failure.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5494)

6 years agoFix a possible memory leak in engine_table_register
Bernd Edlinger [Fri, 2 Mar 2018 08:27:39 +0000 (09:27 +0100)]
Fix a possible memory leak in engine_table_register

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5489)

6 years agoFixed a typo in a man page
Alex Gaynor [Sat, 3 Mar 2018 16:37:07 +0000 (11:37 -0500)]
Fixed a typo in a man page

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5498)

6 years agoUpdate CHANGES for X448 and Ed448
Matt Caswell [Tue, 20 Feb 2018 15:27:15 +0000 (15:27 +0000)]
Update CHANGES for X448 and Ed448

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5481)

6 years agoAdd test vectors for X448 and Ed448
Matt Caswell [Fri, 1 Dec 2017 17:59:23 +0000 (17:59 +0000)]
Add test vectors for X448 and Ed448

This adds the Ed448 test vectors from RFC8032 and the X448 test vectors
from RFC7748.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5481)

6 years agoUpdate some documentation for X448/Ed448
Matt Caswell [Tue, 27 Feb 2018 17:28:48 +0000 (17:28 +0000)]
Update some documentation for X448/Ed448

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5481)

6 years agoIntegrate X448 and Ed448 into libcrypto
Matt Caswell [Wed, 28 Feb 2018 14:59:44 +0000 (14:59 +0000)]
Integrate X448 and Ed448 into libcrypto

This adds all of the relevant EVP plumbing required to make
X448 and Ed448 work.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5481)

6 years agoAdd pkey types for curve448
Matt Caswell [Tue, 28 Nov 2017 16:27:07 +0000 (16:27 +0000)]
Add pkey types for curve448

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5481)

6 years agoFix typo in ASN1_STRING_length doc
Ivan Filenko [Sun, 25 Feb 2018 13:49:27 +0000 (16:49 +0300)]
Fix typo in ASN1_STRING_length doc

CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5458)

6 years agoTest the result of CMS_RecipientInfo_ktri_get0_algs() before using its output in...
Brad Spencer [Wed, 20 Dec 2017 17:41:14 +0000 (13:41 -0400)]
Test the result of CMS_RecipientInfo_ktri_get0_algs() before using its output in rsa_cms_encrypt().

CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/4966)

6 years agoec/asm/x25519-x86_64.pl: remove redundant carry chain.
Andy Polyakov [Tue, 27 Feb 2018 18:02:21 +0000 (19:02 +0100)]
ec/asm/x25519-x86_64.pl: remove redundant carry chain.

Why is it redundant? We're looking at carry from addition of small,
11-bit number to 256-bit one. And carry would mean only one thing,
resulting first limb being small number and remaing ones - zeros.
Hence adding 38 to first limb can't carry.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5476)

6 years agoDo not set a nonzero default max_early_data
Benjamin Kaduk [Wed, 28 Feb 2018 20:49:59 +0000 (14:49 -0600)]
Do not set a nonzero default max_early_data

When early data support was first added, this seemed like a good
idea, as it would allow applications to just add SSL_read_early_data()
calls as needed and have things "Just Work".  However, for applications
that do not use TLS 1.3 early data, there is a negative side effect.
Having a nonzero max_early_data in a SSL_CTX (and thus, SSL objects
derived from it) means that when generating a session ticket,
tls_construct_stoc_early_data() will indicate to the client that
the server supports early data.  This is true, in that the implementation
of TLS 1.3 (i.e., OpenSSL) does support early data, but does not
necessarily indicate that the server application supports early data,
when the default value is nonzero.  In this case a well-intentioned
client would send early data along with its resumption attempt, which
would then be ignored by the server application, a waste of network
bandwidth.

Since, in order to successfully use TLS 1.3 early data, the application
must introduce calls to SSL_read_early_data(), it is not much additional
burden to require that the application also calls
SSL_{CTX_,}set_max_early_data() in order to enable the feature; doing
so closes this scenario where early data packets would be sent on
the wire but ignored.

Update SSL_read_early_data.pod accordingly, and make s_server and
our test programs into applications that are compliant with the new
requirements on applications that use early data.

Fixes #4725

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

6 years agoTell the ciphers which DRBG to use for generating random bytes.
Kurt Roeckx [Sun, 5 Nov 2017 13:37:15 +0000 (14:37 +0100)]
Tell the ciphers which DRBG to use for generating random bytes.

Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #4672

6 years agoFixed typo in description of EVP_CIPHER_meth_set_iv_length().
David Makepeace [Wed, 28 Feb 2018 06:30:32 +0000 (16:30 +1000)]
Fixed typo in description of EVP_CIPHER_meth_set_iv_length().

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5477)

6 years agoAdapt 15-test_out_option.t for more than just Unix
Richard Levitte [Thu, 22 Feb 2018 22:39:01 +0000 (23:39 +0100)]
Adapt 15-test_out_option.t for more than just Unix

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4008)

6 years agoEnable the -out option test on VMS as well
Richard Levitte [Thu, 22 Feb 2018 21:22:29 +0000 (22:22 +0100)]
Enable the -out option test on VMS as well

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4008)

6 years agoCheck on VMS as well
Richard Levitte [Mon, 29 Jan 2018 07:58:26 +0000 (08:58 +0100)]
Check on VMS as well

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4008)

6 years agoAdd VMS version of app_dirname()
Richard Levitte [Mon, 24 Jul 2017 21:32:00 +0000 (23:32 +0200)]
Add VMS version of app_dirname()

Related to #3709

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4008)

6 years agoFix the type of -out option
Paul Yang [Tue, 27 Feb 2018 02:47:16 +0000 (10:47 +0800)]
Fix the type of -out option

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

6 years agoAdd test cases for this -out option check
Paul Yang [Tue, 13 Feb 2018 12:15:34 +0000 (20:15 +0800)]
Add test cases for this -out option check

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

6 years agoCheck directory is able to create files for various -out option
Paul Yang [Wed, 21 Jun 2017 15:02:12 +0000 (23:02 +0800)]
Check directory is able to create files for various -out option

This is to address issue #3404, only works in Unix-like platforms

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

6 years agostoreutl: make sure s2i_ASN1_INTEGER is correctly declared
Richard Levitte [Wed, 28 Feb 2018 17:08:51 +0000 (18:08 +0100)]
storeutl: make sure s2i_ASN1_INTEGER is correctly declared

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

6 years agoAlways use adr with __thumb2__.
David Benjamin [Wed, 21 Feb 2018 23:50:21 +0000 (18:50 -0500)]
Always use adr with __thumb2__.

Thumb2 addresses are a bit a mess, depending on whether a label is
interpreted as a function pointer value (for use with BX and BLX) or as
a program counter value (for use with PC-relative addressing). Clang's
integrated assembler mis-assembles this code. See
https://crbug.com/124610#c54 for details.

Instead, use the ADR pseudo-instruction which has clear semantics and
should be supported by every assembler that handles the OpenSSL Thumb2
code. (In other files, the ADR vs SUB conditionals are based on
__thumb2__ already. For some reason, this one is based on __APPLE__, I'm
guessing to deal with an older version of clang assembler.)

It's unclear to me which of clang or binutils is "correct" or if this is
even a well-defined notion beyond "whatever binutils does". But I will
note that https://github.com/openssl/openssl/pull/4669 suggests binutils
has also changed behavior around this before.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5431)