oweals/openssl.git
5 years agoAdd some more test vectors for ChaCha20
Matt Caswell [Thu, 18 Apr 2019 09:55:11 +0000 (10:55 +0100)]
Add some more test vectors for ChaCha20

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

(cherry picked from commit a595b10d343845eca32cffb35f1d0a2f15ce40a9)

5 years agoClarify the documentation on the use of ChaCha20
Matt Caswell [Thu, 18 Apr 2019 09:54:58 +0000 (10:54 +0100)]
Clarify the documentation on the use of ChaCha20

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

(cherry picked from commit 6f3aae256d62cfcc48c07cc0ead5080b070f371b)

5 years agoasn1parse: avoid double free
Richard Levitte [Mon, 15 Apr 2019 11:15:55 +0000 (13:15 +0200)]
asn1parse: avoid double free

|str| was used for multiple conflicting purposes.  When using
'-strictpem', it's used to uniquely hold a reference to the loaded
payload.  However, when using '-strparse', |str| was re-used to hold
the position from where to start parsing.

So when '-strparse' and '-strictpem' are were together, |str| ended up
pointing into data pointed at by |at|, and was yet being freed, with
the result that the payload it held a reference to became a memory
leak, and there was a double free conflict when both |str| and |at|
were being freed.

The situation is resolved by always having |buf| hold the pointer to
the file data, and always and only use |str| to hold the position to
start parsing from.  Now, we only need to free |buf| properly and not
|str|.

Fixes #8752

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

(cherry picked from commit 4f29f3a29b8b416a501c7166dbbca5284b198f81)

5 years agoAdd test for the BIO_s_mem rdwr->rdonly->rdwr use-case
Tomas Mraz [Thu, 4 Apr 2019 07:49:36 +0000 (09:49 +0200)]
Add test for the BIO_s_mem rdwr->rdonly->rdwr use-case

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

(cherry picked from commit 06add280d90de9625e9c18985f376ef8d0419a46)

5 years agoAdd documentation for the BIO_s_mem pecularities
Tomas Mraz [Thu, 4 Apr 2019 07:48:47 +0000 (09:48 +0200)]
Add documentation for the BIO_s_mem pecularities

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

(cherry picked from commit 3d42833d389134b7b05b655c264e4dba5a2179e9)

5 years agoAdd testing of RDONLY memory BIOs
Tomas Mraz [Wed, 3 Apr 2019 17:07:00 +0000 (19:07 +0200)]
Add testing of RDONLY memory BIOs

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

(cherry picked from commit d34bce03acc53c583df954bbed65d4800751563a)

5 years agoAdd test for the BIO_get_mem_ptr() regression
Bernd Edlinger [Fri, 1 Mar 2019 00:55:38 +0000 (01:55 +0100)]
Add test for the BIO_get_mem_ptr() regression

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

(cherry picked from commit c9dc22bc3d7f2df670dff66f04935e540e1b931a)

5 years agoFix for BIO_get_mem_ptr and related regressions
Tomas Mraz [Wed, 3 Apr 2019 10:31:32 +0000 (12:31 +0200)]
Fix for BIO_get_mem_ptr and related regressions

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

(cherry picked from commit b238fb79709a180ba9b4d837101c9f75e2978dc0)

5 years agoFurther harmonisation of manual page HISTORY sections
Joshua Lock [Thu, 11 Apr 2019 14:38:56 +0000 (15:38 +0100)]
Further harmonisation of manual page HISTORY sections

A couple of minor tweaks to match the style introduced in #7854:
- BIO_connect: remove line break to make more grep friendly
- SSL_CTX_new: harmoise the format of the HISTORY section

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 938e82f622eb04ebbfe534c79d234d0f6a0df035)

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

5 years agoUpdate various man pages to place HISTORY section after SEE ALSO
Joshua Lock [Tue, 9 Apr 2019 14:13:55 +0000 (15:13 +0100)]
Update various man pages to place HISTORY section after SEE ALSO

SEE ALSO before HISTORY is the more common pattern in OpenSSL manual
pages and seems to be the prevalent order based on sampling my system
manual pages.

Fixes #8631

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit b5c4bbbe54e112b976155004b3d702e47ce7d9d9)

 Conflicts:
doc/man3/RAND_DRBG_generate.pod
doc/man3/RAND_DRBG_reseed.pod

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

5 years agoAdd a check for history section location to find-doc-nits
Joshua Lock [Tue, 9 Apr 2019 14:10:08 +0000 (15:10 +0100)]
Add a check for history section location to find-doc-nits

Check that the HISTORY section is located after the SEE ALSO section,
this is a much more frequent order in OpenSSL manual pages (and UNIX
manual pages in general).

Also check that SEE ALSO comes after EXAMPLES, so that the tool can
ensure the correct manual section sequence.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 573ac8f2228241771f727ecd8ff10f54073536d3)

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

5 years agoMake check_example_location() in find-doc-nits generic
Joshua Lock [Tue, 9 Apr 2019 13:53:58 +0000 (14:53 +0100)]
Make check_example_location() in find-doc-nits generic

Change to check_section_location(), a generic function to ensure that
section SECTION appears before section BEFORE in the man pages.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 95f92d57755a9bfc83135a585da69d497f7293d9)

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

5 years agoAdd section order check in util/find-doc-nits
Paul Yang [Tue, 26 Feb 2019 05:51:02 +0000 (13:51 +0800)]
Add section order check in util/find-doc-nits

This patch checks if the EXAMPLES section in a pod file is placed
before the RETURN VALUES section.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit cc838ee2d66f7295bf7a7e6695aab1080d6791e9)

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

