oweals/openssl.git
4 years ago[PROV][EC] Update documentation
Nicola Tuveri [Sun, 9 Feb 2020 11:56:27 +0000 (13:56 +0200)]
[PROV][EC] Update documentation

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

4 years ago[BN] harden `BN_copy()` against leaks from memory accesses
Nicola Tuveri [Tue, 21 Jan 2020 15:08:16 +0000 (17:08 +0200)]
[BN] harden `BN_copy()` against leaks from memory accesses

`BN_copy()` (and indirectly `BN_dup()`) do not propagate the
`BN_FLG_CONSTTIME` flag: the propagation has been turned on and off a
few times in the past years, because in some conditions it has shown
unintended consequences in some code paths.

Without turning the propagation on once more, we can still improve
`BN_copy()` by avoiding to leak `src->top` in case `src` is flagged with
`BN_FLG_CONSTTIME`.
In this case we can instead use `src->dmax` as the number of words
allocated for `dst` and for the `memcpy` operation.

Barring compiler or runtime optimizations, if the caller provides `src`
flagged as const time and preallocated to a public size, no leak should
happen due to the copy operation.

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

4 years ago[EC] harden EC_KEY against leaks from memory accesses
Nicola Tuveri [Tue, 21 Jan 2020 15:00:41 +0000 (17:00 +0200)]
[EC] harden EC_KEY against leaks from memory accesses

We should never leak the bit length of the secret scalar in the key,
so we always set the `BN_FLG_CONSTTIME` flag on the internal `BIGNUM`
holding the secret scalar.

This is important also because `BN_dup()` (and `BN_copy()`) do not
propagate the `BN_FLG_CONSTTIME` flag from the source `BIGNUM`, and
this brings an extra risk of inadvertently losing the flag, even when
the called specifically set it.

The propagation has been turned on and off a few times in the past
years because in some conditions has shown unintended consequences in
some code paths, so at the moment we can't fix this in the BN layer.

In `EC_KEY_set_private_key()` we can work around the propagation by
manually setting the flag after `BN_dup()` as we know for sure that
inside the EC module the `BN_FLG_CONSTTIME` is always treated
correctly and should not generate unintended consequences.

Setting the `BN_FLG_CONSTTIME` flag alone is never enough, we also have
to preallocate the `BIGNUM` internal buffer to a fixed public size big
enough that operations performed during the processing never trigger
a realloc which would leak the size of the scalar through memory
accesses.

Fixed Length
------------

The order of the large prime subgroup of the curve is our choice for
a fixed public size, as that is generally the upper bound for
generating a private key in EC cryptosystems and should fit all valid
secret scalars.

For preallocating the `BIGNUM` storage we look at the number of "words"
required for the internal representation of the order, and we
preallocate 2 extra "words" in case any of the subsequent processing
might temporarily overflow the order length.

Future work
-----------

A separate commit addresses further hardening of `BN_copy()` (and
indirectly `BN_dup()`).

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

4 years ago[PROV][KEYMGMT][EC] Import/export of priv_key as padded const time BN
Nicola Tuveri [Tue, 21 Jan 2020 14:48:49 +0000 (16:48 +0200)]
[PROV][KEYMGMT][EC] Import/export of priv_key as padded const time BN

For EC keys it is particularly important to avoid leaking the bit length
of the secret scalar.

Key import/export should never leak the bit length of the secret
scalar in the key.

For this reason, on export we use padded BIGNUMs with fixed length,
using the new `ossl_param_bld_push_BN_pad()`.

When importing we also should make sure that, even if short lived,
the newly created BIGNUM is marked with the BN_FLG_CONSTTIME flag as
soon as possible, so that any processing of this BIGNUM might opt for
constant time implementations in the backend.

Setting the BN_FLG_CONSTTIME flag alone is never enough, we also have
to preallocate the BIGNUM internal buffer to a fixed size big enough
that operations performed during the processing never trigger a
realloc which would leak the size of the scalar through memory
accesses.

Fixed length
------------

The order of the large prime subgroup of the curve is our choice for
a fixed public size, as that is generally the upper bound for
generating a private key in EC cryptosystems and should fit all valid
secret scalars.

For padding on export we just use the bit length of the order
converted to bytes (rounding up).

For preallocating the BIGNUM storage we look at the number of "words"
required for the internal representation of the order, and we
preallocate 2 extra "words" in case any of the subsequent processing
might temporarily overflow the order length.

Future work
-----------

To ensure the flag and fixed size preallocation persists upon
`EC_KEY_set_private_key()`, we need to further harden
`EC_KEY_set_private_key()` and `BN_copy()`.
This is done in separate commits.

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

4 years ago[PROV][KMGMT][KEXCH][EC] Implement EC keymgtm and ECDH
Nicola Tuveri [Sat, 14 Dec 2019 22:20:53 +0000 (00:20 +0200)]
[PROV][KMGMT][KEXCH][EC] Implement EC keymgtm and ECDH

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

