openssl.git
5 months agoAdd a test for SSL_CTX_new_with_libctx()
Matt Caswell [Wed, 15 Jan 2020 14:48:57 +0000 (14:48 +0000)]
Add a test for SSL_CTX_new_with_libctx()

We test that SSL_CTX_new_with_libctx() can be used to control the libctx
that is in use for SSL operations.

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

5 months agoUse the OPENSSL_CTX and property query string in EVP_PKEY_CTX
Matt Caswell [Wed, 15 Jan 2020 11:20:58 +0000 (11:20 +0000)]
Use the OPENSSL_CTX and property query string in EVP_PKEY_CTX

When we use an EVP_PKEY_CTX in libssl we should be doing so with the
OPENSSL_CTX and property query string that were specified when the
SSL_CTX object was first created.

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

5 months agoExplicitly fetch ciphers and digests in libssl
Matt Caswell [Thu, 16 Jan 2020 12:14:27 +0000 (12:14 +0000)]
Explicitly fetch ciphers and digests in libssl

We modify libssl to use explicitly fetched ciphers, digests and other
algorithms as required based on the configured library context and
property query string for the SSL_CTX that is being used.

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

5 months agoParams: change UTF8 construct calls to avoid explicit strlen(3) calls.
Pauli [Wed, 5 Feb 2020 05:13:49 +0000 (15:13 +1000)]
Params: change UTF8 construct calls to avoid explicit strlen(3) calls.

It is better, safer and smaller to let the library routine handle the
strlen(3) call.

Added a note to the documentation suggesting this.

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

5 months agoStop accepting certificates signed using SHA1 at security level 1
Kurt Roeckx [Thu, 2 Jan 2020 22:25:27 +0000 (23:25 +0100)]
Stop accepting certificates signed using SHA1 at security level 1

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
GH: #10786

5 months agoCreate a new embeddedSCTs1 that's signed using SHA256
Kurt Roeckx [Wed, 22 Jan 2020 23:24:35 +0000 (00:24 +0100)]
Create a new embeddedSCTs1 that's signed using SHA256

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
GH: #10786

5 months agoFix no-multiblock
Matt Caswell [Mon, 3 Feb 2020 15:30:05 +0000 (15:30 +0000)]
Fix no-multiblock

Minor fixes to resolve compilation errors with the no-multiblock
Configure option.

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

5 months agoAuthor: Ross Kinsey <RossIKinsey@gmail.com>
Ross Kinsey [Wed, 5 Feb 2020 03:47:05 +0000 (13:47 +1000)]
Author: Ross Kinsey <RossIKinsey@gmail.com>
Date:   Wed Jan 29 00:19:40 2020 -0500

Removed unnecessary switch statements from bio/bf_* callback_ctrl functions

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

5 months agox86: Add endbranch to indirect branch targets for Intel CET
H.J. Lu [Fri, 31 Jan 2020 13:07:01 +0000 (05:07 -0800)]
x86: Add endbranch to indirect branch targets for Intel CET

To support Intel CET, all indirect branch targets must start with
endbranch.  Here is a patch to add endbranch to all function entries
in x86 assembly codes which are indirect branch targets as discovered
by running openssl testsuite on Intel CET machine and visual inspection.

Since x86 cbc.pl uses indirect branch with a jump table, we also need
to add endbranch to all jump targets.

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

5 months agoMake minimum size for secure memory a size_t.
Pauli [Tue, 4 Feb 2020 23:09:29 +0000 (09:09 +1000)]
Make minimum size for secure memory a size_t.

The minimum size argument to CRYPTO_secure_malloc_init() was an int but ought
to be a size_t since it is a size.

From an API perspective, this is a change.  However, the minimum size is
verified as being a positive power of two and it will typically be a small
constant.

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from #11003)

5 months agoEVP_MD_CTX_ctrl(): Remove unnecessary control
Richard Levitte [Sun, 2 Feb 2020 12:09:29 +0000 (13:09 +0100)]
EVP_MD_CTX_ctrl(): Remove unnecessary control

A check was present as to what operation is performed with this
context.  It may have been useful at some point, but isn't any more.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10947)

5 months agoPROV: Fix the DSA SIGNATURE implementation for better digests handling
Richard Levitte [Sun, 2 Feb 2020 12:09:23 +0000 (13:09 +0100)]
PROV: Fix the DSA SIGNATURE implementation for better digests handling

Refactor the DSA SIGNATURE digest setup to be uniform, and to happen
in two places:

1. when given through the digestsign and digestverify inits
2. when given through the set_ctx_params function.

When setting up the digest, we also check that the digest is one of
the officially accepted for DSA.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10947)

5 months agoPROV: Implement padding mode words in the RSA ASYM_CIPHER implementation
Richard Levitte [Sun, 2 Feb 2020 12:09:09 +0000 (13:09 +0100)]
PROV: Implement padding mode words in the RSA ASYM_CIPHER implementation

Because the libcrypto code has relinquished control of exact words to
express padding mode choices, we re-implement them in the appropriate
provider implementation.

For the sake of legacy controls, we maintain support for the numeric
form of the padding mode, but leave that support otherwise undeclared.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10947)