5 years agoPlace return values after examples in doc
Paul Yang [Tue, 26 Feb 2019 05:11:10 +0000 (13:11 +0800)]
Place return values after examples in doc

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 4564e77ae9dd1866e8a033f03511b6a1792c024e)

 Conflicts:
doc/internal/man3/openssl_ctx_get_data.pod (non-existant)
doc/man3/OPENSSL_s390xcap.pod (non-existant)

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

5 years agoDon't use coordinate blinding when scalar is group order
Bernd Edlinger [Fri, 12 Apr 2019 12:28:00 +0000 (14:28 +0200)]
Don't use coordinate blinding when scalar is group order

This happens in ec_key_simple_check_key and EC_GROUP_check.
Since the the group order is not a secret scalar, it is
unnecessary to use coordinate blinding.

Fixes: #8731

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

(cherry picked from commit 3051bf2afab7ac8b7b9c64e68755d1addd2fb8ff)

5 years agoFixed linux_x86_icc compiler errors in EC code related to __uint128_t/__int128_t
Shane Lontis [Mon, 8 Apr 2019 05:22:18 +0000 (15:22 +1000)]
Fixed linux_x86_icc compiler errors in EC code related to __uint128_t/__int128_t

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

(cherry picked from commit 3a86f1db282569c538273cc48462a3fa5fcffa39)

5 years agoAvoid creating invalid rsa pss params
Bernd Edlinger [Sun, 31 Mar 2019 11:56:23 +0000 (13:56 +0200)]
Avoid creating invalid rsa pss params

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

(cherry picked from commit 491360e7ab2f09fdaadfcd9ff84c425c8f4e5b03)

5 years agoFix typos
Jakub Wilk [Wed, 10 Apr 2019 10:00:20 +0000 (12:00 +0200)]
Fix typos

CLA: trivial

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

(cherry picked from commit ee215c7eea91f193d4765127eb31332758753058)

5 years agoEVP_*Update: ensure that input NULL with length 0 isn't passed
Richard Levitte [Thu, 4 Apr 2019 23:22:14 +0000 (01:22 +0200)]
EVP_*Update: ensure that input NULL with length 0 isn't passed

Even with custome ciphers, the combination in == NULL && inl == 0
should not be passed down to the backend cipher function.  The reason
is that these are the values passed by EVP_*Final, and some of the
backend cipher functions do check for these to see if a "final" call
is made.

Fixes #8675

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

(cherry picked from commit dcb982d792d6064ed3493e79749208d8c257ff04)

5 years agoRework DSO API conditions and configuration option
Richard Levitte [Mon, 1 Apr 2019 04:40:33 +0000 (06:40 +0200)]
Rework DSO API conditions and configuration option

'no-dso' is meaningless, as it doesn't get any macro defined.
Therefore, we remove all checks of OPENSSL_NO_DSO.  However, there may
be some odd platforms with no DSO scheme.  For those, we generate the
internal macro DSO_NONE aand use it.

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

5 years agoFix crash in X509_STORE_CTX_get_by_subject
Matt Caswell [Mon, 8 Apr 2019 10:22:37 +0000 (11:22 +0100)]
Fix crash in X509_STORE_CTX_get_by_subject

If using a custom X509_LOOKUP_METHOD then calls to
X509_STORE_CTX_get_by_subject may crash due to an incorrectly initialised
X509_OBJECT being passed to the callback get_by_subject function.

Fixes #8673

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

(cherry picked from commit b926f9deb3dc79d00f0a989370e95867516a3a17)

5 years agos_client starttls: fix handling of multiline reply
Dan Campbell [Thu, 4 Apr 2019 21:15:33 +0000 (15:15 -0600)]
s_client starttls: fix handling of multiline reply

Fixes #8645

Reviewed-by: Paul Dale <paul.dale@oracle.com>
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/8654)

(cherry picked from commit f997e456b9bd43af275aab90c727a52287467e98)

5 years agoFix the allocation size in EVP_OpenInit and PEM_SignFinal
Bernd Edlinger [Sun, 31 Mar 2019 10:00:16 +0000 (12:00 +0200)]
Fix the allocation size in EVP_OpenInit and PEM_SignFinal

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

(cherry picked from commit 8cf85d489978c384a3f193fb7cb25469e0559f27)

5 years agoOPENSSL_init_crypto(): check config return code correctly
Richard Levitte [Fri, 5 Apr 2019 08:28:32 +0000 (10:28 +0200)]
OPENSSL_init_crypto(): check config return code correctly

It was assumed that the config functionality returned a boolean.
However, it may return a negative number on error, so we need to take
that into account.

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

(cherry picked from commit e3af453baceee7401ba0c5044a4c3aeaf246406f)

5 years agoAdd the prediction_resistance flag to the documentation.
Pauli [Fri, 5 Apr 2019 04:43:18 +0000 (14:43 +1000)]
Add the prediction_resistance flag to the documentation.

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

5 years agoCorrect the documentation about SSL_CIPHER_description()
Matt Caswell [Wed, 3 Apr 2019 22:13:59 +0000 (23:13 +0100)]
Correct the documentation about SSL_CIPHER_description()

There are some ciphersuites that were introduced in TLSv1.0/TLSv1.1 but
are backwards compatible with SSLv3.

Fixes #8655

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

(cherry picked from commit 69539990a8152e90dbe1df1124263db126b1e6f3)

5 years agoUse AI_ADDRCONFIG hint with getaddrinfo if available.
Tomas Mraz [Thu, 21 Mar 2019 12:17:29 +0000 (13:17 +0100)]
Use AI_ADDRCONFIG hint with getaddrinfo if available.

This prevents failure of openssl s_server socket binding to wildcard
address on hosts with disabled IPv6.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8550)

