oweals/openssl.git
6 years agoVMS: add alias macros to avoid 31 character symbol name limit warning
Richard Levitte [Thu, 15 Mar 2018 19:01:11 +0000 (20:01 +0100)]
VMS: add alias macros to avoid 31 character symbol name limit warning

Affected symbol names:

generate_stateless_cookie_callback
verify_stateless_cookie_callback

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

6 years agoWindows makefile: don't use different looking variants of same cmd
Richard Levitte [Thu, 15 Mar 2018 20:37:32 +0000 (21:37 +0100)]
Windows makefile: don't use different looking variants of same cmd

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

6 years agoPublish the RAND_DRBG API
Dr. Matthias St. Pierre [Mon, 5 Mar 2018 22:45:44 +0000 (23:45 +0100)]
Publish the RAND_DRBG API

Fixes #4403

This commit moves the internal header file "internal/rand.h" to
<openssl/rand_drbg.h>, making the RAND_DRBG API public.
The RAND_POOL API remains private, its function prototypes were
moved to "internal/rand_int.h" and converted to lowercase.

Documentation for the new API is work in progress on GitHub #5461.

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

6 years agoAdd code to run test, get malloc counts
Rich Salz [Thu, 15 Mar 2018 14:51:17 +0000 (10:51 -0400)]
Add code to run test, get malloc counts

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

6 years agoutil/postprocess-makedepend.pl: make an effort to collect dependencies
Richard Levitte [Wed, 14 Mar 2018 12:24:12 +0000 (13:24 +0100)]
util/postprocess-makedepend.pl: make an effort to collect dependencies

Instead of just working line by line, we collect all dependencies for
every target and print everything out at the end, with each target
getting a potentially long list of dependencies.

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

6 years agoutil/postprocess-makedepend.pl: For VC, don't include system headers
Richard Levitte [Wed, 14 Mar 2018 09:37:26 +0000 (10:37 +0100)]
util/postprocess-makedepend.pl: For VC, don't include system headers

All dependencies that VC gives us are absolute paths, so we need to
check if some of them are within our source or build tree.  We do that
by comparing the start of each dependency with the absolute versions
of our source and build directories.

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

6 years agoStreamline dependency generation
Richard Levitte [Mon, 12 Mar 2018 08:18:44 +0000 (09:18 +0100)]
Streamline dependency generation

It seems that only gcc -MMD produces dependency files that are "sane"
for our needs.  For all other methods, some post processing is needed:

- 'makedepend' (Unix) insists that object files are located in the
  same spot as the source file.
- 'cl /Zs /showIncludes' (Visual C) has "Note: including file: " where
  we'd like to see the object.
- 'CC/DECC' (VMS) insists that the object file is located in the
  current directory, i.e. it strips away all directory information.

So far, we've managed this (except for the VMS case) with individual
uncommented perl command lines directly in the build file template.
We're now collecting these diverse hacks into one perl script that
takes an argument to tell what kind of input to expect and that
massages whatever it gets on STDIN and outputs the result on STDOUT.

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

6 years agoFix no-chacha and no-poly1305
Matt Caswell [Thu, 15 Mar 2018 08:45:22 +0000 (08:45 +0000)]
Fix no-chacha and no-poly1305

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

6 years agoFix a memory leak in the ca application
Matt Caswell [Wed, 14 Mar 2018 14:32:48 +0000 (14:32 +0000)]
Fix a memory leak in the ca application

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

6 years agoAllow multiple entries without a Subject even if unique_subject == yes
Matt Caswell [Fri, 23 Feb 2018 19:48:11 +0000 (19:48 +0000)]
Allow multiple entries without a Subject even if unique_subject == yes

It is quite likely for there to be multiple certificates with empty
subjects, which are still distinct because of subjectAltName. Therefore
we allow multiple certificates with an empty Subject even if
unique_subject is set to yes.

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

6 years agoReport a readable error on a duplicate cert in ca app
Matt Caswell [Fri, 23 Feb 2018 18:28:47 +0000 (18:28 +0000)]
Report a readable error on a duplicate cert in ca app