5 months agoDon't pass a digest-size to signature implementations
Richard Levitte [Sun, 2 Feb 2020 11:55:05 +0000 (12:55 +0100)]
Don't pass a digest-size to signature implementations

It turns out this was never necessary, as the implementation should
always check the default digest size anyway.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10947)

5 months agoDecentralize legacy_ctrl_str_to_param()
Richard Levitte [Sat, 25 Jan 2020 11:27:47 +0000 (12:27 +0100)]
Decentralize legacy_ctrl_str_to_param()

This function did a bit too much in terms of central control, actually
more so than the legacy counterpart, where all the string processing
is done in the diverse *_pmeth.c.  Furthermore, there was no room
whatsoever for control keys that libcrypto isn't centrally aware of.

This function is changed to simply translating keys and values to
OSSL_PARAM form and then sent on their merry way to the provider
implementations through EVP_PKEY_CTX_set_params().  It translates
selected well known legacy names to their core name counterpart, and
that's as far as centralized control should extend.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10947)

5 months agoTeach more BIOs how to handle BIO_CTRL_EOF
Matt Caswell [Fri, 24 Jan 2020 16:07:51 +0000 (16:07 +0000)]
Teach more BIOs how to handle BIO_CTRL_EOF

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10907)

5 months agoDetect EOF while reading in libssl
Matt Caswell [Fri, 17 Jan 2020 17:39:19 +0000 (17:39 +0000)]
Detect EOF while reading in libssl

If we hit an EOF while reading in libssl then we will report an error
back to the application (SSL_ERROR_SYSCALL) but errno will be 0. We add
an error to the stack (which means we instead return SSL_ERROR_SSL) and
therefore give a hint as to what went wrong.

Contains a partial fix for #10880

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10907)

5 months agoDeprecate the ECDSA and EV_KEY_METHOD functions.
Pauli [Tue, 28 Jan 2020 05:14:18 +0000 (15:14 +1000)]
Deprecate the ECDSA and EV_KEY_METHOD functions.

Use of the low level ECDSA and EC_KEY_METHOD functions has been informally discouraged for a
long time. We now formally deprecate them.

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

5 months agoDeprecate the ECDH functions.
Pauli [Tue, 28 Jan 2020 02:38:47 +0000 (12:38 +1000)]
Deprecate the ECDH functions.

Use of the low level ECDH functions has been informally discouraged for a
long time. We now formally deprecate them.

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

5 months agoec.h: fix preprocessor indentation
Pauli [Tue, 28 Jan 2020 02:37:28 +0000 (12:37 +1000)]
ec.h: fix preprocessor indentation

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

5 months agoFix coverity issues CID 1457745...1457752, 1457853, 1457854
Shane Lontis [Tue, 4 Feb 2020 03:50:51 +0000 (13:50 +1000)]
Fix coverity issues CID 1457745...145775214578531457854

CID 1457854 - keymgmt_lib.c : OVERRUN
CID 1457853 - self_test_kats.c : UNINT
CID 1457752 - fipsprov.c RESOURCE_LEAK (code change in another PR removed this)
CID 1457751 - apps/pkcs12.c CHECKED_RETURN
CID 1457750 - dsa_ossl.c RESOURCE_LEAK (marked as false positive since tmp can not be NULL)
CID 1457749 - apps/nseq.c : CHECKED_RETURN
CID 1457748 - cipher_aes_cbc_hmac_sha.c : SIZEOF_MISMATCH
CID 1457747 - cipher_aes_cbc_hmac_sha.c : SIZEOF_MISMATCH
CID 1457746 - same as 1457752
CID 1457745 - apps/ocsp  : CHECKED_RETURN

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

5 months agoFix krb5 external test failure
Richard Levitte [Mon, 3 Feb 2020 15:34:58 +0000 (15:34 +0000)]
Fix krb5 external test failure

The krb5 test requires the legacy module to be loaded in order to work.
It also seems to be senstive to using relative paths, so we use absolute
ones instead.

[extended tests]

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

5 months agoMissing "obj_mac" header file in "dh_lib"
Davide Galassi [Sun, 2 Feb 2020 09:11:29 +0000 (10:11 +0100)]
Missing "obj_mac" header file in "dh_lib"

Usage of `NID_undef` symbol without including its definition was causing
a build fail

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10996)

5 months agoDon't complain about documented symbols with find-doc-nits -d -o
Matt Caswell [Fri, 31 Jan 2020 10:08:33 +0000 (10:08 +0000)]
Don't complain about documented symbols with find-doc-nits -d -o

find-doc-nits can give a list of symbols that were added since 1.1.1 and
are undocumented (using -o). To do this it uses the missingcrypto111.txt
and missingssl111.txt files which give a snapshot of the undocumented
symbols at the time of the 1.1.1 release. Currently it complains about
symbols that are in those files that have subsequently been documented.
This isn't particularly helpful so we suppress that feature when "-o"
is being used.

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

5 months agoFix common test framework options
Matt Caswell [Thu, 30 Jan 2020 15:30:17 +0000 (15:30 +0000)]
Fix common test framework options