(cherry picked from commit b8472b4e67ec7ad49254821f2da578ce588df4e6)

5 years agoRevert "crypto/rand/rand_win.c: include "e_os.h" to get the default _WIN32_WINNT"
Richard Levitte [Tue, 2 Apr 2019 12:40:11 +0000 (14:40 +0200)]
Revert "crypto/rand/rand_win.c: include "e_os.h" to get the default _WIN32_WINNT"

I turns out that this made crypto/rand/rand_win.c to never build with
BCrypt support unless the user sets _WIN32_WINNT.  That wasn't the
intent.

This reverts commit cc8926ec8fcecae89ceab91ef753de93e49568f9.

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

(cherry picked from commit 705a27f7e07c006b167b59070ff635a61f8e0407)

5 years agorand_win.c: loosen version requirements for BCryptGenRandom
Dr. Matthias St. Pierre [Tue, 2 Apr 2019 10:35:46 +0000 (12:35 +0200)]
rand_win.c: loosen version requirements for BCryptGenRandom

BCryptGenRandom() is available for Windows Vista and newer versions, see
https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgenrandom

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

(cherry picked from commit 2621e6405d7f4765bc57c86ec441129e7d367f14)

5 years agocrypto/rand/rand_win.c: include "e_os.h" to get the default _WIN32_WINNT
Richard Levitte [Tue, 2 Apr 2019 09:14:10 +0000 (11:14 +0200)]
crypto/rand/rand_win.c: include "e_os.h" to get the default _WIN32_WINNT

This helps decide if the BCrypt API should be used or not.

Fixes #8635

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

(cherry picked from commit cc8926ec8fcecae89ceab91ef753de93e49568f9)

5 years agoFixed typo in enc.c warning
x753 [Fri, 29 Mar 2019 01:31:36 +0000 (21:31 -0400)]
Fixed typo in enc.c warning

"warning: iv not use by this cipher" -> "warning: iv not used by this cipher"
CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8608)

(cherry picked from commit 9c119bc6b54f4851898134db28c2a01947b5efba)

5 years agofixed public range check in ec_GF2m_simple_oct2point
Shane Lontis [Wed, 27 Mar 2019 07:38:28 +0000 (17:38 +1000)]
fixed public range check in ec_GF2m_simple_oct2point

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

(cherry picked from commit cad8347be23c5e0c0d9eea02d090d42daf2dd7a9)

5 years agoFor the lack of GetModuleHandleEx(), we use DSO route for WinCE.
Soujyu Tanaka [Wed, 27 Mar 2019 08:30:47 +0000 (17:30 +0900)]
For the lack of GetModuleHandleEx(), we use DSO route for WinCE.
Revert win32_pathbyaddr() which is used in DSO_dsobyaddr().

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

(cherry picked from commit 9c98aa354df8b144a238346b63de8b82f04175dd)

5 years agoCircumvent a problem of lacking GetEnvironmentVariable() in WindowsCE.
Soujyu Tanaka [Wed, 27 Mar 2019 07:21:58 +0000 (16:21 +0900)]
Circumvent a problem of lacking GetEnvironmentVariable() in WindowsCE.

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

(cherry picked from commit 3d098890b23598d1f9455b354f46045a231459cd)

5 years agoAvoid linking error for InitializeCriticalSectionAndSpinCount().
Soujyu Tanaka [Wed, 27 Mar 2019 07:15:31 +0000 (16:15 +0900)]
Avoid linking error for InitializeCriticalSectionAndSpinCount().
Replace it with InitializeCriticalSection()

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

(cherry picked from commit 09305a7d0afcf9ae2d5be459ad6e6433ea85f913)

5 years agoAvoid linking error on WCE700 for _InterlockedExchangeAdd().
Soujyu Tanaka [Wed, 27 Mar 2019 06:55:32 +0000 (15:55 +0900)]
Avoid linking error on WCE700 for _InterlockedExchangeAdd().
This implementation is referenced to https://www.boost.org/doc/libs/1_69_0/boost/detail/interlocked.hpp

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

(cherry picked from commit 88ffc8dea4e313b6acfd3a9ef3868bee96717cf9)

5 years agoconn_is_closed should return 1 if get_last_sys_error is WSAECONNRESET
Paul Monson [Tue, 26 Mar 2019 22:25:19 +0000 (15:25 -0700)]
conn_is_closed should return 1 if get_last_sys_error is WSAECONNRESET
CLA: trivial

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

(cherry picked from commit 0b885f72c2b18c57173e134a03ed013cd1ac361e)

5 years agoAdd some checks of OCSP functions
Dmitry Belyavskiy [Fri, 22 Feb 2019 13:58:55 +0000 (16:58 +0300)]
Add some checks of OCSP functions

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

(cherry picked from commit 72b89b8e201d17dea0219b4b92df7af7e17f183a)

5 years agoMake OCSP_id_cmp and OCSP_id_issuer_cmp accept const params
Matt Caswell [Wed, 27 Mar 2019 11:16:44 +0000 (11:16 +0000)]
Make OCSP_id_cmp and OCSP_id_issuer_cmp accept const params

Fixes #8589

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

(cherry picked from commit cc6d92619fc3678817b2e09894683b40860563a7)

5 years agoIncrease rounds of Miller-Rabin testing DH_check
Jake Massimo [Wed, 27 Mar 2019 04:13:08 +0000 (04:13 +0000)]
Increase rounds of Miller-Rabin testing DH_check

DH_check is used to test the validity of Diffie-Hellman parameter sets (p, q, g). Among the tests performed are primality tests on p and q, for this BN_is_prime_ex is called with the rounds of Miller-Rabin set as default. This will therefore use the average case error estimates derived from the function BN_prime_checks_for_size based on the bit size of the number tested.