Commit 87e8feca (16 years ago!) introduced a bug where if we are
attempting to insert a cert with a duplicate subject name, and
duplicate subject names are not allowed (which is the default),
then we get an unhelpful error message back (error number 2). Prior
to that commit we got a helpful error message which displayed details
of the conflicting entry in the database.

That commit was itself attempting to fix a bug with the noemailDN option
where we were setting the subject field in the database too early
(before extensions had made any amendments to it).

This PR moves the check for a conflicting Subject name until after all
changes to the Subject have been made by extensions etc.

This also, co-incidentally fixes the ca crashing bug described in issue
5109.

Fixes #5109

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

6 years agoRevert "Don't allow an empty Subject when creating a Certificate"
Matt Caswell [Fri, 23 Feb 2018 09:46:30 +0000 (09:46 +0000)]
Revert "Don't allow an empty Subject when creating a Certificate"

This reverts commit e505f1e86874acfd98826d64c53bf2ddfd9c1399.

Empty Subjects should be permissible.

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

6 years agoRevert "Don't crash on a missing Subject in index.txt"
Matt Caswell [Fri, 23 Feb 2018 09:46:06 +0000 (09:46 +0000)]
Revert "Don't crash on a missing Subject in index.txt"

This reverts commit 1e05c6d07ff963107286d028f6778d2ccc863a9a.

Empty subjects should be permissible.

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

6 years agoRename EVP_PKEY_new_private_key()/EVP_PKEY_new_public_key()
Matt Caswell [Thu, 15 Mar 2018 12:19:16 +0000 (12:19 +0000)]
Rename EVP_PKEY_new_private_key()/EVP_PKEY_new_public_key()

Renamed to EVP_PKEY_new_raw_private_key()/EVP_new_raw_public_key() as per
feedback.

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

6 years agoAdd functions for setting the new EVP_PKEY_ASN1_METHOD functions
Matt Caswell [Fri, 9 Mar 2018 11:02:28 +0000 (11:02 +0000)]
Add functions for setting the new EVP_PKEY_ASN1_METHOD functions

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

6 years agoMake sure all errors go on the stack in the EVP_PKEY_new*() functions
Matt Caswell [Mon, 5 Mar 2018 19:26:36 +0000 (19:26 +0000)]
Make sure all errors go on the stack in the EVP_PKEY_new*() functions

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

6 years agoExpand the 25519/448 overview man pages
Matt Caswell [Mon, 5 Mar 2018 19:16:35 +0000 (19:16 +0000)]
Expand the 25519/448 overview man pages

Include more information about how to create keys for these algorithms.

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

6 years agoAdd some test vectors for testing raw 448/25519 keys
Matt Caswell [Mon, 5 Mar 2018 18:39:44 +0000 (18:39 +0000)]
Add some test vectors for testing raw 448/25519 keys

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

6 years agoAdd PrivateKeyRaw and PublicKeyRaw support to evp_test
Matt Caswell [Fri, 1 Dec 2017 17:57:42 +0000 (17:57 +0000)]
Add PrivateKeyRaw and PublicKeyRaw support to evp_test

Previously private and public keys had to be pem encoded to be read by
evp_test. This enables us to embed the raw private/public key values
in the test file. The algorithm has to support EVP_PKEY_new_private_key()
and EVP_PKEY_new_public_key() for this to work.

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

6 years agoAdd documentation for the newly added EVP_PKEY_new*() functions
Matt Caswell [Mon, 5 Mar 2018 17:41:49 +0000 (17:41 +0000)]
Add documentation for the newly added EVP_PKEY_new*() functions

Also adds some documentation for related existing functions/macros

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

6 years agoUpdate the tests to use the new EVP_PKEY_new_private_key() function
Matt Caswell [Mon, 5 Mar 2018 16:22:41 +0000 (16:22 +0000)]
Update the tests to use the new EVP_PKEY_new_private_key() function

Also to use the new EVP_PKEY_new_CMAC_key()

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

6 years agoAdd the function EVP_PKEY_new_CMAC_key()
Matt Caswell [Mon, 5 Mar 2018 17:23:57 +0000 (17:23 +0000)]
Add the function EVP_PKEY_new_CMAC_key()

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

