oweals/openssl.git
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)

6 years agoFix documentation link to reference man3
xemdetia [Tue, 27 Feb 2018 20:29:32 +0000 (15:29 -0500)]
Fix documentation link to reference man3

CLA: trivial

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

6 years agoMake some perl scripts output to stdout
Rich Salz [Tue, 27 Feb 2018 20:14:18 +0000 (15:14 -0500)]
Make some perl scripts output to stdout

And only generate one output "file" at a time for objects.pl

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

6 years agocrypto/ec/asm/x25519-x86_64.pl: close STDOUT, not $STDOUT
Richard Levitte [Tue, 27 Feb 2018 20:02:31 +0000 (21:02 +0100)]
crypto/ec/asm/x25519-x86_64.pl: close STDOUT, not $STDOUT

Fixes #5471

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

6 years agoconfigdata.pm: ensure $prefix is defined
Richard Levitte [Tue, 27 Feb 2018 20:01:59 +0000 (21:01 +0100)]
configdata.pm: ensure $prefix is defined

Fixes #5471

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

6 years agobio_b64.c: prevent base64 filter BIO from decoding out-of-bound data
Dr. Matthias St. Pierre [Wed, 21 Feb 2018 00:45:14 +0000 (01:45 +0100)]
bio_b64.c: prevent base64 filter BIO from decoding out-of-bound data

Fixes #5405, #1381

The base64 filter BIO reads its input in chunks of B64_BLOCK_SIZE bytes.
When processing input in PEM format it can happen in rare cases that

- the trailing PEM marker crosses the boundary of a chunk, and
- the beginning of the following chunk contains valid base64 encoded data.

This happened in issue #5405, where the PEM marker was split into
"-----END CER" and "TIFICATE-----" at the end of the first chunk.

The decoding of the first chunk terminated correctly at the '-' character,
which is treated as an EOF marker, and b64_read() returned. However,
when called the second time, b64_read() read the next chunk and interpreted
the string "TIFICATE" as valid base64 encoded data, adding 6 extra bytes
'4c 81 48 08 04 c4'.

This patch restores the assignment of the error code to 'ctx->cont', which
was deleted accidentally in commit 5562cfaca4f3 and which prevents b64_read()
from reading additional data on subsequent calls.

This issue was observed and reported by Annie Yousar.

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

6 years agoPrepare for 1.1.1-pre3-dev
Matt Caswell [Tue, 27 Feb 2018 13:41:51 +0000 (13:41 +0000)]
Prepare for 1.1.1-pre3-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
6 years agoPrepare for 1.1.1-pre2 release OpenSSL_1_1_1-pre2
Matt Caswell [Tue, 27 Feb 2018 13:40:37 +0000 (13:40 +0000)]
Prepare for 1.1.1-pre2 release

Reviewed-by: Richard Levitte <levitte@openssl.org>
6 years agoUpdate copyright year
Matt Caswell [Tue, 27 Feb 2018 13:37:28 +0000 (13:37 +0000)]
Update copyright year

Reviewed-by: Richard Levitte <levitte@openssl.org>
6 years agoClear some sslapitest global variables after use
Matt Caswell [Mon, 26 Feb 2018 19:34:42 +0000 (19:34 +0000)]
Clear some sslapitest global variables after use

Otherwise we get a use after free if the test order is randomised.

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

6 years agomem_sec.c: relax POSIX requirement.
Andy Polyakov [Sun, 25 Feb 2018 15:56:26 +0000 (16:56 +0100)]
mem_sec.c: relax POSIX requirement.

Even though mlock(2) was standardized in POSIX.1-2001, vendors did
implement it prior that point.

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

6 years agotest/ct_test.c: remove dependency on -lm.
Andy Polyakov [Sun, 25 Feb 2018 15:24:34 +0000 (16:24 +0100)]
test/ct_test.c: remove dependency on -lm.

fabs(3m) is customarily inlined, but it's not, one has to link with -lm.
Since fabs(3m) is the only reference, it makes more sense to avoid it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoExport keying material using early exporter master secret
Tatsuhiro Tsujikawa [Sun, 4 Feb 2018 03:20:37 +0000 (12:20 +0900)]
Export keying material using early exporter master secret

This commit adds SSL_export_keying_material_early() which exports
keying material using early exporter master secret.

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

6 years agoMake it possible to give --libdir an absolute path
Richard Levitte [Fri, 23 Feb 2018 11:10:42 +0000 (12:10 +0100)]
Make it possible to give --libdir an absolute path

With this, we introduce the make variable 'libdir', which differs from
'LIBDIR' not only in casing, but also by being the absolute path to
the library installation directory.  This variable is intentionally
compatible with the GNU coding standards.