4 years ago[CMS] Test decryption of a ciphertext encrypted from 1.1.1
Nicola Tuveri [Sat, 25 Jan 2020 16:19:56 +0000 (18:19 +0200)]
[CMS] Test decryption of a ciphertext encrypted from 1.1.1

Current CMS en/decryption tests only validate that our current decyption
and encryption algorithms are compatible, but they say nothing about
correctness of the output for the given set of parameters.

As a partial fix in absence of proper KAT tests, we decrypt ciphertexts
generated with OpenSSL 1.1.1.

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

4 years ago[EC] Constify internal EC_KEY pointer usage
Nicola Tuveri [Mon, 6 Jan 2020 23:19:13 +0000 (01:19 +0200)]
[EC] Constify internal EC_KEY pointer usage

A pair of internal functions related to EC_KEY handling could benefit
from declaring `EC_KEY *` variables as `const`, providing clarity for
callers and readers of the code, in addition to enlisting the compiler
in preventing some mistakes.

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

4 years ago[PROV][KEYMGMT][DH][DSA] use BN_clear_free for secrets
Nicola Tuveri [Sat, 14 Dec 2019 22:29:34 +0000 (00:29 +0200)]
[PROV][KEYMGMT][DH][DSA] use BN_clear_free for secrets

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

4 years agox86_64: Don't assume 8-byte pointer size
H.J. Lu [Thu, 9 Jan 2020 14:20:09 +0000 (06:20 -0800)]
x86_64: Don't assume 8-byte pointer size

Since pointer in x32 is 4 bytes, add x86_64-support.pl to define
pointer_size and pointer_register based on flavour to support
stuctures like:

struct {  void *ptr; int blocks;  }

This fixes 90-test_sslapi.t on x32.  Verified with

$ ./Configure shared linux-x86_64
$ make
$ make test

and

$ ./Configure shared linux-x32
$ make
$ make test

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

4 years agoDOC:Fix typos in x509v3_config.pod
Alex Boboc [Sun, 16 Feb 2020 20:07:41 +0000 (12:07 -0800)]
DOC:Fix typos in x509v3_config.pod

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11104)

4 years agoDOC:Fix typos in man5/config.pod
Alex Boboc [Sun, 16 Feb 2020 20:04:12 +0000 (12:04 -0800)]
DOC:Fix typos in man5/config.pod

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11104)

4 years agoDOC:Fix typos in openssl-enc.pod.in + openssl.pod
Alex Boboc [Sun, 16 Feb 2020 19:56:11 +0000 (11:56 -0800)]
DOC:Fix typos in openssl-enc.pod.in + openssl.pod

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11104)

4 years agoDOC:Fix typos in ossl_cmp_print_log.pod
Alex Boboc [Sun, 16 Feb 2020 19:25:51 +0000 (11:25 -0800)]
DOC:Fix typos in ossl_cmp_print_log.pod

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11104)

4 years agoDOC:Fix typos in ossl_param_bld_init
Alex Boboc [Sun, 16 Feb 2020 00:55:30 +0000 (16:55 -0800)]
DOC:Fix typos in ossl_param_bld_init

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11104)

4 years agoDeprecate EC command line apps.
Pauli [Wed, 12 Feb 2020 00:10:44 +0000 (10:10 +1000)]
Deprecate EC command line apps.

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

4 years agoTEST: Optionally silence OpenSSL::Test::setup()
Richard Levitte [Sat, 15 Feb 2020 06:18:57 +0000 (07:18 +0100)]
TEST: Optionally silence OpenSSL::Test::setup()

test/generate_ssl_tests.pl uses OpenSSL::Test to get to some of its
practical location functions.  A recent note in the setup() code made
its result not quite match the original (we do check that), so there's
a need to silence setup(), which we do with a simple optional argument.

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