PR#6975 added the ability to our test framework to have common options to
all tests. For example providing the option "-test 5" to one of our test
programs will just run test number 5. This can be useful when debugging
tests.

Unforuntately this does not work well for a number of tests. In particular
those tests that call test_get_argument() without first skipping over these
common test options will not get the expected value. Some tests did this
correctly but a large number did not.

A helper function is introduced, test_skip_common_options(), to make this
easier for those tests which do not have their own specialised test option
handling, but yet still need to call test_get_argument(). This function
call is then added to all those tests that need it.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10975)

5 months agoFix no-ec
Matt Caswell [Fri, 31 Jan 2020 23:58:53 +0000 (23:58 +0000)]
Fix no-ec

The cmp_protect_test cert chain tests use some EC certs which breaks in
a no-ec build. The fix is to just skip those tests if no-ec has been
configured.

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

5 months agoRevert "Legacy digests can have custom control values"
Matt Caswell [Fri, 31 Jan 2020 22:44:56 +0000 (22:44 +0000)]
Revert "Legacy digests can have custom control values"

This reverts commit 1f457256ce6a1b2fd7e3f62eee8faa74cd5c835e.

This is causing Travis failures.

[extended tests]

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10989)

5 months agoCHANGES: Add note about the refactoring of SM2 EVP_PKEYs
Richard Levitte [Thu, 30 Jan 2020 15:02:49 +0000 (16:02 +0100)]
CHANGES: Add note about the refactoring of SM2 EVP_PKEYs

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoAdapt some 'openssl' commands for SM2 changes.
Richard Levitte [Fri, 24 Jan 2020 17:45:23 +0000 (18:45 +0100)]
Adapt some 'openssl' commands for SM2 changes.

There's no longer any need to make an EVP_PKEY type change for SM2
keys, so we trim away that code.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoAdapt tests for SM2 changes.
Richard Levitte [Fri, 24 Jan 2020 17:14:53 +0000 (18:14 +0100)]
Adapt tests for SM2 changes.

With test/ecdsatest.c, we test all the curves once for each EC key
type we have, i.e. one round trip with EVP_PKEY_EC and one with
EVP_PKEY_SM2.  This shows that we can use "normal" EC computations on
keys with the SM2 curve (which have the type EVP_PKEY_SM2 by default)
and SM2 computations with any other curve (which have the type
EVP_PKEY_EC by default)

test/evp_test.c, on the other hand, doesn't need to explicitly set the
EVP_PKEY_SM2 alias type, as that now happens automatically.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoMake SM3 a mandatory hash function for SM2.
Richard Levitte [Fri, 24 Jan 2020 17:14:06 +0000 (18:14 +0100)]
Make SM3 a mandatory hash function for SM2.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoX509: Refactor X509_verify() and X509_REQ_verify() for better streamlining
Richard Levitte [Fri, 24 Jan 2020 17:04:19 +0000 (18:04 +0100)]
X509: Refactor X509_verify() and X509_REQ_verify() for better streamlining

The solution to incorporate the SM2 identity processing was an off
the side hack that more or less duplicated the ASN1_item_verify()
code with just a few lines being different.  We replace this with
a new function ASN1_item_verify_ctx(), which takes an EVP_MD_CTX
pointer instead of an EVP_PKEY pointer, just like its sibling
ASN1_item_sign_ctx().

This allows us to refactor X509_verify() and X509_REQ_verify() to
simply create a local EVP_MD_CTX and an attached EVP_PKEY_CTX,
which gets to hold the SM2 identity, if there is one, and then let
ASN1_item_verify_ctx() to its job.

This will also make it easier to adapt ASN1_item_verify_ctx() for
provider based keys.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoAdd SM2 specific parameter and key generation
Richard Levitte [Fri, 24 Jan 2020 16:59:03 +0000 (17:59 +0100)]
Add SM2 specific parameter and key generation

This makes it possible to generate SM2 parameters and keys like this:

    EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SM2);
    EVP_PKEY *pkey = EVP_PKEY_new();

    EVP_PKEY_keygen_init(pctx);
    EVP_PKEY_keygen(pctx, pkey);

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoEVP_PKEY_assign_EC_KEY(): detect SM2 curve and set EVP_PKEY type accordingly
Richard Levitte [Fri, 24 Jan 2020 16:51:39 +0000 (17:51 +0100)]
EVP_PKEY_assign_EC_KEY(): detect SM2 curve and set EVP_PKEY type accordingly

This means that when loaded or created, EC EVP_PKEYs with the SM2
curve will be regarded as EVP_PKEY_SM2 type keys by default.
Applications are no longer forced to check and fix this.

It's still possible, for those who want this, to set the key type to
EVP_PKEY_EC and thereby run the normal EC computations with the SM2
curve.  This has to be done explicitly.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10942)

5 months agoEVP: Small refactor of keymgmt library code
Richard Levitte [Tue, 28 Jan 2020 15:51:01 +0000 (16:51 +0100)]
EVP: Small refactor of keymgmt library code

Some functions went directly on keymgmt function pointers instead of
going through the internal KEYMGMT API, which makes for a confusing
read.