However, these bounds are only accurate on testing random input. Within this testing scenario, where we are checking the validity of a DH parameter set, we can not assert that these parameters are randomly generated. Thus we must treat them as if they are adversarial in nature and increase the rounds of Miller-Rabin performed.

Generally, each round of Miller-Rabin can declare a composite number prime with probability at most (1/4), thus 64 rounds is sufficient in thwarting known generation techniques (even in safe prime settings - see https://eprint.iacr.org/2019/032 for full analysis). The choice of 64 rounds is also consistent with SRP_NUMBER_ITERATIONS_FOR_PRIME 64 as used in srp_Verify_N_and_g in openssl/apps/s_client.c.

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

(cherry picked from commit 2500c093aa1e9c90c11c415053c0a27a00661d0d)

5 years agoDon't allow SHAKE128/SHAKE256 with HMAC
Matt Caswell [Tue, 26 Mar 2019 13:32:39 +0000 (13:32 +0000)]
Don't allow SHAKE128/SHAKE256 with HMAC

See discussion in github issue #8563

Fixes #8563

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

5 years agoFix a memory leak in ARIA GCM
Matt Caswell [Tue, 26 Mar 2019 14:42:14 +0000 (14:42 +0000)]
Fix a memory leak in ARIA GCM

Fixes #8567

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

(cherry picked from commit 183f52e29af27285ea4ed7c947b71c83618f8702)

5 years agoTolerate 0 byte input length for Update functions
Matt Caswell [Tue, 26 Mar 2019 15:25:15 +0000 (15:25 +0000)]
Tolerate 0 byte input length for Update functions

We treat that as automatic success. Other EVP_*Update functions already do
this (e.g. EVP_EncryptUpdate, EVP_DecryptUpdate etc). EVP_EncodeUpdate is
a bit of an anomoly. That treats 0 byte input length as an error.

Fixes #8576

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

(cherry picked from commit a8274ea351988aa754cb9983b27d7059613ee11e)

5 years agoFix three identical grammatical errors
Dr. Matthias St. Pierre [Tue, 26 Mar 2019 23:55:55 +0000 (00:55 +0100)]
Fix three identical grammatical errors

Reported by Mak Kolybabi

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

(cherry picked from commit fc4e500b037fcbe89238b1c9f0c1ccf46a7c6559)

5 years agots(1): digest option is mandatory
Hubert Kario [Wed, 6 Mar 2019 15:51:49 +0000 (16:51 +0100)]
ts(1): digest option is mandatory

not specifying the digest both on command line and in the config file
will lead to response generation aborting with

140617514493760:error:2F098088:time stamp routines:ts_CONF_lookup_fail: \
    cannot find config variable:crypto/ts/ts_conf.c:106:tsr_test::signer_digest

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

(cherry picked from commit 29716a03e8c602d69d6c86558b2903b23edddd9b)

5 years agoModify the RSA_private_decrypt functions to check the padding in
Bernd Edlinger [Wed, 20 Mar 2019 21:02:58 +0000 (22:02 +0100)]
Modify the RSA_private_decrypt functions to check the padding in
constant time with a memory access pattern that does not depend
on secret information.

[extended tests]

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

(cherry picked from commit 9c0cf214e7836eb5aaf1ea5d3cbf6720533f86b5)

5 years agoMake err_clear_constant_time really constant time
Bernd Edlinger [Wed, 20 Mar 2019 19:01:12 +0000 (20:01 +0100)]
Make err_clear_constant_time really constant time

[extended tests]

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

(cherry picked from commit 94dc53a3f7549040dd9e61a25485070c14b41c49)

5 years agoCosmetic rand/drbg changes.
Pauli [Fri, 22 Mar 2019 00:49:57 +0000 (10:49 +1000)]
Cosmetic rand/drbg changes.

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

(cherry picked from commit b3d113ed2993801ee643126118ccf6592ad18ef7)

5 years agoProviding missing accessor to EVP_PKEY.engine
Dmitry Belyavskiy [Tue, 19 Mar 2019 11:07:37 +0000 (14:07 +0300)]
Providing missing accessor to EVP_PKEY.engine

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

5 years agoReorganized signature-scheme detection in 'apps/s_cb.c:security_callback_debug' callb...
Lorinczy Zsigmond [Fri, 8 Mar 2019 19:22:05 +0000 (20:22 +0100)]
Reorganized signature-scheme detection in 'apps/s_cb.c:security_callback_debug' callback-function.

So far, it only handled hash-and-algorithm pairs from TLS1.2,
now it also handles 'schemes' defined in TLS1.3 like 0x0807=ed25519 or
0x0809=rsa_pss_pss_sha256

Now it prints information in one of these formats:

... Algorithm scheme=ecdsa_secp256r1_sha256, security bits=128 ... TLS1.3
... Algorithm digest=SHA384, algorithm=DSA, security bits=192  ... TLS1.2
... Algorithm scheme=unknown(0x0e01), security bits=128        ... unhandled case

To implement this added three new lookup-tables: signature_tls13_scheme_list,
signature_tls12_alg_list, signature_tls12_hash_list.

Also minor changes in 'security_callback_debug', eg adding variable 'show_nm'
to indicate if we should show 'nm'.

Also coding-styles fixes from matcaswell

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

(cherry picked from commit 861e45624fe5f16adb11e041a7ac7a1b3229d756)

5 years agoOPENSSL_config(): restore error agnosticism
Richard Levitte [Wed, 20 Mar 2019 09:18:13 +0000 (10:18 +0100)]
OPENSSL_config(): restore error agnosticism

Great effort has been made to make initialization more configurable.
However, the behavior of OPENSSL_config() was lost in the process,
having it suddenly generate errors it didn't previously, which is not
how it's documented to behave.

A simple setting of default flags fixes this problem.

Fixes #8528

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

(cherry picked from commit 905c9a72a708701597891527b422c7f374125c52)

5 years agoUpdated doc for BN_clear, BN_CTX_end when param is NULL
Shane Lontis [Tue, 19 Mar 2019 22:13:55 +0000 (08:13 +1000)]
Updated doc for BN_clear, BN_CTX_end when param is NULL

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

(cherry picked from commit 138ef774fedb567b29d6e5a96541a396cadc6135)

5 years agoUpdate pkeyutl documentation about the digest option
Matt Caswell [Thu, 7 Mar 2019 14:02:56 +0000 (14:02 +0000)]
Update pkeyutl documentation about the digest option

DSA can accept other digests other than SHA1. EC ignores the digest option
altogether.

Fixes #8425

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

(cherry picked from commit 6a6d9ecd1dff669c162e8ab940dac5db2e82679d)

5 years agoapps/speed.c: properly address NO_EC2M on systems without SIGALRM
Vitezslav Cizek [Tue, 5 Mar 2019 21:52:33 +0000 (22:52 +0100)]
apps/speed.c: properly address NO_EC2M on systems without SIGALRM

The ecdh_c array is allocated of the same size as ecdh_choices,
whose size depends on whether the support for binary curves is enabled
or not.  (The same goes for ecdsa_c).
On systems without SIGALRM, ecdh_c is indexed by predefined constants
intended for representing the index of the ciphers in the ecdh_choices
array.
However, in case of NO_EC2M some of the #defined constants won't match
and would actually access the ecdh_c out-of-bounds.

Use enum instead of a macro to define the curve indexes so they're
within the bounds of the ecdh_c array.

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

(cherry picked from commit f5c9916742655f872018426838cff4ff04da5321)

5 years agoapps/speed.c: skip binary curves when compiling with OPENSSL_NO_EC2M
Vitezslav Cizek [Tue, 5 Mar 2019 16:14:33 +0000 (17:14 +0100)]
apps/speed.c: skip binary curves when compiling with OPENSSL_NO_EC2M

openssl speed doesn't take into account that the library could be
compiled without the support for the binary curves and happily uses
them, which results in EC_GROUP_new_by_curve_name() errors.

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

(cherry picked from commit d61f489b5a8d8369e75ee1e4991b3d4db95d7c7c)

5 years agoConfigure: untabify indentation
Dr. Matthias St. Pierre [Mon, 18 Mar 2019 10:51:19 +0000 (11:51 +0100)]
Configure: untabify indentation

The indentation in the Configure file is currently very strange when
viewed in an editor with a tab width of four spaces, because it has
mixed tab-and-whitespace indentation, which was apparently done with
a tab width of eight spaces.

This commit converts all tabs to spaces using expand(1) with default
    settings. To verify that there are only whitespace changes, use

   git show --ignore-space-change  <this commit>

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

5 years agoFix compiling error for mips32r6 and mips64r6
Hua Zhang [Wed, 13 Mar 2019 06:28:44 +0000 (14:28 +0800)]
Fix compiling error for mips32r6 and mips64r6

There are some compiling errors for mips32r6 and mips64r6:

crypto/bn/bn-mips.S:56: Error: opcode not supported on this processor: mips2 (mips2) `mulu $1,$12,$7'
crypto/mips_arch.h: Assembler messages:
crypto/mips_arch.h:15: Error: junk at end of line, first unrecognized character is `&'

Signed-off-by: Hua Zhang <hua.zhang1974@hotmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8464)