4 years agoTEST: Modify test/recipes/tconversion.pl to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 07:46:54 +0000 (08:46 +0100)]
TEST: Modify test/recipes/tconversion.pl to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/80-test_ssl_old.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 07:43:28 +0000 (08:43 +0100)]
TEST: Modify test/recipes/80-test_ssl_old.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/80-test_ssl_new.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 07:42:05 +0000 (08:42 +0100)]
TEST: Modify test/recipes/80-test_ssl_new.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/80-test_ocsp.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 07:37:32 +0000 (08:37 +0100)]
TEST: Modify test/recipes/80-test_ocsp.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/80-test_cms.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 07:34:40 +0000 (08:34 +0100)]
TEST: Modify test/recipes/80-test_cms.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/80-test_ca.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 06:16:25 +0000 (07:16 +0100)]
TEST: Modify test/recipes/80-test_ca.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/20-test_pkeyutl.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 06:01:15 +0000 (07:01 +0100)]
TEST: Modify test/recipes/20-test_pkeyutl.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/20-test_enc_more.t to leave artifacts behind
Richard Levitte [Fri, 14 Feb 2020 05:56:04 +0000 (06:56 +0100)]
TEST: Modify test/recipes/20-test_enc_more.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/25-test_x509.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 23:28:47 +0000 (00:28 +0100)]
TEST: Modify test/recipes/25-test_x509.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/25-test_req.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 23:28:31 +0000 (00:28 +0100)]
TEST: Modify test/recipes/25-test_req.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/25-test_crl.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 23:28:16 +0000 (00:28 +0100)]
TEST: Modify test/recipes/25-test_crl.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/20-test_enc.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 23:28:02 +0000 (00:28 +0100)]
TEST: Modify test/recipes/20-test_enc.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/20-test_dgst.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 19:29:33 +0000 (20:29 +0100)]
TEST: Modify test/recipes/20-test_dgst.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/15-test_rsapss.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 19:29:20 +0000 (20:29 +0100)]
TEST: Modify test/recipes/15-test_rsapss.t to leave artifacts behind

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

4 years agoTEST: Modify test/recipes/15-test_mp_rsa.t to leave artifacts behind
Richard Levitte [Wed, 12 Feb 2020 19:29:04 +0000 (20:29 +0100)]
TEST: Modify test/recipes/15-test_mp_rsa.t to leave artifacts behind

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

4 years agoTEST: Create test specific output directories
Richard Levitte [Wed, 12 Feb 2020 19:22:42 +0000 (20:22 +0100)]
TEST: Create test specific output directories

We had all tests run with test/test-runs/ as working directory, and
tests cleaned up after themselves...  which is well and good, until
you want to have a look at what went wrong when a complex test fails,
and you have to recreate everything it does manually.

