oweals/openssl.git
8 years agoAdd documentation for SSL_has_pending()
Matt Caswell [Tue, 16 Feb 2016 10:36:18 +0000 (10:36 +0000)]
Add documentation for SSL_has_pending()

A previous commit added the SSL_has_pending() function which provides a
method for knowing whether OpenSSL has buffered, but as yet unprocessed
record data.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd pipelining documentation
Matt Caswell [Mon, 15 Feb 2016 15:45:18 +0000 (15:45 +0000)]
Add pipelining documentation

Add some documentation for all of the SSL/SSL_CTX functions/ctrls for
conrolling read and write pipelining.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix erroneous fall thgrough in switch statement
Matt Caswell [Mon, 15 Feb 2016 15:43:28 +0000 (15:43 +0000)]
Fix erroneous fall thgrough in switch statement

Fix an erroenous fall through when setting the max_pipelines value.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoEnsure s_client and s_server work when read_ahead is set
Matt Caswell [Fri, 12 Feb 2016 13:33:45 +0000 (13:33 +0000)]
Ensure s_client and s_server work when read_ahead is set

Previously s_client and s_server relied on using SSL_pending() which does
not take into account read_ahead. For read pipelining to work, read_ahead
gets set automatically. Therefore s_client and s_server have been
converted to use SSL_has_pending() instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd an SSL_has_pending() function
Matt Caswell [Fri, 12 Feb 2016 12:03:58 +0000 (12:03 +0000)]
Add an SSL_has_pending() function

This is similar to SSL_pending() but just returns a 1 if there is data
pending in the internal OpenSSL buffers or 0 otherwise (as opposed to
SSL_pending() which returns the number of bytes available). Unlike
SSL_pending() this will work even if "read_ahead" is set (which is the
case if you are using read pipelining, or if you are doing DTLS). A 1
return value means that we have unprocessed data. It does *not* necessarily
indicate that there will be application data returned from a call to
SSL_read(). The unprocessed data may not be application data or there
could be errors when we attempt to parse the records.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd an ability to set the SSL read buffer size
Matt Caswell [Wed, 13 Jan 2016 14:20:25 +0000 (14:20 +0000)]
Add an ability to set the SSL read buffer size

This capability is required for read pipelining. We will only read in as
many records as will fit in the read buffer (and the network can provide
in one go). The bigger the buffer the more records we can process in
parallel.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoLazily initialise the compression buffer
Matt Caswell [Wed, 13 Jan 2016 11:44:04 +0000 (11:44 +0000)]
Lazily initialise the compression buffer

With read pipelining we use multiple SSL3_RECORD structures for reading.
There are SSL_MAX_PIPELINES (32) of them defined (typically not all of these
would be used). Each one has a 16k compression buffer allocated! This
results in a significant amount of memory being consumed which, most of the
time, is not needed.  This change swaps the allocation of the compression
buffer to be lazy so that it is only done immediately before it is actually
used.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoImplement read pipeline support in libssl
Matt Caswell [Tue, 12 Jan 2016 14:52:35 +0000 (14:52 +0000)]
Implement read pipeline support in libssl

Read pipelining is controlled in a slightly different way than with write
pipelining. While reading we are constrained by the number of records that
the peer (and the network) can provide to us in one go. The more records
we can get in one go the more opportunity we have to parallelise the
processing.

There are two parameters that affect this:
* The number of pipelines that we are willing to process in one go. This is
controlled by max_pipelines (as for write pipelining)
* The size of our read buffer. A subsequent commit will provide an API for
adjusting the size of the buffer.

Another requirement for this to work is that "read_ahead" must be set. The
read_ahead parameter will attempt to read as much data into our read buffer
as the network can provide. Without this set, data is read into the read
buffer on demand. Setting the max_pipelines parameter to a value greater
than 1 will automatically also turn read_ahead on.

Finally, the read pipelining as currently implemented will only parallelise
the processing of application data records. This would only make a
difference for renegotiation so is unlikely to have a significant impact.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd dummy pipeline support for aes128_cbc_hmac_sha1
Matt Caswell [Fri, 27 Nov 2015 12:02:25 +0000 (12:02 +0000)]
Add dummy pipeline support for aes128_cbc_hmac_sha1