Related to #10962

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

5 months agoconfig: ensure the perl Configure run is the last statement
Richard Levitte [Mon, 27 Jan 2020 07:42:20 +0000 (08:42 +0100)]
config: ensure the perl Configure run is the last statement

Running any statement after Configure means we lose its exit code

Fixes #10951

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

5 months agoFix "ts" no-XXX options, document two TLS options
Rich Salz [Fri, 24 Jan 2020 17:33:05 +0000 (12:33 -0500)]
Fix "ts" no-XXX options, document two TLS options

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

5 months agoUpdate the SSL/TLS connection options
Rich Salz [Sat, 12 Oct 2019 21:45:56 +0000 (17:45 -0400)]
Update the SSL/TLS connection options

Refactor common flags for SSL/TLS connection options.
Update SSL_CONF_cmd.pod to match ordering.
Rewrite much of the documentation.

Fixes #10160

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

5 months agoevp_pmeth: free the MD reference correctly.
Pauli [Wed, 29 Jan 2020 23:35:37 +0000 (09:35 +1000)]
evp_pmeth: free the MD reference correctly.

The code was calling EVP_MD_meth_free which is incorrect.  It should call
EVP_MD_free.  It happened to work but by luck rather than design.

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

5 months agoscrypt: free the MD reference correctly.
Pauli [Wed, 29 Jan 2020 23:04:14 +0000 (09:04 +1000)]
scrypt: free the MD reference correctly.

The code was calling EVP_MD_meth_free which is incorrect.  It should call
EVP_MD_free.  It happened to work but by luck rather than design.

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

5 months agoAdd support for DH 'modp' group parameters (RFC 3526)
Shane Lontis [Thu, 30 Jan 2020 22:18:46 +0000 (08:18 +1000)]
Add support for DH 'modp' group parameters (RFC 3526)

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

5 months agoDon't acknowledge a servername following warning alert in servername cb
Matt Caswell [Mon, 2 Dec 2019 17:29:21 +0000 (17:29 +0000)]
Don't acknowledge a servername following warning alert in servername cb

If the servername cb decides to send back a warning alert then the
handshake continues, but we should not signal to the client that the
servername has been accepted.

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

5 months agoProvide better documentation for SSL_get_servername()
Matt Caswell [Thu, 28 Nov 2019 12:03:00 +0000 (12:03 +0000)]
Provide better documentation for SSL_get_servername()

The behaviour of SSL_get_servername() is quite complicated and depends on
numerous factors such as whether it is called on the client or the server,
whether it is called before or after the handshake, what protocol version
was negotiated, and whether a resumption was attempted or was successful.

We attempt to document the behavior more clearly.

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

5 months agoTest that SSL_get_servername returns what we expect
Matt Caswell [Thu, 26 Sep 2019 15:16:06 +0000 (16:16 +0100)]
Test that SSL_get_servername returns what we expect

Test this on both the client and the server after a normal handshake,
and after a resumption handshake. We also test what happens if an
inconsistent SNI is set between the original handshake and the resumption
handshake. Finally all of this is also tested in TLSv1.2 and TLSv1.3.

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

5 months agoFix SSL_get_servername() and SNI behaviour
Matt Caswell [Wed, 25 Sep 2019 16:06:06 +0000 (17:06 +0100)]
Fix SSL_get_servername() and SNI behaviour

The SNI behaviour for TLSv1.3 and the behaviour of SSL_get_servername()
was not quite right, and not entirely consistent with the RFC.

The TLSv1.3 RFC explicitly says that SNI is negotiated on each handshake
and the server is not required to associate it with the session. This was
not quite reflected in the code so we fix that.

Additionally there were some additional checks around early_data checking
that the SNI between the original session and this session were
consistent. In fact the RFC does not require any such checks, so they are
removed.

Finally the behaviour of SSL_get_servername() was not quite right. The
behaviour was not consistent between resumption and normal handshakes,
and also not quite consistent with historical behaviour. We clarify the
behaviour in various scenarios and also attempt to make it match historical
behaviour as closely as possible.

Fixes #8822

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

5 months agoFix type name typo in d2i/i2d documentation.
David Makepeace [Thu, 23 Jan 2020 01:07:18 +0000 (11:07 +1000)]
Fix type name typo in d2i/i2d documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10933)

5 months agoAdd -issuer_checks to verify options
Rich Salz [Fri, 24 Jan 2020 18:32:34 +0000 (13:32 -0500)]
Add -issuer_checks to verify options

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

5 months agoDocument most missing options
Rich Salz [Thu, 16 Jan 2020 18:40:52 +0000 (13:40 -0500)]
Document most missing options

Add cmd-nits make target.

Listing options should stop when it hits the "parameters" separator.

Add missing .pod.in files to doc/man1/build.info

Tweak find-doc-nits to try openssl-XXX before XXX for POD files and
change an error messavge to be more useful.

Fix the following pages: ca, cms, crl, dgst, enc,
engine, errstr, gendsa, genrsa, list, ocsp, passwd, pkcs7, pkcs12, rand,
rehash, req, rsautil, s_server, speed, s_time,
sess_id, smime, srp, ts, x509.

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