(cherry picked from commit 1b9c5f2e2f283a3b12d02a89c11b8e8d97bc6312)

5 years agoAdd missing '.text' in crypto/bn/asm/ppc.pl
Richard Levitte [Sat, 16 Mar 2019 09:15:19 +0000 (10:15 +0100)]
Add missing '.text' in crypto/bn/asm/ppc.pl

Fixes #8495

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

(cherry picked from commit 2864df8f9d3264e19b49a246e272fb513f4c1be3)

5 years agoAdded NULL check to BN_clear() & BN_CTX_end()
Shane Lontis [Mon, 18 Mar 2019 23:58:09 +0000 (09:58 +1000)]
Added NULL check to BN_clear() & BN_CTX_end()

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

(cherry picked from commit ce1415ed2ce15305356cd028bcf7b9bc688d6d5c)

5 years agoClear the point S before freeing in ec_scalar_mul_ladder
Bernd Edlinger [Sun, 17 Mar 2019 16:28:24 +0000 (17:28 +0100)]
Clear the point S before freeing in ec_scalar_mul_ladder

The secret point R can be recovered from S using the equation R = S - P.
The X and Z coordinates should be sufficient for that.

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

(cherry picked from commit 8a74bb5c7becbd7492f4445b852602c3e88ba143)

5 years agoClear the secret point in ecdh_simple_compute_key
Bernd Edlinger [Sun, 17 Mar 2019 08:48:15 +0000 (09:48 +0100)]
Clear the secret point in ecdh_simple_compute_key

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

(cherry picked from commit 1ff2c992c24c330c0d40708b4169b862563d6aab)

5 years agoPPC assembly pack: fix copy-paste error in CTR mode
Daniel Axtens [Sun, 17 Mar 2019 23:22:44 +0000 (10:22 +1100)]
PPC assembly pack: fix copy-paste error in CTR mode

There are two copy-paste errors in handling CTR mode. When dealing
with a 2 or 3 block tail, the code branches to the CBC decryption exit
path, rather than to the CTR exit path.