Add dummy pipline support to dasync for the aes128_cbc_hmac_sha1 cipher.
This is treated as an AEAD cipher.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd pipeline support to s_server and s_client
Matt Caswell [Tue, 22 Sep 2015 10:23:33 +0000 (11:23 +0100)]
Add pipeline support to s_server and s_client

Add the options min_send_frag and max_pipelines to s_server and s_client
in order to control pipelining capabilities. This will only have an effect
if a pipeline capable cipher is used (such as the one provided by the
dasync engine).

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoImplement write pipeline support in libssl
Matt Caswell [Tue, 22 Sep 2015 10:12:50 +0000 (11:12 +0100)]
Implement write pipeline support in libssl

Use the new pipeline cipher capability to encrypt multiple records being
written out all in one go. Two new SSL/SSL_CTX parameters can be used to
control how this works: max_pipelines and split_send_fragment.

max_pipelines defines the maximum number of pipelines that can ever be used
in one go for a single connection. It must always be less than or equal to
SSL_MAX_PIPELINES (currently defined to be 32). By default only one
pipeline will be used (i.e. normal non-parallel operation).

split_send_fragment defines how data is split up into pipelines. The number
of pipelines used will be determined by the amount of data provided to the
SSL_write call divided by split_send_fragment. For example if
split_send_fragment is set to 2000 and max_pipelines is 4 then:
SSL_write called with 0-2000 bytes == 1 pipeline used
SSL_write called with 2001-4000 bytes == 2 pipelines used
SSL_write called with 4001-6000 bytes == 3 pipelines used
SSL_write_called with 6001+ bytes == 4 pipelines used

split_send_fragment must always be less than or equal to max_send_fragment.
By default it is set to be equal to max_send_fragment. This will mean that
the same number of records will always be created as would have been
created in the non-parallel case, although the data will be apportioned
differently. In the parallel case data will be spread equally between the
pipelines.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoUpdate the dasync engine to add a pipeline cipher
Matt Caswell [Tue, 22 Sep 2015 10:11:24 +0000 (11:11 +0100)]
Update the dasync engine to add a pipeline cipher

Implement aes128-cbc as a pipeline capable cipher in the dasync engine.
As dasync is just a dummy engine, it actually just performs the parallel
encrypts/decrypts in serial.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoAdd defines for pipeline capable ciphers
Matt Caswell [Tue, 22 Sep 2015 10:08:25 +0000 (11:08 +0100)]
Add defines for pipeline capable ciphers