To remedy this, we have OpenSSL::Test create the result directory
dynamically (and cleaning it up first if it's already there) and let
the test recipe have that as working directory.

Test recipes are now encouraged to name their diverse output files
uniquely, and not to clean them up, to allow a developer to have a
look at the files that were produced.

With continuous integration that allows this, the result directories
could also be archived and be left as a build artifact.

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

4 years agoDOC: Add documentation related to X509_LOOKUPs
Richard Levitte [Fri, 31 Jan 2020 14:35:46 +0000 (15:35 +0100)]
DOC: Add documentation related to X509_LOOKUPs

Most of all, the base X509_LOOKUP functionality is now documented.
Furthermore, the names X509_LOOKUP_METHOD and X509_STORE are added for
reference.

Some functions were moved from X509_LOOKUP_meth_new.pod

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

4 years agoFix podchecker warnings
Richard Levitte [Sat, 8 Feb 2020 19:20:47 +0000 (20:20 +0100)]
Fix podchecker warnings

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

4 years agoMake util/find-doc-nits runnable from the build tree
Richard Levitte [Sat, 8 Feb 2020 19:15:06 +0000 (20:15 +0100)]
Make util/find-doc-nits runnable from the build tree

Because we generate an increasing number of POD files, some of them
end up in the build tree.  This makes it difficult for find-doc-nits
to work as desired when the build tree is separate from the source
tree.

The best supported way to make it work in such an environment is to
run it from the build tree and let it use the build information from
configdata.pm to find all the POD files.  To make this smooth enough,
we add a function 'files' that returns an array of file names
corresponding to criteria from the caller.

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

4 years agoffc: use sizeof(*pointer) instead of sizeof(struct) in memset(3) call.
Pauli [Sun, 16 Feb 2020 08:02:38 +0000 (18:02 +1000)]
ffc: use sizeof(*pointer) instead of sizeof(struct) in memset(3) call.

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

4 years agoCoverity 1458438: fix uninitialised memory access.
Pauli [Sun, 16 Feb 2020 08:02:03 +0000 (18:02 +1000)]
Coverity 1458438: fix uninitialised memory access.

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

4 years agoCoverity 1458439: fix resource leak
Pauli [Sun, 16 Feb 2020 07:58:45 +0000 (17:58 +1000)]
Coverity 1458439: fix resource leak

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

4 years agochunk 7 of CMP contribution to OpenSSL
Dr. David von Oheimb [Sat, 15 Feb 2020 13:57:32 +0000 (14:57 +0100)]
chunk 7 of CMP contribution to OpenSSL

add CMP message validation and related tests; while doing so:
* add ERR_add_error_mem_bio() to crypto/err/err_prn.c
* move ossl_cmp_add_error_txt() as ERR_add_error_txt() to crypto/err/err_prn.c
* add X509_STORE_CTX_print_verify_cb() to crypto/x509/t_x509.c,
  adding internally x509_print_ex_brief(), print_certs(), and print_store_certs()
* move {ossl_cmp_,}X509_STORE_get1_certs() to crypto/x509/x509_lu.c

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

4 years agofix various formatting nits in CMP contribution chunks 1-6 found by the new util...
Dr. David von Oheimb [Fri, 13 Dec 2019 19:07:08 +0000 (20:07 +0100)]
fix various formatting nits in CMP contribution chunks 1-6 found by the new util/check-format.pl

in addition:
correct wording in doc, comments, and parameter names: self-signed -> self-issued where appropriate

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

4 years agoimprove CMP logging according to comments on CMP chunk 7 preview
Dr. David von Oheimb [Fri, 13 Dec 2019 18:50:20 +0000 (19:50 +0100)]
improve CMP logging according to comments on CMP chunk 7 preview

in particular:
consolidate documentation of CMP logging and error reporting functions
fix compilation problem with clang on some platforms
rename OSSL_CMP_log etc. to ossl_cmp_log etc. since these macros are CMP-internal
move chopping of trailing separator to ossl_cmp_add_error_txt(), also fix handling of leading separator
internalize X509_print_ex_brief() as x509_print_ex_brief()

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

4 years agoadd internal doc files actually belonging to CMP contribution chunk 6
Dr. David von Oheimb [Fri, 13 Dec 2019 17:54:15 +0000 (18:54 +0100)]
add internal doc files actually belonging to CMP contribution chunk 6

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

4 years agoAlso check for errors in x86_64-xlate.pl.
David Benjamin [Mon, 17 Feb 2020 02:17:53 +0000 (12:17 +1000)]
Also check for errors in x86_64-xlate.pl.

In https://github.com/openssl/openssl/pull/10883, I'd meant to exclude
the perlasm drivers since they aren't opening pipes and do not
particularly need it, but I only noticed x86_64-xlate.pl, so
arm-xlate.pl and ppc-xlate.pl got the change.

That seems to have been fine, so be consistent and also apply the change
to x86_64-xlate.pl. Checking for errors is generally a good idea.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David Benjamin <davidben@google.com>
(Merged from https://github.com/openssl/openssl/pull/10930)

4 years agoAdd $debug variable and use it
Rich Salz [Wed, 15 Jan 2020 16:41:07 +0000 (11:41 -0500)]
Add $debug variable and use it

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

4 years agoFix a bug for aarch64 BigEndian
simplelins [Fri, 3 Jan 2020 14:56:18 +0000 (22:56 +0800)]
Fix a bug for aarch64 BigEndian
FIXES #10692 #10638
a bug for aarch64 bigendian with instructions 'st1' and 'ld1' on AES-GCM mode.

CLA: trivial

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

4 years agocrypto/bn: fix debug build
Wataru Ashihara [Sat, 1 Feb 2020 06:01:40 +0000 (15:01 +0900)]
crypto/bn: fix debug build

Fixes:

    gcc  -I. -Iinclude -Iproviders/common/include -Iproviders/implementations/include -Icrypto/include  -DSTATIC_LEGACY -DBN_DEBUG -DREF_DEBUG     -DCONF_DEBUG -DBN_CTX_DEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror      -DOPENSSL_BUILDING_OPENSSL -DOPENSSLDIR="\"/home/wsh/opt/openssl/ssl\"" -DENGINESDIR="\"/home/wsh/opt/openssl/lib/engines-3\""     -DMODULESDIR="\"/home/wsh/opt/openssl/lib/ossl-modules\""   -MMD -MF crypto/bn/libcrypto-lib-bn_conv.d.tmp -MT crypto/bn/libcrypto-lib-bn_conv.o -c -o crypto/bn/libcrypto-lib-bn_conv.o crypto/bn/bn_conv.c
    In file included from crypto/bn/bn_conv.c:12:
    crypto/bn/bn_conv.c: In function 'BN_hex2bn':
    crypto/bn/bn_local.h:178:31: error: implicit declaration of function 'ossl_assert'; did you mean 'ossl_ssize_t'? [-Werror=implicit-function-declaration]
                             (void)ossl_assert((_top == 0 && !_bnum2->neg) || \
                                   ^~~~~~~~~~~
    crypto/bn/bn_conv.c:188:5: note: in expansion of macro 'bn_check_top'
         bn_check_top(ret);
         ^~~~~~~~~~~~

CLA: trivial

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

4 years agoAdd FFC param/key validation
Shane Lontis [Sun, 16 Feb 2020 03:03:46 +0000 (13:03 +1000)]
Add FFC param/key validation

Embed libctx in dsa and dh objects and cleanup internal methods to not pass libctx (This makes it consistent with the rsa changes)

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

4 years agox86_64: Add endbranch at function entries for Intel CET
H.J. Lu [Fri, 31 Jan 2020 12:17:26 +0000 (04:17 -0800)]
x86_64: Add endbranch at function entries for Intel CET

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

Verified with

$ CC="gcc -Wl,-z,cet-report=error" ./Configure shared linux-x86_64 -fcf-protection
$ make
$ make test

and

$ CC="gcc -mx32 -Wl,-z,cet-report=error" ./Configure shared linux-x32 -fcf-protection
$ make
$ make test # <<< passed with https://github.com/openssl/openssl/pull/10988

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

4 years agoinclude/openssl/whrlpool.h: correct unbalanced deprecation guards
Richard Levitte [Thu, 13 Feb 2020 11:50:32 +0000 (12:50 +0100)]
include/openssl/whrlpool.h: correct unbalanced deprecation guards

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

4 years agoDOC: document in more detail what a BIO_read_ex() via BIO_f_buffer() does
Richard Levitte [Sun, 19 Jan 2020 02:19:31 +0000 (03:19 +0100)]
DOC: document in more detail what a BIO_read_ex() via BIO_f_buffer() does

The BIO_f_buffer() documentation tells in enough detail how it affects
BIO_gets(), but not how it affects BIO_read_ex().  This change
remedies that.

Fixes #10859

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

4 years agoDocument OSSL_SERIALIZER_PUBKEY_TO_DER_PQ and friends
Richard Levitte [Wed, 12 Feb 2020 12:05:09 +0000 (13:05 +0100)]
Document OSSL_SERIALIZER_PUBKEY_TO_DER_PQ and friends

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

4 years agoPROV: Build the main FIPS module code with FIPS_MODE defined
Richard Levitte [Thu, 13 Feb 2020 17:17:43 +0000 (18:17 +0100)]
PROV: Build the main FIPS module code with FIPS_MODE defined

Without that, its main source wasn't compiled correctly.

Fixes #11089

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

4 years agoapps x509: passing PKCS#11 URL as -signkey
Bastian Germann [Thu, 13 Feb 2020 10:58:27 +0000 (11:58 +0100)]
apps x509: passing PKCS#11 URL as -signkey

OpenSSL 1.1.0 has extended option checking, and rejects passing a PKCS#11
engine URL to "-signkey" option. The actual code is ready to take it.

Change the option parsing to allow an engine URL to be passed and modify
the manpage accordingly.

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/11086)

4 years agoMake secure-memory be a config option
Rich Salz [Wed, 5 Feb 2020 19:28:37 +0000 (14:28 -0500)]
Make secure-memory be a config option

Adding support for "no-secure-memory" was simple, a one-liner.
Fixing all the "ifdef OPENSSL_SECURE_MEMORY" to be "ifndef NO_xxx"
was a bit more work.  My original goof, for not following the OpenSSL
pattern "ifndef NO_" used everywhere else.

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

4 years agoAdapt i2d_PUBKEY for provider only keys
Richard Levitte [Wed, 12 Feb 2020 17:58:15 +0000 (18:58 +0100)]
Adapt i2d_PUBKEY for provider only keys

It uses EVP_PKEY serializers to get the desired results.

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

4 years agoAdapt i2d_PrivateKey for provider only keys
Richard Levitte [Tue, 11 Feb 2020 05:29:08 +0000 (06:29 +0100)]
Adapt i2d_PrivateKey for provider only keys

It uses EVP_PKEY serializers to get the desired results.

One might think that ddoing this might make things a bit dicy for
existing serializers, as they should obviously use i2d functions.
However, since our serializers use much more primitive functions
such as i2d_ASN1_INTEGER(), or keytype specific ones such as
i2d_RSAPrivateKey(), there is no clash.

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

4 years agoForgotten GOST2012 support in non-vital places
Nikolay Morozov [Wed, 12 Feb 2020 12:20:41 +0000 (15:20 +0300)]
Forgotten GOST2012 support in non-vital places

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/11072)

4 years agodsatest: fix the non-deprecated version of the test run.
Pauli [Wed, 12 Feb 2020 22:02:08 +0000 (08:02 +1000)]
dsatest: fix the non-deprecated version of the test run.

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

4 years agoApps: don't build deprecated DH and DSA apps.
Pauli [Wed, 12 Feb 2020 10:05:29 +0000 (20:05 +1000)]
Apps: don't build deprecated DH and DSA apps.

This also means that there doesn't need to be any conditional checks in the .c
files to avoid deprecated builds.

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

4 years agoFix coverity issues
Shane Lontis [Mon, 10 Feb 2020 01:45:27 +0000 (11:45 +1000)]
Fix coverity issues

CID : 1458169 RESOURCE LEAK ffc_params_generate.c - False positive, but addressed another Leak in adjacent code
CID : 1458171 UNCHECKED RET apps/pkeyutl.c
CID : 1458173 DEAD CODE ffc_params_generate.c
CID : 1458174 RESOURCE LEAK ssl_lib.c

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

4 years agox86_64: Always generate .note.gnu.property section for ELF outputs
H.J. Lu [Fri, 31 Jan 2020 17:13:27 +0000 (09:13 -0800)]
x86_64: Always generate .note.gnu.property section for ELF outputs

We should always generate .note.gnu.property section in x86_64 assembly
codes for ELF outputs to mark Intel CET support since all input files
must be marked with Intel CET support in order for linker to mark output
with Intel CET support.  Also .note.gnu.property section in x32 should
be aligned to 4 bytes, not 8 bytes and .p2align should be used
consistently.

Verified with

$ CC="gcc -Wl,-z,cet-report=error" ./Configure shared linux-x86_64 -fcf-protection
$ make
$ make test

and

$ CC="gcc -mx32 -Wl,-z,cet-report=error" ./Configure shared linux-x32 -fcf-protection
$ make
$ make test # <<< 90-test_sslapi.t failed because 8-byte pointer size.

Fix #10896

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

4 years agoFix a mem leak in libssl
Matt Caswell [Wed, 12 Feb 2020 11:55:30 +0000 (11:55 +0000)]
Fix a mem leak in libssl

Make sure we free up any ENGINE references after we have finished using
them.

Fixes #11064

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

4 years agoAdd Asymmetric RSA cipher tests in FIPS provider
Matt Caswell [Fri, 17 Jan 2020 15:54:09 +0000 (15:54 +0000)]
Add Asymmetric RSA cipher tests in FIPS provider

We also add some DSA tests for code that is already in the FIPS provider.

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

4 years agoMake the RSA ASYM_CIPHER implementation available inside the FIPS module
Matt Caswell [Fri, 17 Jan 2020 14:47:18 +0000 (14:47 +0000)]
Make the RSA ASYM_CIPHER implementation available inside the FIPS module

RSA ASYM_CIPHER was already available within the default provider. We
now make it also available from inside the FIPS module.

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

4 years agoAdd assembly config targets for UEFI build
Christopher J Zurcher [Thu, 6 Feb 2020 02:56:53 +0000 (18:56 -0800)]
Add assembly config targets for UEFI build

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

4 years agoFix no-ec build
Matt Caswell [Wed, 12 Feb 2020 09:19:41 +0000 (09:19 +0000)]
Fix no-ec build

Don't attempt to build ecx related source files in a "no-ec" build.

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

4 years agoAdd OSSL_SERIALIZER_PUBKEY_TO_DER_PQ and friends
Richard Levitte [Tue, 11 Feb 2020 05:23:58 +0000 (06:23 +0100)]
Add OSSL_SERIALIZER_PUBKEY_TO_DER_PQ and friends

It's already used internally, there's no reason the DER serializer
propqueries shouldn't be present alongside the PEM and TEXT ones.

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

4 years agofix build for new HTTP client in case OPENSSL_NO_CMP or OPENSSL_NO_OCSP
Dr. David von Oheimb [Tue, 11 Feb 2020 15:07:00 +0000 (16:07 +0100)]
fix build for new HTTP client in case OPENSSL_NO_CMP or OPENSSL_NO_OCSP

fix also formatting nits w.r.t. #if indentations in ocsp.h

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11058)