This can lead to data corruption: in the Linux kernel we have a copy
of this file, and the bug leads to corruption of the IV, which leads
to data corruption when we call the encryption function again later to
encrypt subsequent blocks.

Originally reported to the Linux kernel by Ondrej Mosnáček <omosnacek@gmail.com>

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8510)

(cherry picked from commit f643deac417a3ccb27f77670bb2b136de49079d9)

5 years agocoverity fixes for bntest.c
Shane Lontis [Mon, 18 Mar 2019 00:39:07 +0000 (10:39 +1000)]
coverity fixes for bntest.c

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

(cherry picked from commit e2f5081116d8b3dadd602fcf611bc6584ab395f7)

5 years agoVMS: only use the high precision on VMS v8.4 and up
Dr. Matthias St. Pierre [Fri, 15 Mar 2019 00:48:51 +0000 (01:48 +0100)]
VMS: only use the high precision on VMS v8.4 and up

Fixes #8487
Amends #7230

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

(cherry picked from commit 355417eb4611014767480e5d3e96b1b08eb02700)

5 years agoFix memory leak in ectest
Nicola Tuveri [Wed, 13 Mar 2019 09:38:40 +0000 (11:38 +0200)]
Fix memory leak in ectest

Fixes #8462

(cherry picked from commit 81d61a62faa809e6c51f5fc2b86fb0d31146fd5e)

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

5 years agoFix memory leaks in pkread.c demo file
Matt Caswell [Tue, 12 Mar 2019 10:21:39 +0000 (10:21 +0000)]
Fix memory leaks in pkread.c demo file

Also make various changes to bring the file into line with current coding
style.

Fixes #8456

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

(cherry picked from commit 81cd023f1dc5a8c9094f8e91c1e85e3c9b98a551)

5 years agofix truncation of integers on 32bit AIX
Shane Lontis [Wed, 6 Mar 2019 02:57:09 +0000 (12:57 +1000)]
fix truncation of integers on 32bit AIX

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

(cherry picked from commit 98f29466dc1ed7f80b9b8750309a41b5a1150d25)

5 years agoFix two spelling errors
A. Schulze [Sat, 9 Mar 2019 18:05:31 +0000 (19:05 +0100)]
Fix two spelling errors

CLA: trivial

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

(cherry picked from commit 3dcbb6c4a395d56dfa561145d89017ff958bb18e)

5 years agoUpdate documentation of RSA_padding_check_PKCS1_OAEP_mgf1
Bernd Edlinger [Sun, 3 Mar 2019 13:25:52 +0000 (14:25 +0100)]
Update documentation of RSA_padding_check_PKCS1_OAEP_mgf1

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit f0e4a860d0b350e10a1ee3898445cac85af8ea16)

5 years agoDo the error handling in pkey_rsa_decrypt in constant time
Bernd Edlinger [Sun, 3 Mar 2019 09:36:57 +0000 (10:36 +0100)]
Do the error handling in pkey_rsa_decrypt in constant time

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit 049e64cbb08df1fbf256bb79e950e8d0959de091)

5 years agoAdd a simple test for RSA_SSLV23_PADDING
Bernd Edlinger [Sat, 2 Mar 2019 23:04:11 +0000 (00:04 +0100)]
Add a simple test for RSA_SSLV23_PADDING

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit ac6fff700a9799c25902165e2594fd46826f3ee3)

5 years agoUpdate documentation regarding required output buffer memory size
Bernd Edlinger [Fri, 1 Mar 2019 08:27:32 +0000 (09:27 +0100)]
Update documentation regarding required output buffer memory size
of RSA_private_decrypt/RSA_public_encrypt.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit b89fdeb2f7d4471cbfd8a579945754327a4e06a8)

5 years agoFix memory overrun in rsa padding check functions
Bernd Edlinger [Thu, 28 Feb 2019 09:08:18 +0000 (10:08 +0100)]
Fix memory overrun in rsa padding check functions

Fixes #8364 and #8357

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit d7f5e5ae6d53f1387a42d210806cf5e9ed0882d6)

5 years agoLimit DEVRANDOM_WAIT to linux
Bernd Edlinger [Thu, 7 Mar 2019 07:19:28 +0000 (08:19 +0100)]
Limit DEVRANDOM_WAIT to linux

Fixes #8416

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8428)

(cherry picked from commit 596521f48826892ddd62322726f6f2a2a52db652)

5 years agoAdd a test for underflow in ecp_nistp521.c
Matt Caswell [Wed, 6 Mar 2019 11:51:28 +0000 (11:51 +0000)]
Add a test for underflow in ecp_nistp521.c

The previous commit fixed an underflow that may occur in ecp_nistp521.c.
This commit adds a test for that condition. It is heavily based on an
original test harness by Billy Brumley.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8405)

(cherry picked from commit 6855b496b205c067ecb276221c31c6212f4fdbae)

5 years agoAvoid an underflow in ecp_nistp521.c
Matt Caswell [Tue, 5 Mar 2019 13:26:45 +0000 (13:26 +0000)]
Avoid an underflow in ecp_nistp521.c

The function felem_diff_128_64 in ecp_nistp521.c substracts the number |in|
from |out| mod p. In order to avoid underflow it first adds 32p mod p
(which is equivalent to 0 mod p) to |out|. The comments and variable naming
suggest that the original author intended to add 64p mod p. In fact it
has been shown that with certain unusual co-ordinates it is possible to
cause an underflow in this function when only adding 32p mod p while
performing a point double operation. By changing this to 64p mod p the
underflow is avoided.

It turns out to be quite difficult to construct points that satisfy the
underflow criteria although this has been done and the underflow
demonstrated. However none of these points are actually on the curve.
Finding points that satisfy the underflow criteria and are also *on* the
curve is considered significantly more difficult. For this reason we do
not believe that this issue is currently practically exploitable and
therefore no CVE has been assigned.