5 months agoAdd more generated man1 doc files
Rich Salz [Mon, 20 Jan 2020 14:45:27 +0000 (09:45 -0500)]
Add more generated man1 doc files

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

5 months agoAdd RSA key validation to default provider
Shane Lontis [Wed, 29 Jan 2020 10:32:32 +0000 (20:32 +1000)]
Add RSA key validation to default provider

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

5 months agoTLS: use EVP for HMAC throughout libssl.
Pauli [Fri, 24 Jan 2020 00:41:38 +0000 (10:41 +1000)]
TLS: use EVP for HMAC throughout libssl.

Backwards compatibility with the old ticket key call back is maintained.
This will be removed when the low level HMAC APIs are finally removed.

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

5 months agoDeprecate the low level HMAC functions
Pauli [Tue, 14 Jan 2020 02:11:50 +0000 (12:11 +1000)]
Deprecate the low level HMAC functions

Use of the low level HMAC functions has been informally discouraged for a
long time.  We now formally deprecate them.

Applications should instead use EVP_MAC_CTX_new(3), EVP_MAC_CTX_free(3),
EVP_MAC_init(3), EVP_MAC_update(3) and EVP_MAC_final(3).

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

5 months agohmac: preprocessor indentation fixes
Pauli [Tue, 14 Jan 2020 00:49:28 +0000 (10:49 +1000)]
hmac: preprocessor indentation fixes

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

5 months agoDeprecate the low level CMAC functions
Pauli [Tue, 14 Jan 2020 00:59:11 +0000 (10:59 +1000)]
Deprecate the low level CMAC functions

Use of the low level CMAC functions has been informally discouraged for a
long time.  We now formally deprecate them.

Applications should instead use EVP_MAC_CTX_new(3), EVP_MAC_CTX_free(3),
EVP_MAC_init(3), EVP_MAC_update(3) and EVP_MAC_final(3).

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

5 months agocmac: preprocessor indentation fixes
Pauli [Tue, 14 Jan 2020 00:48:48 +0000 (10:48 +1000)]
cmac: preprocessor indentation fixes

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

5 months agoAdapt X509_PUBKEY_set() for use with provided implementations
Richard Levitte [Sun, 12 Jan 2020 23:27:40 +0000 (00:27 +0100)]
Adapt X509_PUBKEY_set() for use with provided implementations

We do this by letting a serializer serialize the provider side key to
a DER blob formatted according to the SubjectPublicKeyInfo structure
(see RFC 5280), and deserialize it in libcrypto using the usual d2i
function.

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

5 months agotest_evp_extra_test.c: don't rely on exact parameter position
Richard Levitte [Wed, 22 Jan 2020 19:59:56 +0000 (20:59 +0100)]
test_evp_extra_test.c: don't rely on exact parameter position

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10920)

5 months agoPROV: Adapt the DSA signature implementation to provide Algorithmidentifiers
Richard Levitte [Tue, 21 Jan 2020 14:05:56 +0000 (15:05 +0100)]
PROV: Adapt the DSA signature implementation to provide Algorithmidentifiers

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10920)

5 months agoAdapt ASN1_item_sign_ctx() for use with provided keypairs
Richard Levitte [Tue, 21 Jan 2020 13:56:13 +0000 (14:56 +0100)]
Adapt ASN1_item_sign_ctx() for use with provided keypairs

The mechanism to do this is to ask the signature operation for the DER
encoded AlgorithmIdentifier that corresponds to the combination of
signature algorithm and digest algorithm.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10920)

5 months agoModify EVP_PKEY_CTX_new_from_pkey() to add a propquery parameter
Matt Caswell [Wed, 15 Jan 2020 11:10:43 +0000 (11:10 +0000)]
Modify EVP_PKEY_CTX_new_from_pkey() to add a propquery parameter

The function EVP_PKEY_CTX_new_from_pkey() infers the name of the
algorithm to fetch from the EVP_PKEY that has been supplied as an
argument. But there was no way to specify properties to be used during
that fetch.

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

5 months agoOpenSSL::Test: bring back the relative paths
Richard Levitte [Tue, 21 Jan 2020 06:53:40 +0000 (07:53 +0100)]
OpenSSL::Test: bring back the relative paths

Because there was a bug in File::Spec::Unix' abs2rel when it was given
relative paths as both PATH and BASE arguments, the directories we
deal with were made to be all absolute.  Unfortunately, this meant
getting paths in our verbose test output which are difficult to use
anywhere else (such as a separate test build made for comparison), due
to the constant need to edit all the paths all the time.

We're therefore getting back the relative paths, by doing an extra
abs2rel() in __srctop_file, __srctop_dir, __bldtop_file and
__bldtop_dir, with a 'Cwd::getcwd' call as BASE argument.

Fixes #10628

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

5 months agotest/recipes/30-test_evp.t: Fix multiple definition of @bffiles
Richard Levitte [Sat, 25 Jan 2020 06:55:36 +0000 (07:55 +0100)]
test/recipes/30-test_evp.t: Fix multiple definition of @bffiles