4 years agoRemove unused ossl_param_bld_to_param_ex() function.
Pauli [Mon, 10 Feb 2020 23:19:19 +0000 (09:19 +1000)]
Remove unused ossl_param_bld_to_param_ex() function.

The recently introduced ossl_param_bld_to_param_ex() function is only
called by the unit tests.

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

4 years agoRemove unused OSSL_PARAM_construct_from_text() function.
Pauli [Mon, 10 Feb 2020 23:13:33 +0000 (09:13 +1000)]
Remove unused OSSL_PARAM_construct_from_text() function.

This function is recently introduced and never called by the library or tests.

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

4 years agoAdd NEWS entry about deprecation of command line public tools
Pauli [Mon, 10 Feb 2020 00:23:57 +0000 (10:23 +1000)]
Add NEWS entry about deprecation of command line public tools

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

4 years agodsa: deprecate applications that depend on the low level DSA functions.
Pauli [Thu, 6 Feb 2020 22:09:53 +0000 (08:09 +1000)]
dsa: deprecate applications that depend on the low level DSA functions.

speed is updated to not support DSA instead of being removed.

The dhparam, dsaparam, dsa and gendsa commands are deprecated but still
exist without NO_DEPRECATED defined.

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

4 years agoapp: add a deprecation warning to all deprecated commands.
Pauli [Wed, 5 Feb 2020 01:27:23 +0000 (11:27 +1000)]
app: add a deprecation warning to all deprecated commands.

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