When --libdir is given an absolute path, it is considered as a value
according to GNU coding standards, and the variables LIBDIR and libdir
will be this:

    LIBDIR=
    libdir=/absolute/path

When --libdir is given a relative path (just the name of the desired
library directory), or not given at all, it is considered as a
"traditional" OpenSSL value, and the variables LIBDIR and libdir will
be this:

    LIBDIR=relativepath
    libdir=$(INSTALLTOP)/$(LIBDIR)

Fixes #5398

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

6 years agoappveyor.yml: omit makedepend step.
Andy Polyakov [Fri, 23 Feb 2018 16:24:41 +0000 (17:24 +0100)]
appveyor.yml: omit makedepend step.

makedepend makes lesser sense in a throw-away build like CI, but
it spares some computational time, because with MSVC it takes
separate per-file compiler invocation.

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

6 years agoec/ecp_nistp{224,256,521}.c: harmonize usage of __uint128_t.
Andy Polyakov [Fri, 23 Feb 2018 12:55:37 +0000 (13:55 +0100)]
ec/ecp_nistp{224,256,521}.c: harmonize usage of __uint128_t.

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

6 years ago{ec/curve25519,poly1305/poly1305}.c: relax pedantic constraint.
Andy Polyakov [Fri, 23 Feb 2018 12:37:06 +0000 (13:37 +0100)]
{ec/curve25519,poly1305/poly1305}.c: relax pedantic constraint.

As it turns out gcc -pedantic doesn't seem to consider __uint128_t
as non-standard, unlike __int128 that is.

Fix even MSVC warnings in curve25519.c.

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

6 years agoec/curve448: portability fixups.
Andy Polyakov [Fri, 23 Feb 2018 12:20:33 +0000 (13:20 +0100)]
ec/curve448: portability fixups.

SPARC condition in __SIZEOF_INT128__==16 is rather performance thing
than portability. Even though compiler advertises int128 capability,
corresponding operations are inefficient, because they are not
directly backed by instruction set.

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

6 years agoec/asm/x25519-x86_64.pl: fix up ADCX/ADOX fallback.
Andy Polyakov [Fri, 23 Feb 2018 10:51:41 +0000 (11:51 +0100)]
ec/asm/x25519-x86_64.pl: fix up ADCX/ADOX fallback.

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

6 years agoRemove OSSLzu, and fix the one place that used it.
Rich Salz [Fri, 23 Feb 2018 21:49:59 +0000 (16:49 -0500)]
Remove OSSLzu, and fix the one place that used it.

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

6 years agoFix some bugs with the cfb1 bitsize handling
Bernd Edlinger [Wed, 21 Feb 2018 14:48:02 +0000 (15:48 +0100)]
Fix some bugs with the cfb1 bitsize handling

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

6 years agoRemove executable bit from test/recipes/03-test_internal_sm4.t
Bernd Edlinger [Thu, 22 Feb 2018 07:30:41 +0000 (08:30 +0100)]
Remove executable bit from test/recipes/03-test_internal_sm4.t

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

6 years agoAdd a note in CHANGES
Richard Levitte [Thu, 22 Feb 2018 04:45:18 +0000 (05:45 +0100)]
Add a note in CHANGES

[extended tests]

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

6 years agoTest the storeutl searching options
Richard Levitte [Mon, 20 Feb 2017 01:49:13 +0000 (02:49 +0100)]
Test the storeutl searching options

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

6 years agoSTORE: Add documentation on search criteria
Richard Levitte [Wed, 5 Jul 2017 17:17:40 +0000 (19:17 +0200)]
STORE: Add documentation on search criteria

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

6 years agoAdapt storeutl to allow search for specific objects
Richard Levitte [Mon, 20 Feb 2017 01:47:56 +0000 (02:47 +0100)]
Adapt storeutl to allow search for specific objects

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

6 years agoSTORE 'file' scheme loader: Add search capibility
Richard Levitte [Mon, 20 Feb 2017 01:39:52 +0000 (02:39 +0100)]
STORE 'file' scheme loader: Add search capibility

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

6 years agoSTORE: Add the possibility to search for specific information
Richard Levitte [Sun, 19 Feb 2017 11:24:19 +0000 (12:24 +0100)]
STORE: Add the possibility to search for specific information

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

6 years agoTest the storeutl expectation options
Richard Levitte [Sat, 11 Feb 2017 03:02:32 +0000 (04:02 +0100)]
Test the storeutl expectation options

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