Curiously enough, perl only warned about the shadowing.  However, the
following 'plan' statement got disturbed somehow, as one could notice
the test counter say "11/?" instead of "11/25".

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10944)

5 months agoCheck that the default signature type is allowed
Kurt Roeckx [Thu, 2 Jan 2020 21:53:32 +0000 (22:53 +0100)]
Check that the default signature type is allowed

TLS < 1.2 has fixed signature algorithms: MD5+SHA1 for RSA and SHA1 for the
others. TLS 1.2 sends a list of supported ciphers, but allows not sending
it in which case SHA1 is used. TLS 1.3 makes sending the list mandatory.

When we didn't receive a list from the client, we always used the
defaults without checking that they are allowed by the configuration.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
GH: #10784

5 months agoReplace apps/server.pem with certificate with a sha256 signature.
Kurt Roeckx [Sun, 12 Jan 2020 15:44:01 +0000 (16:44 +0100)]
Replace apps/server.pem with certificate with a sha256 signature.

It replaces apps/server.pem that used a sha1 signature with a copy of
test/certs/servercert.pem that is uses sha256.

This caused the dtlstest to start failing. It's testing connection
sbetween a dtls client and server. In particular it was checking that if
we drop a record that the handshake recovers and still completes
successfully. The test iterates a number of times. The first time
through it drops the first record. The second time it drops the second
one, and so on. In order to do this it has a hard-coded value for the
expected number of records it should see in a handshake. That's ok
because we completely control both sides of the handshake and know what
records we expect to see. Small changes in message size would be
tolerated because that is unlikely to have an impact on the number of
records. Larger changes in message size however could increase or
decrease the number of records and hence cause the test to fail.

This particular test uses a mem bio which doesn't have all the CTRLs
that the dgram BIO has. When we are using a dgram BIO we query that BIO
to determine the MTU size. The smaller the MTU the more fragmented
handshakes become. Since the mem BIO doesn't report an MTU we use a
rather small default value and get quite a lot of records in our
handshake. This has the tendency to increase the likelihood of the
number of records changing in the test if the message size changes.

It so happens that the new server certificate is smaller than the old
one. AFAICT this is probably because the DNs for the Subject and Issuer
are significantly shorter than previously. The result is that the number
of records used to transmit the Certificate message is one less than it
was before. This actually has a knock on impact for subsequent messages
and how we fragment them resulting in one less ServerKeyExchange record
too (the actual size of the ServerKeyExchange message hasn't changed,
but where in that message it gets fragmented has). In total the number
of records used in the handshake has decreased by 2 with the new
server.pem file.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
GH: #10784

5 months agoEVP: Adapt EVP_PKEY Seal and Open for provider keys
Richard Levitte [Fri, 10 Jan 2020 23:04:56 +0000 (00:04 +0100)]
EVP: Adapt EVP_PKEY Seal and Open for provider keys

This affects the following function, which can now deal with provider
side keys:

- EVP_SealInit()
- EVP_OpenInit()

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10808)

5 months agoopenssl-config: add example libssl system-defaults
Benjamin Kaduk [Fri, 24 Jan 2020 01:08:34 +0000 (17:08 -0800)]
openssl-config: add example libssl system-defaults

Provide a "simple" example for affecting the systemwide default behavior
of libssl.  The large number of mandatory nested sections makes this
less simple than the main description might suggest.

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

5 months agoDeprecate the low level DES functions.
Pauli [Thu, 16 Jan 2020 03:50:03 +0000 (13:50 +1000)]
Deprecate the low level DES functions.

Use of the low level DES functions has been informally discouraged for a
long time. We now formally deprecate them.

Applications should instead use the EVP APIs, e.g. EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_EncryptFinal_ex, and the equivalently named decrypt
functions.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10858)

5 months agodes: fix header file preprocessor indentation
Pauli [Thu, 16 Jan 2020 03:17:25 +0000 (13:17 +1000)]
des: fix header file preprocessor indentation

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10858)

5 months agoMake sure we use RAND_bytes_ex and RAND_priv_bytes_ex in libssl
Matt Caswell [Wed, 15 Jan 2020 18:12:59 +0000 (18:12 +0000)]
Make sure we use RAND_bytes_ex and RAND_priv_bytes_ex in libssl

Now that libssl knows about libctx we should use it wherever we generate
a random number.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10927)

5 months agoNew functions for PKCS8 attributes management - documentation
Dmitry Belyavskiy [Mon, 20 Jan 2020 13:02:26 +0000 (16:02 +0300)]
New functions for PKCS8 attributes management - documentation

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10900)

5 months agoNew functions for PKCS8 attributes management
Dmitry Belyavskiy [Mon, 20 Jan 2020 13:01:02 +0000 (16:01 +0300)]
New functions for PKCS8 attributes management

This commit introduces functions PKCS8_pkey_add1_attr_by_OBJ and PKCS8_pkey_add1_attr

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10900)

5 months agoModify DSA and DH keys to use a shared FFC_PARAMS struct
Shane Lontis [Fri, 24 Jan 2020 04:09:33 +0000 (14:09 +1000)]
Modify DSA and DH keys to use a shared FFC_PARAMS struct