4 years agotest/recipes/80-test_ssl_old.t: Replace 'openssl gendsa'
Richard Levitte [Thu, 6 Feb 2020 11:12:49 +0000 (12:12 +0100)]
test/recipes/80-test_ssl_old.t: Replace 'openssl gendsa'

Use 'openssl genpkey' instead.

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

4 years agotest_dsa: fix deprecation logic
Pauli [Thu, 6 Feb 2020 23:00:15 +0000 (09:00 +1000)]
test_dsa: fix deprecation logic

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

4 years agotest/recipes/15-test_dsa.t: Deal with deprecation of 'openssl dsa'
Richard Levitte [Thu, 6 Feb 2020 11:10:23 +0000 (12:10 +0100)]
test/recipes/15-test_dsa.t: Deal with deprecation of 'openssl dsa'

Do not run programs that depend on deprecated APIs when
'no-deprecated' is configured.

We still retain the conversion tests that use 'openssl pkey', and add
the one that's missing.

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

4 years agoDeprecate the low level DSA functions.
Pauli [Wed, 29 Jan 2020 21:23:39 +0000 (07:23 +1000)]
Deprecate the low level DSA functions.

Use of the low level DSA 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/10977)

4 years agodsa.h: fix preprocessor indentation
Pauli [Wed, 29 Jan 2020 04:40:43 +0000 (14:40 +1000)]
dsa.h: fix preprocessor indentation

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