This only impacts builds using the enable-ec_nistp_64_gcc_128 Configure
option.

With thanks to Bo-Yin Yang, Billy Brumley and Dr Liu for their significant
help in investigating this issue.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8405)

(cherry picked from commit 13fbce17fc9f02e2401fc3868f3f8e02d6647e5f)

5 years agoUpdate ChaCha20-Poly1305 documentation
Matt Caswell [Tue, 5 Mar 2019 15:41:27 +0000 (15:41 +0000)]
Update ChaCha20-Poly1305 documentation

Correctly describe the maximum IV length.

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

(cherry picked from commit 27d5631236325c3fd8a3bd06af282ac496aac64b)

5 years agoTest an overlong ChaCha20-Poly1305 nonce
Matt Caswell [Tue, 5 Mar 2019 14:51:07 +0000 (14:51 +0000)]
Test an overlong ChaCha20-Poly1305 nonce

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

(cherry picked from commit a4f0b50eafb256bb802f2724fc7f7580fb0fbabc)

5 years agoPrevent over long nonces in ChaCha20-Poly1305
Matt Caswell [Tue, 5 Mar 2019 14:39:15 +0000 (14:39 +0000)]
Prevent over long nonces in ChaCha20-Poly1305

ChaCha20-Poly1305 is an AEAD cipher, and requires a unique nonce input for
every encryption operation. RFC 7539 specifies that the nonce value (IV)
should be 96 bits (12 bytes). OpenSSL allows a variable nonce length and
front pads the nonce with 0 bytes if it is less than 12 bytes. However it
also incorrectly allows a nonce to be set of up to 16 bytes. In this case
only the last 12 bytes are significant and any additional leading bytes are
ignored.

It is a requirement of using this cipher that nonce values are unique.
Messages encrypted using a reused nonce value are susceptible to serious
confidentiality and integrity attacks. If an application changes the
default nonce length to be longer than 12 bytes and then makes a change to
the leading bytes of the nonce expecting the new value to be a new unique
nonce then such an application could inadvertently encrypt messages with a
reused nonce.

Additionally the ignored bytes in a long nonce are not covered by the
integrity guarantee of this cipher. Any application that relies on the
integrity of these ignored leading bytes of a long nonce may be further
affected.

Any OpenSSL internal use of this cipher, including in SSL/TLS, is safe
because no such use sets such a long nonce value. However user
applications that use this cipher directly and set a non-default nonce
length to be longer than 12 bytes may be vulnerable.

CVE-2019-1543

Fixes #8345

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

(cherry picked from commit 2a3d0ee9d59156c48973592331404471aca886d6)

5 years agoDon't write the tick_identity to the session
Matt Caswell [Fri, 1 Mar 2019 15:40:20 +0000 (15:40 +0000)]
Don't write the tick_identity to the session

Sessions must be immutable once they can be shared with multiple threads.
We were breaking that rule by writing the ticket index into it during the
handshake. This can lead to incorrect behaviour, including failed
connections in multi-threaded environments.

Reported by David Benjamin.

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

(cherry picked from commit c96ce52ce293785b54a42d119c457aef739cc2ce)

5 years agoopenssl_strerror_r: Fix handling of GNU strerror_r
Vitezslav Cizek [Thu, 28 Feb 2019 12:47:18 +0000 (13:47 +0100)]
openssl_strerror_r: Fix handling of GNU strerror_r

GNU strerror_r may return either a pointer to a string that the function
stores in buf, or a pointer to some (immutable) static string in which case
buf is unused.

In such a case we need to set buf manually.

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

(cherry picked from commit e3b35d2b29e9446af83fcaa534e67e7b04a60d7a)

5 years agoFix seeding from random device w/o getrandom syscall
Bernd Edlinger [Thu, 14 Feb 2019 23:03:50 +0000 (00:03 +0100)]
Fix seeding from random device w/o getrandom syscall

Use select to wait for /dev/random in readable state,
but do not actually read anything from /dev/random,
use /dev/urandom first.

Use linux define __NR_getrandom instead of the
glibc define SYS_getrandom, in case the kernel headers
are more current than the glibc headers.

Fixes #8215

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8251)

(cherry picked from commit 38023b87f037f4b832c236dfce2a76272be08763)

5 years agodeps: add s390 asm rules for OpenSSL-1.1.1
Shigeki Ohtsu [Wed, 7 Mar 2018 14:52:52 +0000 (23:52 +0900)]
deps: add s390 asm rules for OpenSSL-1.1.1

Generate asm files with Makefile rules.

From:
- https://github.com/nodejs/node/commit/0d9a86c7cb3566b22becc656691282402f5026c0

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

5 years agoConfigure: support a few more "make variables" defaulting from env
Richard Levitte [Tue, 26 Feb 2019 22:18:02 +0000 (23:18 +0100)]
Configure: support a few more "make variables" defaulting from env

CFLAGS, CXXFLAGS, CPPFLAGS, LDFLAGS, and LDLIBS

(cherry picked from commit 8e7984e5783877c58cddc7b4e668401580ab4467)

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

5 years ago.travis.yml: change -std=c89 to -ansi
Richard Levitte [Tue, 26 Feb 2019 08:34:00 +0000 (09:34 +0100)]
.travis.yml: change -std=c89 to -ansi

For C, -ansi is equivalent to -std=c90
For C++, -ansi is equivalent to -std=c++98

We also place -ansi in CPPFLAGS instead of the usual command line config,
to avoid getting it when linking (clang complains)

(cherry picked from commit 874f785988c17991051d36a0407a87b36c463a94)

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