6 years agoSTORE: Add documentation on expecting specific infos
Richard Levitte [Wed, 5 Jul 2017 14:15:48 +0000 (16:15 +0200)]
STORE: Add documentation on expecting specific infos

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

6 years agoAdapt storeutl to allow looking for a specific info type
Richard Levitte [Sat, 11 Feb 2017 02:20:45 +0000 (03:20 +0100)]
Adapt storeutl to allow looking for a specific info type

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

6 years agoSTORE 'file' scheme loader: Add info type expectation
Richard Levitte [Sat, 11 Feb 2017 01:27:31 +0000 (02:27 +0100)]
STORE 'file' scheme loader: Add info type expectation

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

6 years agoSTORE: Add the possibility to specify an expected info type
Richard Levitte [Sat, 11 Feb 2017 01:33:18 +0000 (02:33 +0100)]
STORE: Add the possibility to specify an expected info type

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

6 years agoSTORE: In preparation for coming work, mark when loading is started
Richard Levitte [Sat, 11 Feb 2017 01:50:50 +0000 (02:50 +0100)]
STORE: In preparation for coming work, mark when loading is started

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

6 years agoRemove unreachable statement.
Pauli [Fri, 23 Feb 2018 00:55:50 +0000 (10:55 +1000)]
Remove unreachable statement.

The return at the end isn't reachable.

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

6 years agoBuild files: when using $(CPP), use the C flags alongside the CPP flags
Richard Levitte [Thu, 22 Feb 2018 15:33:58 +0000 (16:33 +0100)]
Build files: when using $(CPP), use the C flags alongside the CPP flags

The reason for this is that some of the C flags affect built in macros
that we may depend on.

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

6 years agoRemove unused num.pl,segregnam scripts
Rich Salz [Thu, 22 Feb 2018 20:36:27 +0000 (15:36 -0500)]
Remove unused num.pl,segregnam scripts

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

6 years agoinitialise dc variable to satisfy old compilers.
Steve Linsell [Thu, 22 Feb 2018 18:24:13 +0000 (13:24 -0500)]
initialise dc variable to satisfy old compilers.

When compiling with -Wall on a machine with an old compiler it gives a false
positive that the dc variable which is a structure of type DISPLAY_COLUMNS
could be used uninitialised. In fact the dc variable's members will always get
set in the case it is used, otherwise it is left uninitialised.
This fix just causes the dc variable's members to always get initialised to 0
at declaration, so the false positive will not get flagged.

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

6 years agoUpdate EC_POINT_new.pod
Per Sandström [Wed, 14 Feb 2018 13:08:33 +0000 (14:08 +0100)]
Update EC_POINT_new.pod

CLA: trivial
fix typo:
EC_point2buf => EC_POINT_point2buf

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

6 years agoBuild file templates: be less verbose when reconfiguring
Richard Levitte [Fri, 2 Feb 2018 19:33:13 +0000 (20:33 +0100)]
Build file templates: be less verbose when reconfiguring

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

6 years agoReplace the message about configdata.pm as a script
Richard Levitte [Fri, 2 Feb 2018 11:30:50 +0000 (12:30 +0100)]
Replace the message about configdata.pm as a script

The new message is geared toward issue reports

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

6 years agoAdd a comment in configdata.pm regarding script-only variables
Richard Levitte [Fri, 2 Feb 2018 11:30:14 +0000 (12:30 +0100)]
Add a comment in configdata.pm regarding script-only variables

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

6 years agoMake CROSS_COMPILE another supported "make variable" in Configure
Richard Levitte [Fri, 2 Feb 2018 11:27:29 +0000 (12:27 +0100)]
Make CROSS_COMPILE another supported "make variable" in Configure

No more special casing for that one, and this means it gets displayed
by 'perl configdata.pm --make-variables' among all the others.

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

6 years agoUnix Makefile: Rework the assignment of CXX and AS
Richard Levitte [Fri, 2 Feb 2018 11:25:26 +0000 (12:25 +0100)]
Unix Makefile: Rework the assignment of CXX and AS

If the configured value is the empty string, give them a sane default.
Otherwise, give them the configured value prefix with $(CROSS_COMPILE)

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

6 years agoRefactor the ranlib attribute
Richard Levitte [Fri, 2 Feb 2018 11:23:09 +0000 (12:23 +0100)]
Refactor the ranlib attribute

It was inconsistent to see this specific command have
'$(CROSS_COMPILE)' in its value when no other command did.

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

6 years agoHave configdata.pm display information on perl
Richard Levitte [Fri, 2 Feb 2018 11:21:27 +0000 (12:21 +0100)]
Have configdata.pm display information on perl

Specifically, the specific perl that was used to run Configure

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