Add a flag to indicate that a cipher is capable of performing
"pipelining", i.e. multiple encrypts/decrypts in parallel. Also add some
new ctrls that ciphers will need to implement if they are pipeline capable.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agomake update
Matt Caswell [Mon, 7 Mar 2016 20:21:16 +0000 (20:21 +0000)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoTrim Travis config part 3
Emilia Kasper [Mon, 7 Mar 2016 14:15:20 +0000 (15:15 +0100)]
Trim Travis config part 3

- Only build & test two configurations. Make all the
  other build variants buildonly on gcc (clang on osx).
- Don't build with default clang at all on linux.
- Only use gcc-5 and clang-3.6 for the sanitizer builds. Re-running
  e.g. CONFIG_OPTS="shared" with them seems redundant.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRevert "Allow OPENSSL_NO_SOCK in e_os.h even for non-Windows/DOS platforms"
Rich Salz [Mon, 7 Mar 2016 20:32:18 +0000 (15:32 -0500)]
Revert "Allow OPENSSL_NO_SOCK in e_os.h even for non-Windows/DOS platforms"

This reverts commit 963bb62195109fb863dc4d88c7470ce7f9af25ac.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix pkeyutl to KDF lnks.
Rich Salz [Sat, 5 Mar 2016 06:13:58 +0000 (01:13 -0500)]
Fix pkeyutl to KDF lnks.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoRemove really old demo's
Rich Salz [Mon, 7 Mar 2016 19:55:44 +0000 (14:55 -0500)]
Remove really old demo's

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoElide OPENSSL_INIT_set_config_filename() for no-stdio build
David Woodhouse [Mon, 22 Feb 2016 16:44:46 +0000 (16:44 +0000)]
Elide OPENSSL_INIT_set_config_filename() for no-stdio build

Strictly speaking, it isn't stdio and file access which offend me here;
it's the fact that UEFI doesn't provide a strdup() function. But the
fact that it's pointless without file access is a good enough excuse for
compiling it out.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoElide DES_read_password() for no-ui build
David Woodhouse [Sun, 21 Feb 2016 16:19:44 +0000 (16:19 +0000)]
Elide DES_read_password() for no-ui build

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMove declaration of X509_aux_print() out of #ifndef OPENSSL_NO_STDIO
David Woodhouse [Sat, 20 Feb 2016 15:23:28 +0000 (15:23 +0000)]
Move declaration of X509_aux_print() out of #ifndef OPENSSL_NO_STDIO

This isn't a file access function; it's still present.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAllow OPENSSL_NO_SOCK in e_os.h even for non-Windows/DOS platforms
David Woodhouse [Sat, 20 Feb 2016 15:07:32 +0000 (15:07 +0000)]
Allow OPENSSL_NO_SOCK in e_os.h even for non-Windows/DOS platforms

UEFI needs this too. Don't keep it only in the Windows/DOS ifdef block.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoISSUE 43: Add BIO_sock_shutdown
Rich Salz [Wed, 2 Mar 2016 21:12:46 +0000 (16:12 -0500)]
ISSUE 43: Add BIO_sock_shutdown

This replaces SHUTDOWN/SHUTDOWN2 with BIO_closesocket.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoMinor update to includes and documentation for ct_test.c
Rob Percival [Mon, 7 Mar 2016 17:58:49 +0000 (17:58 +0000)]
Minor update to includes and documentation for ct_test.c

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove OPENSSL_NO_UNIT_TEST guard from ct_test.c
Rob Percival [Mon, 7 Mar 2016 17:58:14 +0000 (17:58 +0000)]
Remove OPENSSL_NO_UNIT_TEST guard from ct_test.c

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUse s->session->peer instead of calling SSL_get_peer_certificate(s)
Rob Percival [Mon, 7 Mar 2016 18:05:53 +0000 (18:05 +0000)]
Use s->session->peer instead of calling SSL_get_peer_certificate(s)

Avoids modifying certificate reference count, and thereby avoids locking.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoLowercase name of SSL_validate_ct as it is an internal function
Rob Percival [Mon, 7 Mar 2016 18:03:34 +0000 (18:03 +0000)]
Lowercase name of SSL_validate_ct as it is an internal function

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoCT code now calls X509_free() after calling SSL_get_peer_certificate()
Rob Percival [Mon, 7 Mar 2016 17:23:39 +0000 (17:23 +0000)]
CT code now calls X509_free() after calling SSL_get_peer_certificate()

Without this, the peer certificate would never be deleted, resulting in
a memory leak.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFixes memory leaks in CT code
Rob Percival [Mon, 7 Mar 2016 12:38:49 +0000 (12:38 +0000)]
Fixes memory leaks in CT code

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix the build tree include directory for afalg engine
Richard Levitte [Mon, 7 Mar 2016 17:58:25 +0000 (18:58 +0100)]
Fix the build tree include directory for afalg engine

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMake OpenSSL::Test::setup() a bit more forgiving
Richard Levitte [Sat, 5 Mar 2016 18:05:25 +0000 (19:05 +0100)]
Make OpenSSL::Test::setup() a bit more forgiving

It was unexpected that OpenSSL::Test::setup() should be called twice
by the same recipe.  However, that may happen if a recipe combines
OpenSSL::Test and OpenSSL::Test::Simple, which can be a sensible thing
to do.  Therefore, we now allow it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoElide EVP_read_pw_string() and friends for no-ui
David Woodhouse [Sun, 21 Feb 2016 11:36:52 +0000 (11:36 +0000)]
Elide EVP_read_pw_string() and friends for no-ui

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoGH768: Minor grammar nits in CRYPTO_get_ex_new_index.pod
Benjamin Kaduk [Tue, 15 Dec 2015 22:23:51 +0000 (16:23 -0600)]
GH768: Minor grammar nits in CRYPTO_get_ex_new_index.pod

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoUnified - adapt the generation of padlock assembler to use GENERATE
Richard Levitte [Mon, 7 Mar 2016 14:50:52 +0000 (15:50 +0100)]
Unified - adapt the generation of padlock assembler to use GENERATE

This gets rid of the BEGINRAW..ENDRAW sections in engines/build.info.

This also moves the assembler generating perl scripts to take the
output file name as last command line argument, where necessary.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUnified - adapt the generation of bignum assembler to use GENERATE
Richard Levitte [Mon, 7 Mar 2016 14:41:33 +0000 (15:41 +0100)]
Unified - adapt the generation of bignum assembler to use GENERATE

This gets rid of the BEGINRAW..ENDRAW sections in crypto/bn/build.info.

This also moves the assembler generating perl scripts to take the
output file name as last command line argument, where necessary.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUnified - Add the build.info command OVERRIDE, to avoid build file clashes
Richard Levitte [Mon, 7 Mar 2016 13:50:37 +0000 (14:50 +0100)]
Unified - Add the build.info command OVERRIDE, to avoid build file clashes

Should it be needed because the recipes within a RAW section might
clash with those generated by Configure, it's possible to tell it
not to generate them with the use of OVERRIDES, for example:

    SOURCE[libfoo]=foo.c bar.c

    OVERRIDES=bar.o
    BEGINRAW[Makefile(unix)]
    bar.o: bar.c
        $(CC) $(CFLAGS) -DSPECIAL -c -o $@ $<
    ENDRAW[Makefile(unix)]

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUnified - Adapt the Unix and VMS templates to support GENERATE
Richard Levitte [Mon, 7 Mar 2016 13:38:54 +0000 (14:38 +0100)]
Unified - Adapt the Unix and VMS templates to support GENERATE

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUnified - Add the build.info command GENERATE, to generate source files
Richard Levitte [Mon, 7 Mar 2016 13:37:00 +0000 (14:37 +0100)]
Unified - Add the build.info command GENERATE, to generate source files

In some cases, one might want to generate some source files from
others, that's done as follows:

    GENERATE[foo.s]=asm/something.pl $(CFLAGS)
    GENERATE[bar.s]=asm/bar.S

The value of each GENERATE line is a command line or part of it.
Configure places no rules on the command line, except the the first
item muct be the generator file.  It is, however, entirely up to the
build file template to define exactly how those command lines should
be handled, how the output is captured and so on.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd a function to detect if we have async or not
Matt Caswell [Mon, 7 Mar 2016 16:55:39 +0000 (16:55 +0000)]
Add a function to detect if we have async or not

Add the ASYNC_is_capable() function and use it in speed.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGH804: Fix unused-result warnings in dasync
Alessandro Ghedini [Mon, 7 Mar 2016 12:27:52 +0000 (12:27 +0000)]
GH804: Fix unused-result warnings in dasync

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agodocumentation and duplicate goto statements
Billy Brumley [Mon, 29 Feb 2016 20:35:35 +0000 (22:35 +0200)]
documentation and duplicate goto statements

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agomove ifdef statements
Billy Brumley [Mon, 29 Feb 2016 19:01:47 +0000 (21:01 +0200)]
move ifdef statements

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoNIST SP800-56A co-factor ECDH KATs
Billy Brumley [Mon, 29 Feb 2016 14:23:00 +0000 (16:23 +0200)]
NIST SP800-56A co-factor ECDH KATs

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove use of CRYPTO_LOCK_INIT in init code
Matt Caswell [Mon, 7 Mar 2016 14:39:22 +0000 (14:39 +0000)]
Remove use of CRYPTO_LOCK_INIT in init code

Swap the use of CRYPTO_LOCK_INIT in the init code to use the new threading
API mechanism for locking.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSwap the init code to use the new Thread API thread locals
Matt Caswell [Wed, 2 Mar 2016 15:23:57 +0000 (15:23 +0000)]
Swap the init code to use the new Thread API thread locals

The init code was using its own thread local code. Now we have a central
API for it we should use that instead.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSwap the init code to use CRYPTO_ONCE
Matt Caswell [Wed, 2 Mar 2016 14:51:00 +0000 (14:51 +0000)]
Swap the init code to use CRYPTO_ONCE

The init code was using its own "once" implementation. Now that we have
the new thread API we should use that instead.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agomake update
Dr. Stephen Henson [Mon, 7 Mar 2016 15:25:56 +0000 (15:25 +0000)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate documentation
Dr. Stephen Henson [Fri, 4 Mar 2016 03:51:35 +0000 (03:51 +0000)]
Update documentation

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMake PKCS8_PRIV_KEY_INFO opaque.
Dr. Stephen Henson [Fri, 4 Mar 2016 03:48:39 +0000 (03:48 +0000)]
Make PKCS8_PRIV_KEY_INFO opaque.

Make PKCS8_PRIV_KEY_INFO opaque. Several accessor functions already exist
for this structure. Two new ones were added to handle attributes.

The old handling of broken formats has been removed and the corresponding
structures simplified.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd support to ASYNC_WAIT_CTX to speed
Andrea Grandi [Mon, 29 Feb 2016 11:28:55 +0000 (11:28 +0000)]
Add support to ASYNC_WAIT_CTX to speed

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemove unnecessary memset() to 0 and check for NULL before OPENSSL_free()
Andrea Grandi [Sat, 27 Feb 2016 06:14:49 +0000 (06:14 +0000)]
Remove unnecessary memset() to 0 and check for NULL before OPENSSL_free()

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix the error with RSA and the daysnc engine in async mode.
Andrea Grandi [Thu, 18 Feb 2016 10:56:53 +0000 (10:56 +0000)]
Fix the error with RSA and the daysnc engine in async mode.

Move RSA struct in the job local struct.
The change is applied also to other crypto operations (e.g. DSA) to
make things consistent.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd support for async jobs in OpenSSL speed
Andrea Grandi [Wed, 9 Dec 2015 07:26:38 +0000 (07:26 +0000)]
Add support for async jobs in OpenSSL speed

Summary of the changes:

* Move the calls to the crypto operations inside wrapper functions.
  This is required because ASYNC_start_job takes a function as an argument.

* Add new function run_benchmark() that manages the jobs for all the operations.
  In the POSIX case it uses a select() to receive the events from the engine
  and resume the jobs that are paused, while in the WIN case it uses PeekNamedPipe()

* Add new option argument async_jobs to enable and specify the number of async jobs

Example:
  openssl speed -engine dasync -elapsed -async_jobs 32 rsa2048

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRework the default cipherlist.
Emilia Kasper [Thu, 3 Mar 2016 18:50:03 +0000 (19:50 +0100)]
Rework the default cipherlist.

 - Always prefer forward-secure handshakes.
 - Consistently order ECDSA above RSA.
 - Next, always prefer AEADs to non-AEADs, irrespective of strength.
 - Within AEADs, prefer GCM > CHACHA > CCM for a given strength.
 - Prefer TLS v1.2 ciphers to legacy ciphers.
 - Remove rarely used DSS, IDEA, SEED, CAMELLIA, CCM from the default
   list to reduce ClientHello bloat.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMakefile.in: populate [PLIB_]LDFLAG even with $target{} settings.
Andy Polyakov [Sun, 6 Mar 2016 13:36:11 +0000 (14:36 +0100)]
Makefile.in: populate [PLIB_]LDFLAG even with $target{} settings.

RT#4373

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agobn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.
Andy Polyakov [Fri, 4 Mar 2016 10:39:11 +0000 (11:39 +0100)]
bn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.

Some OSes, *cough*-dows, insist on stack being "wired" to
physical memory in strictly sequential manner, i.e. if stack
allocation spans two pages, then reference to farmost one can
be punishable by SEGV. But page walking can do good even on
other OSes, because it guarantees that villain thread hits
the guard page before it can make damage to innocent one...

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRestore some mingw builds
Emilia Kasper [Mon, 7 Mar 2016 11:59:40 +0000 (12:59 +0100)]
Restore some mingw builds

"no-pic" builds have in fact been green (and reasonably fast), so
restore them while we figure out why tests without "no-pic" hang.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoperlasm/x86_64-xlate.pl: handle binary constants early.
Andy Polyakov [Fri, 4 Mar 2016 10:32:26 +0000 (11:32 +0100)]
perlasm/x86_64-xlate.pl: handle binary constants early.

Not all assemblers of "gas" flavour handle binary constants, e.g.
seasoned MacOS Xcode doesn't, so give them a hand.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix some clang warnings
Matt Caswell [Mon, 7 Mar 2016 12:36:20 +0000 (12:36 +0000)]
Fix some clang warnings

The af_alg engine and associated test were creating warnings when compiled
with clang. This fixes it.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix minor errors in the afalg test
Matt Caswell [Thu, 3 Mar 2016 14:56:10 +0000 (14:56 +0000)]
Fix minor errors in the afalg test

The new afalg test should have a copyright date of 2016. Also an
incorrect buffer was being sent to EVP_CipherFinal_ex when
decrypting.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdding afalg test
clucey [Thu, 3 Mar 2016 05:56:10 +0000 (05:56 +0000)]
Adding afalg test

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix OPENSSL_INIT flags to avoid a clash.
Matt Caswell [Mon, 29 Feb 2016 16:14:00 +0000 (16:14 +0000)]
Fix OPENSSL_INIT flags to avoid a clash.

The 0x00010000L OPENSSL_INIT flag appeared twice.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoMisc afalg build fixes
Matt Caswell [Mon, 29 Feb 2016 13:36:47 +0000 (13:36 +0000)]
Misc afalg build fixes

Misc afalg build fixes as suggested by Richard Levitte for the latest
Configure changes.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRework based on feedback:
clucey [Tue, 23 Feb 2016 08:01:01 +0000 (08:01 +0000)]
Rework based on feedback:
1. Cleaned up eventfd handling
2. Reworked socket setup code to allow other algorithms to be added in
   future
3. Fixed compile errors for static build
4. Added error to error stack in all cases of ALG_PERR/ALG_ERR
5. Called afalg_aes_128_cbc() from bind() to avoid race conditions
6. Used MAX_INFLIGHT define in io_getevents system call
7. Coding style fixes

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoALG: Add AFALG engine
clucey [Wed, 17 Feb 2016 13:38:36 +0000 (13:38 +0000)]
ALG: Add AFALG engine

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoTrim Travis config part 2
Emilia Kasper [Sun, 6 Mar 2016 21:31:18 +0000 (22:31 +0100)]
Trim Travis config part 2

- Remove Win builds (temporarily). They're slow, allowed to fail,
  and therefore not useful as they are.
- Make the --unified part of the matrix build-only. (This can be
  swapped if --unified becomes the default)
- Only build 'no-engine' once, don't run any tests, but don't allow it
  to fail.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoTrim the Travis config
Emilia Kasper [Sun, 6 Mar 2016 20:59:53 +0000 (21:59 +0100)]
Trim the Travis config

- Remove no-asm. We've got to cut something, and this is at least
  partially covered by the sanitizer builds.
- Remove enable-crypto-mdebug from sanitizer
  builds. enable-crypto-mdebug has been shown to catch some static
  initialization bugs that the standard leak sanitizer can't so
  perhaps it has _some_ value; but we shouldn't let the two compete.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoGH616: Remove dead code
Rich Salz [Sat, 5 Mar 2016 06:00:50 +0000 (01:00 -0500)]
GH616: Remove dead code

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoNo -fno-common for Darwin
Richard Levitte [Fri, 4 Mar 2016 12:48:59 +0000 (13:48 +0100)]
No -fno-common for Darwin

When object files with common block symbols are added to static
libraries on Darwin, those symbols are invisible to the linker that
tries to use them.  Our solution was to use -fno-common when compiling
C source.

Unfortunately, there is assembler code that defines OPENSSL_ia32cap_P
as a common block symbol, unconditionally, and in some cases, there is
no other definition.  -fno-common doesn't help in this case.

However, 'ranlib -c' adds common block symbols to the index of the
static library, which makes them visible to the linker using it, and
that solves the problem we've seen.

The common conclusion is, either use -fno-common or ranlib -c on
Darwin.  Since we have common block symbols unconditionally, choosing
the method for our source is easy.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoNew ordinal files, recreated from scratch
Richard Levitte [Thu, 3 Mar 2016 11:42:37 +0000 (12:42 +0100)]
New ordinal files, recreated from scratch

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoChange names of ordinals and libs, libeay => libcrypto and ssleay => libssl
Richard Levitte [Thu, 3 Mar 2016 11:42:01 +0000 (12:42 +0100)]
Change names of ordinals and libs, libeay => libcrypto and ssleay => libssl

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove the old ordinals
Richard Levitte [Thu, 3 Mar 2016 11:24:09 +0000 (12:24 +0100)]
Remove the old ordinals

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agouse saner default parameters for scrypt
Dr. Stephen Henson [Fri, 4 Mar 2016 23:28:45 +0000 (23:28 +0000)]
use saner default parameters for scrypt

Thanks to Colin Percival for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDisable SSLv3 by default
Kurt Roeckx [Thu, 3 Mar 2016 21:45:57 +0000 (22:45 +0100)]
Disable SSLv3 by default

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Kasper <emilia@openssl.org>
MR: #2203

8 years agoDon't mark the eNULL ciphers as non-default.
Kurt Roeckx [Thu, 3 Mar 2016 21:02:58 +0000 (22:02 +0100)]
Don't mark the eNULL ciphers as non-default.

They're not part of ALL, so they're not part of COMPLEMENTOFDEFAULT

Reviewed-by: Rich Salz <rsalz@openssl.org>
MR: #2202

8 years agoCurve25519: fix const-initialization
Emilia Kasper [Fri, 4 Mar 2016 17:05:35 +0000 (18:05 +0100)]
Curve25519: fix const-initialization

Clang is permissive of this, but gcc fails.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd ASN.1 ADB callback.
Dr. Stephen Henson [Fri, 4 Mar 2016 14:55:24 +0000 (14:55 +0000)]
Add ASN.1 ADB callback.

Add support for application supplied any defined by callback. An
application can change the selector value if it wishes. This is
mainly intended for values which are only known at runtime, for
example dynamically created OIDs.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGH784: Better variable name
Dmitry-Me [Fri, 4 Mar 2016 07:34:47 +0000 (10:34 +0300)]
GH784: Better variable name

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoMake formatting consistent in apps/Makefile.in
Rob Percival [Fri, 4 Mar 2016 15:30:33 +0000 (15:30 +0000)]
Make formatting consistent in apps/Makefile.in

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove redundant semi-colons from apps/Makefile.in
Rob Percival [Fri, 4 Mar 2016 13:18:24 +0000 (13:18 +0000)]
Remove redundant semi-colons from apps/Makefile.in

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDocumentation for new CT s_client flags
Rob Percival [Thu, 3 Mar 2016 14:07:28 +0000 (14:07 +0000)]
Documentation for new CT s_client flags

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDocumentation for new SSL functions
Rob Percival [Thu, 3 Mar 2016 18:39:30 +0000 (18:39 +0000)]
Documentation for new SSL functions

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoHandle empty log name in "enable_logs" line of the CT log file
Rob Percival [Thu, 3 Mar 2016 16:08:55 +0000 (16:08 +0000)]
Handle empty log name in "enable_logs" line of the CT log file

e.g. "enabled_logs = foo,,bar"

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoHandle missing "enabled_logs" line in CT log file
Rob Percival [Thu, 3 Mar 2016 16:08:01 +0000 (16:08 +0000)]
Handle missing "enabled_logs" line in CT log file

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoIf a CT log entry in CTLOG_FILE is invalid, skip it and continue loading
Rob Percival [Thu, 3 Mar 2016 16:06:59 +0000 (16:06 +0000)]
If a CT log entry in CTLOG_FILE is invalid, skip it and continue loading

Previously, the remaining CT log entries would not be loaded.
Also, CTLOG_STORE_load_file would return 1 even if a log entry was
invalid, resulting in no errors being shown.

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoExtends s_client to allow a basic CT policy to be enabled
Rob Percival [Wed, 2 Mar 2016 13:34:05 +0000 (13:34 +0000)]
Extends s_client to allow a basic CT policy to be enabled

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoChange default CT log list filename to "ct_log_list.cnf"
Rob Percival [Fri, 4 Mar 2016 13:18:54 +0000 (13:18 +0000)]
Change default CT log list filename to "ct_log_list.cnf"

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdds CT validation to SSL connections
Rob Percival [Thu, 3 Mar 2016 16:19:23 +0000 (16:19 +0000)]
Adds CT validation to SSL connections

Disabled by default, but can be enabled by setting the
ct_validation_callback on a SSL or SSL_CTX.

Reviewed-by: Ben Laurie <ben@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoChanges to DEFAULT curves
Rich Salz [Sun, 3 Jan 2016 18:24:32 +0000 (13:24 -0500)]
Changes to DEFAULT curves

Change the ECC default curve list to be this, in order: x25519, secp256r1,
secp521r1, secp384r1, brainpoolP256r1, brainpoolP384r1, and brainpool512r1.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoCurve25519: avoid undefined behaviour
Emilia Kasper [Wed, 2 Mar 2016 22:50:58 +0000 (23:50 +0100)]
Curve25519: avoid undefined behaviour

Appease the sanitizer: avoid left shifts of negative values.

This could've been done entirely with casts to uint and back,
but using masks seemed slightly more readable.

There are also implementation-defined signed right shifts in this
code. Those remain.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agochacha/asm/chacha-ppc.pl: fix typo.
Andy Polyakov [Wed, 2 Mar 2016 11:43:09 +0000 (12:43 +0100)]
chacha/asm/chacha-ppc.pl: fix typo.

RT#4365

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDon't build RC4 ciphersuites into libssl by default
Matt Caswell [Thu, 3 Mar 2016 15:40:51 +0000 (15:40 +0000)]
Don't build RC4 ciphersuites into libssl by default

RC4 based ciphersuites in libssl have been disabled by default. They can
be added back by building OpenSSL with the "enable-weak-ssl-ciphers"
Configure option at compile time.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoImproved HKDF and TLS1-PRF documentation
Viktor Dukhovni [Fri, 4 Mar 2016 04:30:42 +0000 (23:30 -0500)]
Improved HKDF and TLS1-PRF documentation

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoCorrection, $disabled{shared} rather than $config{no_shared}
Richard Levitte [Fri, 4 Mar 2016 04:43:15 +0000 (05:43 +0100)]
Correction, $disabled{shared} rather than $config{no_shared}

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRestore the zlib / zlib-dynamic logic
Richard Levitte [Thu, 3 Mar 2016 09:07:29 +0000 (10:07 +0100)]
Restore the zlib / zlib-dynamic logic

The proper logic is that both zlib and zlib-dynamic are disabled by
default and that enabling zlib-dynamic would enable zlib.  Somewhere
along the way, the logic got changed, zlib-dynamic was enabled by
default and zlib didn't get automatically enabled.

This change restores the original logic.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoSanity check PVK file fields.
Dr. Stephen Henson [Thu, 3 Mar 2016 23:37:36 +0000 (23:37 +0000)]
Sanity check PVK file fields.

PVK files with abnormally large length or salt fields can cause an
integer overflow which can result in an OOB read and heap corruption.
However this is an rarely used format and private key files do not
normally come from untrusted sources the security implications not
significant.

Fix by limiting PVK length field to 100K and salt to 10K: these should be
more than enough to cover any files encountered in practice.

Issue reported by Guido Vranken.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGH773: Possible leak on CRYPTO_THREAD_lock_new failure
FdaSilvaYY [Tue, 1 Mar 2016 20:59:48 +0000 (21:59 +0100)]
GH773: Possible leak on CRYPTO_THREAD_lock_new failure

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoGH781: openssl.spec: use secure urls
Viktor Szakats [Thu, 3 Mar 2016 09:56:30 +0000 (10:56 +0100)]
GH781: openssl.spec: use secure urls

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoGH769: Reuse strndup()
Dmitry-Me [Tue, 1 Mar 2016 08:48:15 +0000 (11:48 +0300)]
GH769: Reuse strndup()

Reviewed-by: Matt Caswell <matt@openssl.org>
Signed-off-by: Rich Salz <rsalz@akamai.com>
8 years agoGH355: Implement HKDF
Alessandro Ghedini [Wed, 2 Mar 2016 23:58:27 +0000 (23:58 +0000)]
GH355: Implement HKDF

This patch implements the HMAC-based Extract-and-Expand Key Derivation
Function (HKDF) as defined in RFC 5869.

It is required to implement the QUIC and TLS 1.3 protocols (among others).

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>