6 years agoAdd support for setting raw private Poly1305 keys
Matt Caswell [Mon, 5 Mar 2018 16:22:24 +0000 (16:22 +0000)]
Add support for setting raw private Poly1305 keys

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

6 years agoAdd support for setting raw private SIPHASH keys
Matt Caswell [Mon, 5 Mar 2018 16:17:24 +0000 (16:17 +0000)]
Add support for setting raw private SIPHASH keys

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

6 years agoAdd support for setting raw private HMAC keys
Matt Caswell [Mon, 5 Mar 2018 15:13:43 +0000 (15:13 +0000)]
Add support for setting raw private HMAC keys

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

6 years agoAdd support for setting raw private/public 25519/448 keys
Matt Caswell [Mon, 5 Mar 2018 13:58:46 +0000 (13:58 +0000)]
Add support for setting raw private/public 25519/448 keys

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

6 years agoAdd functions to create an EVP_PKEY from raw private/public key data
Matt Caswell [Mon, 5 Mar 2018 14:06:41 +0000 (14:06 +0000)]
Add functions to create an EVP_PKEY from raw private/public key data

Not all algorithms will support this, since their keys are not a simple
block of data. But many can.

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

6 years agoConfigure: allow to enable afalgeng if target does not start with Linux
Sebastian Andrzej Siewior [Thu, 25 Jan 2018 21:50:55 +0000 (22:50 +0100)]
Configure: allow to enable afalgeng if target does not start with Linux