5 years agoConfiguration: divide devteam flags into language specific sets
Richard Levitte [Tue, 26 Feb 2019 08:32:52 +0000 (09:32 +0100)]
Configuration: divide devteam flags into language specific sets

Some of the devteam flags are not for C++

(cherry picked from commit e373c70a3e535b560f6b6bade914a724aa975c55)

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

5 years agoDo buildtests on our public header files with C++ as well
Richard Levitte [Mon, 25 Feb 2019 10:43:00 +0000 (11:43 +0100)]
Do buildtests on our public header files with C++ as well

This ensures that we don't mistakenly use C++ keywords anywhere public.

Related to #8313

(cherry picked from commit 9f27d4bf32c0465270e1922365b21825a0f7a42a)

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

5 years agoConfigure: make --strict-warnings a regular user provided compiler option
Richard Levitte [Thu, 14 Feb 2019 15:26:40 +0000 (16:26 +0100)]
Configure: make --strict-warnings a regular user provided compiler option

This makes `--strict-warnings` into a compiler pseudo-option, i.e. it
gets treated the same way as any other compiler option given on the
configuration command line, but is retroactively replaced by actual
compiler warning options, depending on what compiler is used.

This makes it easier to see in what order options are given to the
compiler from the configuration command line, i.e. this:

    ./config -Wall --strict-warnings

would give the compiler flags in the same order as they're given,
i.e.:

    -Wall -Werror -Wno-whatever ...

instead of what we got previously:

    -Werror -Wno-whatever ... -Wall

(cherry picked from commit fcee53948b7f9a5951d42f4ee321e706ea6b4b84)

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

5 years agocfi build fixes in x86-64 ghash assembly
Shane Lontis [Tue, 19 Feb 2019 03:56:33 +0000 (13:56 +1000)]
cfi build fixes in x86-64 ghash assembly

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

(cherry picked from commit 54d00677f305375eee65a0c9edb5f0980c5f020f)

5 years agoMake the padlock engine build correctly
Richard Levitte [Wed, 13 Feb 2019 03:23:14 +0000 (04:23 +0100)]
Make the padlock engine build correctly

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

(cherry picked from commit 149c12d5e41b238ce4af6d1b6b3a767b40293bd7)

5 years agoEnsure configured module specific and application specific defines are used
Richard Levitte [Wed, 13 Feb 2019 03:21:59 +0000 (04:21 +0100)]
Ensure configured module specific and application specific defines are used

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

(cherry picked from commit 2fce15b58b2502a614529707eb45b6e5cac4eb15)

5 years agoAdd PADLOCK_ASM to dso_defines rather than lib_defines
Richard Levitte [Wed, 13 Feb 2019 02:58:52 +0000 (03:58 +0100)]
Add PADLOCK_ASM to dso_defines rather than lib_defines

Since the padlock code is an engine, the assembler is for a module,
not a library link to when building a program...  there's a
distinction.

Fixes #2311

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

(cherry picked from commit 88780b1c5f6000fe6731fec74efe697bcf493b6c)

5 years agoFix the default digest algorthm of SM2
Paul Yang [Mon, 25 Feb 2019 09:34:03 +0000 (17:34 +0800)]
Fix the default digest algorthm of SM2

Currently SM2 shares the ameth with EC, so the current default digest
algorithm returned is SHA256. This fixes the default digest algorithm of
SM2 to SM3, which is the only valid digest algorithm for SM2 signature.

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

(cherry picked from commit e766f4a0531bffdab8ad2038279b755928d7a40a)

5 years agoRevert "Configure: stop forcing use of DEFINE macros in headers"
Richard Levitte [Fri, 15 Feb 2019 10:48:24 +0000 (11:48 +0100)]
Revert "Configure: stop forcing use of DEFINE macros in headers"

Github PR #8246 provides a better solution to the problem.

This reverts commit f11ffa505f8a9345145a26a05bf77b012b6941bd.

[extended tests]

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8247)

(cherry picked from commit 4089b4340701e3c13e07169e67a7d14519c98658)

5 years ago[test] modernize ecdsatest and extend ECDSA sign KATs
Billy Brumley [Sat, 23 Feb 2019 08:12:35 +0000 (10:12 +0200)]
[test] modernize ecdsatest and extend ECDSA sign KATs

(cherry picked from commit 1a31d8017ee7e8df0eca76fee601b826699c9ac1)

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8314)

5 years agoFix trivial typo in EVP_DigestVerifyInit doc
Nicola Tuveri [Sun, 24 Feb 2019 19:29:32 +0000 (21:29 +0200)]
Fix trivial typo in EVP_DigestVerifyInit doc

(cherry picked from commit b3883f77df33989b0d4298ca9a21d8595dd9a8c9)

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8319)

5 years agoPrepare for 1.1.1c-dev
Matt Caswell [Tue, 26 Feb 2019 14:17:50 +0000 (14:17 +0000)]
Prepare for 1.1.1c-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
5 years agoPrepare for 1.1.1b release OpenSSL_1_1_1b
Matt Caswell [Tue, 26 Feb 2019 14:15:30 +0000 (14:15 +0000)]
Prepare for 1.1.1b release

Reviewed-by: Richard Levitte <levitte@openssl.org>
5 years agoClarify that SSL_shutdown() must not be called after a fatal error
Matt Caswell [Wed, 20 Feb 2019 14:21:36 +0000 (14:21 +0000)]
Clarify that SSL_shutdown() must not be called after a fatal error

Follow on from CVE-2019-1559

Reviewed-by: Richard Levitte <levitte@openssl.org>
5 years agoUpdate copyright year
Matt Caswell [Tue, 26 Feb 2019 14:05:09 +0000 (14:05 +0000)]
Update copyright year

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