4 years agoDSA: fix the DSA parameter logic in test.
Pauli [Mon, 3 Feb 2020 01:41:31 +0000 (11:41 +1000)]
DSA: fix the DSA parameter logic in test.

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

4 years agoAdd S390 support for provider based X25519/X448
Matt Caswell [Tue, 4 Feb 2020 16:41:19 +0000 (16:41 +0000)]
Add S390 support for provider based X25519/X448

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoAdd X25519/X448 Key Exchange to the default provider
Matt Caswell [Fri, 24 Jan 2020 17:13:40 +0000 (17:13 +0000)]
Add X25519/X448 Key Exchange to the default provider

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoImplement Provider side Key Management for X25519 and X448
Matt Caswell [Mon, 27 Jan 2020 16:57:03 +0000 (16:57 +0000)]
Implement Provider side Key Management for X25519 and X448

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoImplement a stricter ECX_KEY type
Matt Caswell [Mon, 27 Jan 2020 16:50:47 +0000 (16:50 +0000)]
Implement a stricter ECX_KEY type

Add ref counting and control how we allocate storage for the private key.
We will need this type in following commits where we move the ecx code
to be provider aware.

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)

4 years agoCheck that ed25519 and ed448 are allowed by the security level
Kurt Roeckx [Sun, 9 Feb 2020 18:28:15 +0000 (19:28 +0100)]
Check that ed25519 and ed448 are allowed by the security level

Signature algorithms not using an MD weren't checked that they're
allowed by the security level.

Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #10785

4 years agoGenerate new Ed488 certificates
Kurt Roeckx [Thu, 2 Jan 2020 22:16:30 +0000 (23:16 +0100)]
Generate new Ed488 certificates

Create a whole chain of Ed488 certificates so that we can use it at security
level 4 (192 bit). We had an 2048 bit RSA (112 bit, level 2) root sign the
Ed488 certificate using SHA256 (128 bit, level 3).

Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #10785

4 years agoAdd a minimal build target for Travis and Appveyor
Bernd Edlinger [Fri, 13 Sep 2019 07:24:53 +0000 (09:24 +0200)]
Add a minimal build target for Travis and Appveyor

[extended tests]

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

4 years agoX509_PUBKEY_set(): Fix memory leak
Richard Levitte [Fri, 7 Feb 2020 08:13:21 +0000 (09:13 +0100)]
X509_PUBKEY_set(): Fix memory leak

With the provided method of creating the new X509_PUBKEY, an extra
EVP_PKEY is created and needs to be properly cleaned away.

(note: we could choose to keep it just as well, but there are
consequences, explained in a comment in the code)

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

4 years agoGeneralize the HTTP client so far implemented mostly in crypto/ocsp/ocsp_ht.c
Dr. David von Oheimb [Wed, 30 Oct 2019 22:39:35 +0000 (23:39 +0100)]
Generalize the HTTP client so far implemented mostly in crypto/ocsp/ocsp_ht.c
The new client has become an independent libcrpyto module in crypto/http/ and
* can handle any types of requests and responses (ASN.1-encoded and plain)
* does not include potentially busy loops when waiting for responses but
* makes use of a new timeout mechanism integrated with socket-based BIO
* supports the use of HTTP proxies and TLS, including HTTPS over proxies
* supports HTTP redirection via codes 301 and 302 for GET requests
* returns more useful diagnostics in various error situations
Also adapts - and strongly simplifies - hitherto uses of HTTP in crypto/ocsp/,
crypto/x509/x_all.c, apps/lib/apps.c, and apps/{ocsp,s_client,s_server}.c

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/10667)