This is required in order to share code for FIPS related parameter generation and validation routinues.
Note the 'counter' field is now stored as a integer (as that is the form required for generation/validation functions).

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

5 months agoUpdate man3/verify documentation, error text
Rich Salz [Sat, 12 Oct 2019 21:45:56 +0000 (17:45 -0400)]
Update man3/verify documentation, error text

Move the x509_V_ERR_xxx definitions from openssl-verify to
X509_STORE_CTX_get_error.pod.  Add some missing ones.  Consistently
start with a lowercase letter, unless it's an acronym.

Fix some markup mistakes in X509_verify_cert.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/10132)

5 months agoConfigure: Better detection of '-static' in @{$config{LDFLAGS}}
Richard Levitte [Fri, 17 Jan 2020 11:47:44 +0000 (12:47 +0100)]
Configure: Better detection of '-static' in @{$config{LDFLAGS}}

@{$config{LDFLAGS}} isn't necessarily split up in pieces, so we need
to check for '-static' with a regexp rather than with an exact string
match.

Fixes #10867

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

5 months agoAdd answers for EVP_PKEY_get_default_digest_name() in RSA and DSA keymgmt
Richard Levitte [Mon, 13 Jan 2020 07:54:47 +0000 (08:54 +0100)]
Add answers for EVP_PKEY_get_default_digest_name() in RSA and DSA keymgmt

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

5 months agoEVP: Add EVP_PKEY_get_default_digest_name() and use it
Richard Levitte [Mon, 13 Jan 2020 07:49:44 +0000 (08:49 +0100)]
EVP: Add EVP_PKEY_get_default_digest_name() and use it

It is the provider version of EVP_PKEY_get_default_digest_nid().  We make
sure to use it in the non-legacy section of do_sigver_init() (internal
implementation for EVP_DigestSignInit() and EVP_DigestVerifyInit())

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

5 months agoAdd internal maxsize macros
Richard Levitte [Wed, 22 Jan 2020 13:00:21 +0000 (14:00 +0100)]
Add internal maxsize macros

We've started to see "magic" numbers being used for certain sizes,
such as algorithm names and property query strings.

This change takes care of the few items where buffers for algorithm
names and property query strings are used.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10928)

5 months agoPROV: Fix bignum printout in text serializers
Richard Levitte [Sun, 19 Jan 2020 08:04:08 +0000 (09:04 +0100)]
PROV: Fix bignum printout in text serializers

The common routine ossl_prov_print_labeled_bignum() didn't print the
BIGNUM quite the way it should.  It treated the limbs in a big endian
fashion, when they are really organised in a little endian fashion.

Furthermore, we make it inherit the behaviour from the print of legacy
keys, where a number starting with the high bit set gets an extra zero
printed first.

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

5 months agoAdd DH key exchange to fips provider
Shane Lontis [Thu, 23 Jan 2020 10:33:28 +0000 (20:33 +1000)]
Add DH key exchange to fips provider

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

5 months agoCheck ECC-CDH is compliant with SP800-56A-r3
Shane Lontis [Thu, 23 Jan 2020 10:17:05 +0000 (20:17 +1000)]
Check ECC-CDH is compliant with SP800-56A-r3

Added comments and cleared an intermediate result.
KAT tests already exist in evppkey.txt (Search for "KAS_ECC_CDH_PrimitiveTest")

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

5 months agoRe-remove TS_VERIFY_CTX_set_certs entry from missingcrypto.txt
Shane Lontis [Thu, 23 Jan 2020 00:18:34 +0000 (10:18 +1000)]
Re-remove TS_VERIFY_CTX_set_certs entry from missingcrypto.txt

make doc-nits was failing due to a merge error on master in missingcrypto.txt.

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

5 months agoAvoid leak in error path of PKCS5_PBE_keyivgen
kinichiro [Sun, 12 Jan 2020 08:35:39 +0000 (17:35 +0900)]
Avoid leak in error path of PKCS5_PBE_keyivgen

CLA: trivial

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

5 months agoLegacy digests can have custom control values
Dmitry Belyavskiy [Tue, 21 Jan 2020 17:08:38 +0000 (20:08 +0300)]
Legacy digests can have custom control values

Fixes #10915.

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

5 months agoDo not silently truncate files on perlasm errors
David Benjamin [Fri, 17 Jan 2020 21:53:56 +0000 (16:53 -0500)]
Do not silently truncate files on perlasm errors

If one of the perlasm xlate drivers crashes, OpenSSL's build will
currently swallow the error and silently truncate the output to however
far the driver got. This will hopefully fail to build, but better to
check such things.

Handle this by checking for errors when closing STDOUT (which is a pipe
to the xlate driver).

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

5 months agoRussian Elbrus processors support
Dmitry Belyavskiy [Mon, 20 Jan 2020 13:25:43 +0000 (16:25 +0300)]
Russian Elbrus processors support

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10901)

5 months agoAdd missing files to generated
Rich Salz [Mon, 13 Jan 2020 18:48:08 +0000 (13:48 -0500)]
Add missing files to generated

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10256)