6 years agoCheck return value of time() when getting additional data for the DRBG
Kurt Roeckx [Sun, 18 Feb 2018 17:39:19 +0000 (18:39 +0100)]
Check return value of time() when getting additional data for the DRBG

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
GH: #5400

6 years agoSwitch the DRBGs from AES-128-CTR to AES-256-CTR
Kurt Roeckx [Sun, 18 Feb 2018 18:16:13 +0000 (19:16 +0100)]
Switch the DRBGs from AES-128-CTR to AES-256-CTR

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

6 years agoUse malloc to avoid alignment problems.
Viktor Dukhovni [Wed, 21 Feb 2018 13:25:49 +0000 (08:25 -0500)]
Use malloc to avoid alignment problems.

Thanks to Norm Green for reporting this issue.

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

6 years agoAdd support for PBKDF2 for enc command
EasySec [Wed, 14 Dec 2016 15:29:06 +0000 (16:29 +0100)]
Add support for PBKDF2 for enc command

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

6 years agodo_body: fix heap-use-after-free.
Pavel Kopyl [Fri, 3 Nov 2017 19:18:35 +0000 (22:18 +0300)]
do_body: fix heap-use-after-free.

The memory pointed to by the 'push' is freed by the
X509_NAME_ENTRY_free() in do_body(). The second time
it is referenced to (indirectly) in certify_cert:X509_REQ_free().

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

6 years agoX509V3_EXT_add_nconf_sk, X509v3_add_ext: fix errors handling
Pavel Kopyl [Tue, 7 Nov 2017 12:28:18 +0000 (15:28 +0300)]
X509V3_EXT_add_nconf_sk, X509v3_add_ext: fix errors handling

X509v3_add_ext: free 'sk' if the memory pointed to by it
was malloc-ed inside this function.
X509V3_EXT_add_nconf_sk: return an error if X509v3_add_ext() fails.
This prevents use of a freed memory in do_body:sk_X509_EXTENSION_num().

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

6 years agoReplaced variable-time GCD with consttime inversion to avoid side-channel attacks...
Samuel Weiser [Wed, 21 Feb 2018 11:56:01 +0000 (11:56 +0000)]
Replaced variable-time GCD with consttime inversion to avoid side-channel attacks on RSA key generation

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

6 years agoSanity check the ticket length before using key name/IV
Matt Caswell [Tue, 20 Feb 2018 10:20:20 +0000 (10:20 +0000)]
Sanity check the ticket length before using key name/IV

This could in theory result in an overread - but due to the over allocation
of the underlying buffer does not represent a security issue.

Thanks to Fedor Indutny for reporting this issue.

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

6 years agoFix no-ec build
Matt Caswell [Tue, 20 Feb 2018 14:53:40 +0000 (14:53 +0000)]
Fix no-ec build

[extended tests]

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

6 years agoFix some undefined behaviour in the Curve448 code
Matt Caswell [Tue, 20 Feb 2018 14:53:06 +0000 (14:53 +0000)]
Fix some undefined behaviour in the Curve448 code

We can't add NULL data into a hash

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

6 years agoRemove a spurious TLSProxy byte in TLSv1.3
Matt Caswell [Wed, 14 Feb 2018 17:29:32 +0000 (17:29 +0000)]
Remove a spurious TLSProxy byte in TLSv1.3

When the proxy re-encrypted a TLSv1.3 record it was adding a spurious
byte onto the end. This commit removes that.

The "extra" byte was intended to be the inner content type of the record.
However, TLSProxy was actually adding the original encrypted data into the
record (which already has the inner content type in it) and then adding
the spurious additional content type byte on the end (and adjusting the
record length accordingly).

It is interesting to look at why this didn't cause a failure:

The receiving peer first attempts to decrypt the data. Because this is
TLSProxy we always use a GCM based ciphersuite with a 16 byte tag. When
we decrypt this it actually gets diverted to the ossltest engine. All this
does is go through the motions of encrypting/decrypting but just passes
back the original data. Crucially it will never fail because of a bad tag!
The receiving party thinks the spurious additional byte is part of the
tag and the ossltest engine ignores it.

This means the data that gets passed back to the record layer still has
an additional spurious byte on it - but because the 16 byte tag has been
removed, this is actually the first byte of the original tag. Again
because we are using ossltest engine we aren't actually creating "real"
tags - we only ever emit 16, 0 bytes for the tag. So the spurious
additional byte always has the value 0. The TLSv1.3 spec says that records
can have additional 0 bytes on the end of them - this is "padding". So the
record layer interprets this 0 byte as padding and strips it off to end up
with the originally transmitted record data - which it can now process
successfully.

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