4 years agoadd BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() improving timeout support
Dr. David von Oheimb [Tue, 4 Feb 2020 08:55:35 +0000 (09:55 +0100)]
add BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() improving timeout support

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/10667)

4 years agoPROV: Ensure the AlgorithmIdentifier registers in DSA signature impl
Richard Levitte [Fri, 7 Feb 2020 08:09:50 +0000 (09:09 +0100)]
PROV: Ensure the AlgorithmIdentifier registers in DSA signature impl

When setting up the hash function for DSA signature, the encoded
AlgorithmIdentifier for the DSA+hash combination is queried, but not
stored, which leads to problems when signing ASN.1 items in libcrypto.

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

4 years agoMemory allocator code cleanup
Davide Galassi [Mon, 10 Feb 2020 06:49:10 +0000 (16:49 +1000)]
Memory allocator code cleanup

Typedefs of CRYPTO malloc, realloc and free.

MEM_CHECK "modes" are used only as a CRYPTO_mem_ctrl() parameter

The CRYPTO_mem_ctrl is defined only if OPENSSL_NO_CRYPTO_MDEBUG is
defined, thus define the MEM_CHECK modes under the same condition.

Maybe the macros can be removed at all since:
1. CRYPTO_mem_ctrl() just returns -1 and ignores the parameter
2. CRYPTO_mem_ctr() is declared as DEPRECATED by 3.0

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

4 years agox86: Always generate .note.gnu.property section for ELF outputs
H.J. Lu [Sat, 14 Dec 2019 17:48:18 +0000 (09:48 -0800)]
x86: Always generate .note.gnu.property section for ELF outputs

We should always generate .note.gnu.property section in x86 assembly
codes for ELF outputs to mark Intel CET support since all input files
must be marked with Intel CET support in order for linker to mark output
with Intel CET support.

Verified with

$ CC="gcc -Wl,-z,cet-report=error" ./Configure shared linux-x86 -fcf-protection
$ make
$ make test

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

4 years agoDon't compile AESNI code if we're not AESNI capable
Matt Caswell [Wed, 5 Feb 2020 17:42:40 +0000 (17:42 +0000)]
Don't compile AESNI code if we're not AESNI capable

Compile failures were occuring on systems that weren't AESNI capable
because the detection wasn't quite right in a couple of files.

This fixes a run-checker build failure for the 386 compile option.

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

4 years agoFix no-des
Matt Caswell [Thu, 6 Feb 2020 16:59:49 +0000 (16:59 +0000)]
Fix no-des

Don't attempt to self-test DES in the FIPS provider if we have been built
without FIPS support.

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

4 years agoFix no-engine
Matt Caswell [Thu, 6 Feb 2020 15:54:09 +0000 (15:54 +0000)]
Fix no-engine

We don't need to check if an engine has a cipher/digest in a no-engine
build.

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

4 years agoFix no-dh
Matt Caswell [Thu, 6 Feb 2020 15:30:24 +0000 (15:30 +0000)]
Fix no-dh

Don't use DH specific macros that might need to be used in a no-dh build.

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

4 years agoFix no-ec
Matt Caswell [Thu, 6 Feb 2020 15:17:28 +0000 (15:17 +0000)]
Fix no-ec

Recent SM2 related changes were not properly guarded with OPENSSL_NO_EC

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

4 years agoUse swapcontext for Intel CET
H.J. Lu [Sat, 14 Dec 2019 00:46:07 +0000 (16:46 -0800)]
Use swapcontext for Intel CET

When Intel CET is enabled, makecontext will create a different shadow
stack for each context.  async_fibre_swapcontext cannot use _longjmp.
It must call swapcontext to swap shadow stack as well as normal stack.

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

4 years agoAdapt all build.info and test recipes to the new $disabled{'deprecated-x.y'}
Richard Levitte [Thu, 6 Feb 2020 10:31:41 +0000 (11:31 +0100)]
Adapt all build.info and test recipes to the new $disabled{'deprecated-x.y'}

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

4 years agoConfigure: Add easy to use disabled deprecated functionality indicators
Richard Levitte [Thu, 6 Feb 2020 10:26:22 +0000 (11:26 +0100)]
Configure: Add easy to use disabled deprecated functionality indicators

In C, we have macros like OPENSSL_NO_DEPRECATED_3_0 to check if some
section of code should be disabled to simulate a removal of things
deprecated in the version.

In perl, we had to check $disabled{deprecated} and compare
$config{api} with the proper version code, which is doable but tedious
and error prone.

This change adds $disabled{'deprecated-x.y'} (x.y being a version
number) which directly corresponds to OPENSSL_NO_DEPRECATED_x_y, for
use in build.info conditions, test recipes and other perl stuff.

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