5 months agoFix some missing doc links.
Rich Salz [Thu, 24 Oct 2019 20:40:11 +0000 (16:40 -0400)]
Fix some missing doc links.

Replace "=for openssl foreign manuals" with simpler syntax, it looks
like the "=for openssl ifdef" construct.
Fix some broken L<> links; add some missing foreign references and fixed
some typo's.
The WARNINGS in dhparam referred to non-existant commands so reword it.

Fixes #10109

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10256)

5 months agoDocument the SSL_CTX_with_libctx() function
Matt Caswell [Thu, 16 Jan 2020 12:29:01 +0000 (12:29 +0000)]
Document the SSL_CTX_with_libctx() function

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

5 months agoIntroduce SSL_CTX_new_with_libex()
Matt Caswell [Thu, 16 Jan 2020 12:13:09 +0000 (12:13 +0000)]
Introduce SSL_CTX_new_with_libex()

We add the ability to specify an OPENSSL_CTX (which may be NULL for the
default context) and a property query string for use during algorithm
fetch operations.

For example, in this way one SSL_CTX could be used the default provider,
and another one could be used with the FIPS provider.

At this stage we don't use these values. That will come later.

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

5 months agoPROV: Add support for error queue marks and implement in FIPS module
Richard Levitte [Wed, 15 Jan 2020 13:09:54 +0000 (14:09 +0100)]
PROV: Add support for error queue marks and implement in FIPS module

This propagates ERR_set_mark(), and ERR_clear_last_mark() and
ERR_pop_to_mark() for provider use.

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

5 months agoEVP: clear error when falling back from failed EVP_KEYMGMT_fetch()
Richard Levitte [Fri, 10 Jan 2020 16:50:03 +0000 (17:50 +0100)]
EVP: clear error when falling back from failed EVP_KEYMGMT_fetch()

Since we're falling back to legacy, this isn't an error any more.
Among others the failed EVP_KEYMGMT_fetch() error shadows other errors
produced by the legacy code, which disrupts our test/evp_test runs.

We use the error stack mark to restore the error stack just right,
i.e. ERR_set_mark(), ERR_clear_last_mark() and ERR_pop_to_mark()

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

5 months agoFix unwind info in crypto/rc4/asm/rc4-x86_64.pl
H.J. Lu [Thu, 16 Jan 2020 21:37:14 +0000 (13:37 -0800)]
Fix unwind info in crypto/rc4/asm/rc4-x86_64.pl

Move .cfi_startproc to the right place for RC4.  Add missing
.cfi_startproc and .cfi_endproc to RC4_options.

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

5 months agoImplement the NULL cipher in the default provider
Matt Caswell [Wed, 8 Jan 2020 16:16:22 +0000 (16:16 +0000)]
Implement the NULL cipher in the default provider

Libssl uses the null cipher in certain situations. It should be
converted to a provided cipher.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10865)

5 months agoConvert rand_bytes_ex and rand_priv_bytes_ex to public functions
Matt Caswell [Wed, 15 Jan 2020 16:34:55 +0000 (16:34 +0000)]
Convert rand_bytes_ex and rand_priv_bytes_ex to public functions

These were initially added as internal functions only. However they will
also need to be used by libssl as well. Therefore it make sense to move
them into the public API.

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

5 months agoDon't register drbg_delete_thread_state twice
Matt Caswell [Wed, 15 Jan 2020 18:11:04 +0000 (18:11 +0000)]
Don't register drbg_delete_thread_state twice

drbg_delete_thread_state cleans up after both the public and the private
DRBG. It can be registered automtically by getting either of those DRBGs,
but it should not be registered twice.

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

5 months agoFix init_thread_stop
Matt Caswell [Wed, 15 Jan 2020 18:10:03 +0000 (18:10 +0000)]
Fix init_thread_stop

init_thread_stop maintains a linked lists of handlers that it should
call when a thread finishes. The linked list handling wasn't quite right
resulting in corrupted data.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10863)

5 months agolibssl: Eliminate as much use of EVP_PKEY_size() as possible
Matt Caswell [Fri, 10 Jan 2020 14:16:30 +0000 (14:16 +0000)]
libssl: Eliminate as much use of EVP_PKEY_size() as possible

Some uses were going against documented recommendations.

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

5 months agolibcrypto: Eliminate as much use of EVP_PKEY_size() as possible
Richard Levitte [Thu, 9 Jan 2020 20:38:47 +0000 (21:38 +0100)]
libcrypto: Eliminate as much use of EVP_PKEY_size() as possible

Some uses were going against documented recommendations.

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

5 months agoAPPS & TEST: Eliminate as much use of EVP_PKEY_size() as possible
Richard Levitte [Thu, 9 Jan 2020 20:37:32 +0000 (21:37 +0100)]
APPS & TEST: Eliminate as much use of EVP_PKEY_size() as possible

Some uses were going against documented recommendations.

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

5 months agomdc2: use evp_test instead of a separate test application.
Pauli [Mon, 13 Jan 2020 22:01:34 +0000 (08:01 +1000)]
mdc2: use evp_test instead of a separate test application.

One of the MDC2 test applications can be done using evp_test.
This makes it so.

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