The Debian build system uses a `debian' target which sets CFLAGS and
then we have for instance debian-amd64 which inherits from
linux-x86_64 and debian [0]. So far so good.

Unless there are different suggestions how to do this, I would keep it.
However since the target name does not start with `linux', the build
system does not enable the afalg engine. So in order to get enabled, I
added a
`enable           => [ "afalgeng" ],'
to the generic linux config which sets it explicit (as suggested by
Richard Levitte). Having this set, we can check for it instead matching
the target name.

[0] https://sources.debian.org/src/openssl/1.1.0g-2/Configurations/20-debian.conf/
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5169)

6 years agoOnly update the server session cache when the session is ready
Matt Caswell [Wed, 14 Mar 2018 17:51:18 +0000 (17:51 +0000)]
Only update the server session cache when the session is ready

In TLSv1.3 the session is not ready until after the end of the handshake
when we are constructing the NewSessionTicket.

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

6 years agoMissings OIDs for XTS added.
Pauli [Thu, 15 Mar 2018 01:01:48 +0000 (11:01 +1000)]
Missings OIDs for XTS added.

Added two missing OIDs for AES-{128,256}-XTS.

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

6 years agoFix no-ec
Matt Caswell [Wed, 14 Mar 2018 14:04:18 +0000 (14:04 +0000)]
Fix no-ec

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

6 years agoFix test_out_option
Patrick Steuer [Mon, 12 Mar 2018 12:53:21 +0000 (12:53 +0000)]
Fix test_out_option

Random path generation code in test/recipes/15-test_out_option.t
does not work: The code sets rand_path to "/test.pem". I.e. the
test will fail as expected for unprivileged user but will pass
for root user.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5595)

6 years agoutil/add-depends.pl: sort the dependency files
Richard Levitte [Wed, 14 Mar 2018 11:39:45 +0000 (12:39 +0100)]
util/add-depends.pl: sort the dependency files

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

6 years agoFix an error number clash
Matt Caswell [Wed, 14 Mar 2018 11:27:45 +0000 (11:27 +0000)]
Fix an error number clash

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

6 years agoPut the default set of TLSv1.3 ciphersuites in a header file
Matt Caswell [Wed, 14 Mar 2018 10:43:53 +0000 (10:43 +0000)]
Put the default set of TLSv1.3 ciphersuites in a header file

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

6 years agoFix clienthellotest for new TLSv1.3 ciphersuite configuration
Matt Caswell [Mon, 12 Mar 2018 10:48:32 +0000 (10:48 +0000)]
Fix clienthellotest for new TLSv1.3 ciphersuite configuration

A place in clienthellotest was missed in converting to the new mechanism
for configuration of TLSv1.3 ciphersuites.

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

6 years agoUpdate CHANGES with details of TLSv1.3 ciphersuite configuration
Matt Caswell [Wed, 21 Feb 2018 17:47:12 +0000 (17:47 +0000)]
Update CHANGES with details of TLSv1.3 ciphersuite configuration

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

6 years agoAdd documentation for TLSv1.3 ciphersuite configuration
Matt Caswell [Wed, 21 Feb 2018 17:23:11 +0000 (17:23 +0000)]
Add documentation for TLSv1.3 ciphersuite configuration

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

6 years agoUpdate s_time to be allow configuration of TLSv1.3 ciphersuites
Matt Caswell [Mon, 19 Feb 2018 12:07:18 +0000 (12:07 +0000)]
Update s_time to be allow configuration of TLSv1.3 ciphersuites

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

6 years agoSplit configuration of TLSv1.3 ciphers from older ciphers
Matt Caswell [Fri, 16 Feb 2018 11:26:02 +0000 (11:26 +0000)]
Split configuration of TLSv1.3 ciphers from older ciphers

With the current mechanism, old cipher strings that used to work in 1.1.0,
may inadvertently disable all TLSv1.3 ciphersuites causing connections to
fail. This is confusing for users.

In reality TLSv1.3 are quite different to older ciphers. They are much
simpler and there are only a small number of them so, arguably, they don't
need the same level of control that the older ciphers have.

This change splits the configuration of TLSv1.3 ciphers from older ones.
By default the TLSv1.3 ciphers are on, so you cannot inadvertently disable
them through your existing config.

Fixes #5359

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

6 years agoUpdate version numbers for TLSv1.3 draft-26
Matt Caswell [Tue, 13 Mar 2018 13:13:33 +0000 (13:13 +0000)]
Update version numbers for TLSv1.3 draft-26

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

6 years agoOnly allow supported_versions in a TLSv1.3 ServerHello
Matt Caswell [Tue, 13 Mar 2018 10:36:03 +0000 (10:36 +0000)]
Only allow supported_versions in a TLSv1.3 ServerHello

As per the latest text in TLSv1.3 draft-26

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

6 years agoUse the TLSv1.3 record header as AAD
Matt Caswell [Mon, 26 Feb 2018 12:26:14 +0000 (12:26 +0000)]
Use the TLSv1.3 record header as AAD

As of TLSv1.3 draft-25 the record header data must be used as AAD

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

6 years agoRemove '-Wextra' as default user flags for the Linux clang targets
Richard Levitte [Wed, 14 Mar 2018 08:41:35 +0000 (09:41 +0100)]
Remove '-Wextra' as default user flags for the Linux clang targets

We have '--strict-warnings' for this kind of stuff...  also, user
flags are added last, so this overrides any warning supression
--strict-warnings may put in place (for good reasons).

Fixes #5609

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

6 years agoWindows build file: make sure to quote
Richard Levitte [Tue, 13 Mar 2018 21:07:02 +0000 (22:07 +0100)]
Windows build file: make sure to quote

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

6 years agoRemove the temporary file in case it wasn't renamed
Richard Levitte [Tue, 13 Mar 2018 20:55:52 +0000 (21:55 +0100)]
Remove the temporary file in case it wasn't renamed

...  also, name it with "-$$" added instead of ".$$"

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

6 years agoRemove debugging prints from util/add-depends.pl
Richard Levitte [Tue, 13 Mar 2018 18:38:04 +0000 (19:38 +0100)]
Remove debugging prints from util/add-depends.pl

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

6 years agoConfigurations/*.conf: overhaul Android targets.
Andy Polyakov [Sun, 11 Mar 2018 18:08:56 +0000 (19:08 +0100)]
Configurations/*.conf: overhaul Android targets.

Move Android targets to separate file, automate sysroot setup and
add support for NDK 16.

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

6 years agoec/curve25519.c: resolve regression with Android NDK's arm64 gcc.
Andy Polyakov [Mon, 12 Mar 2018 09:46:23 +0000 (10:46 +0100)]
ec/curve25519.c: resolve regression with Android NDK's arm64 gcc.

Unlike "upstream", Android NDK's arm64 gcc [but not clang] performs
64x64=128-bit multiplications with library calls, which appears to
have devastating impact on performance. [The condition is reduced to
__ANDROID__ [&& !__clang__], because x86_64 has corresponding
assembly module.]

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

6 years agostore/loader_file.c: rename variables causing conflicts with Android NDK.
Andy Polyakov [Sun, 11 Mar 2018 17:47:44 +0000 (18:47 +0100)]
store/loader_file.c: rename variables causing conflicts with Android NDK.

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

6 years agoRefactor the 'depend' target
Richard Levitte [Tue, 13 Mar 2018 16:56:20 +0000 (17:56 +0100)]
Refactor the 'depend' target

With the help of the perl script util/add-depends.pl, which takes all
its information directly from configdata.pm, the dependency adding
procedure can be streamlined for all support platforms.

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

6 years agoupdate SRP copyright notice
Tim Hudson [Tue, 13 Mar 2018 08:33:44 +0000 (18:33 +1000)]
update SRP copyright notice

As per discussion with Peter Sylvester

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

6 years agoopenssl rehash: no more need to massage the files on VMS
Richard Levitte [Mon, 12 Mar 2018 22:02:18 +0000 (23:02 +0100)]
openssl rehash: no more need to massage the files on VMS

OPENSSL_DIR_read() now returns unique file names on VMS, no generation
number.  We therefore do not need to handle that case in apps/rehash.c
any more.

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

6 years agoAdjust LPdir_unix.c on VMS for OpenSSL expectations
Richard Levitte [Sun, 11 Mar 2018 22:48:04 +0000 (23:48 +0100)]
Adjust LPdir_unix.c on VMS for OpenSSL expectations

When OPENSSL_DIR_read implemented by LPdir_unix.c gets a Unixy path,
it will return file names like you'd expect them on Unix.

However, if given a path with VMS syntax, such as "[.foo]", it returns
file names with generation numbers, such as "bar.txt;1", which makes
sense for VMS expectations, but can be surprising for OpenSSL.

Our solution is to simply shave off the generation number if
OPENSSL_DIR_read() expects there should be one, and make sure not to
return the same file name twice.  Note that VMS filesystems are case
insensitive, so the check for duplicate file names are done without
regard to character case.

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

6 years agoCONF inclusion test: Add VMS specific tests
Richard Levitte [Sun, 11 Mar 2018 22:47:40 +0000 (23:47 +0100)]
CONF inclusion test: Add VMS specific tests

We want to see that VMS syntax paths are treated correctly.

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

6 years agoCONF: On VMS, treat VMS syntax inclusion paths correctly
Richard Levitte [Sun, 11 Mar 2018 09:14:11 +0000 (10:14 +0100)]
CONF: On VMS, treat VMS syntax inclusion paths correctly

non-VMS syntax inclusion paths get the same treatment as on Unix.

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

6 years agoFree the correct type in OBJ_add_object()
Matt Caswell [Mon, 12 Mar 2018 15:24:29 +0000 (15:24 +0000)]
Free the correct type in OBJ_add_object()

We should be using ASN1_OBJECT_free() not OPENSSL_free().

Fixes #5568

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

6 years agoFix enable-ssl-trace
Matt Caswell [Mon, 12 Mar 2018 16:08:31 +0000 (16:08 +0000)]
Fix enable-ssl-trace

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

6 years agoIntroduce SSL_CTX_set_stateless_cookie_{generate,verify}_cb
Benjamin Saunders [Mon, 26 Feb 2018 02:39:11 +0000 (18:39 -0800)]
Introduce SSL_CTX_set_stateless_cookie_{generate,verify}_cb

These functions are similar to SSL_CTX_set_cookie_{generate,verify}_cb,
but used for the application-controlled portion of TLS1.3 stateless
handshake cookies rather than entire DTLSv1 cookies.

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

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)