Граф коммитов

36 Коммитов

Автор SHA1 Сообщение Дата
Renato Golin 4a364317cb
Implement TLS in OpenSSL, support TLS 1.3 (#3361)
* Implement TLS in OpenSSL, support TLS 1.3

This is a large commit, implementing the TLS layer in OpenSSL,
together with mbedTLS, and is part of a transition to eliminate
mbedTLS from the codebase.

The src/crypto part is done already and this is a similar effort
on src/tls. The last part is src/clients (used for testing) and
will be done as a future patch, with extensive testing separate
than this work.

This commit has a temporary structure, to allow a compiler flag
to switch between OpenSSL and mbedTLS. Unlike src/crypto, we want
the transition to be as short lived as possible, so we didn't try
to create common classes, just an include trick to use the right
library.

The main changes, in order from most generic to most specific, are:

1.  The CMake flag `TLS_PROVIDER_IS_MBEDTLS` was introduced, turned
    OFF by default, to build CCF with mbedTLS instead of OpenSSL. This
    is for testing, in case we find issues with the new implementation.
    This is in addition to `CRYPTO_PROVIDER_IS_MBEDTLS` so we can set
    each flag independently.
2.  The OpenSSL library (`libssl`) that we use is from the same place
    we pick the Crypto library (`libcrypto`). Either the system or
    OpenEnclave, decided elsewhere. No new libraries are needed.
3.  Some of the existing mbedTLS headers were moved to src/clients to
    isolate that migration from the server side. So far, it only
    needed `ca.h` and `cert.h`, which are self-conatined. Those
    will be removed with the mbedTLS cleanup.
4.  A number of `#ifdef TLS_PROVIDER_IS_MBEDTLS` were added where
    there was no other way to common up implementation. Most notably
    in the previous TLS headers (`src/tls/*.h`) that are now just
    wrappers to the actual headers (`src/tls/{mbedtls,openssl}/*.h`).
5.  All TLS errors on both mbedTLS and OpenSSL have been #defined
    to a common set of `TLS_ERR_` errors, to allow for common error
    handlind, including `WANT_READ` and `WANT_WRITE`. To keep the
    mbedTLS way, OpenSSL has a hack to return the negative
    counterparts of the error codes, so that we can treat them as
    errors, like mbedTLS.
6.  To keep the current CCF implementation intact, we had to keep
    the callback mechanism in OpenSSL. This isn't the most natural
    way of handling BIOs but it works. Both `tls_endpoint` and
    `tls_test` have a similar implementation, handling asynchronous
    I/O. This should disappear later (probably well after removing
    mbedTLS from the codebase), once we manage to get BIOs directly
    to the users, from the OpenSSL implementation.
7.  A number of mbedTLS functionality, most notably in `context.h`,
    has been adapted to allow a common implementation between the
    two libraries, for example `peer_cert()` and `get_verify_error`.
8.  A copy of `crypto::error_string()` is present in the TLS side
    so that we can more easily control each (crypto/tls) with the
    CMake flags.
9.  A number of log messages were added or changed to convey more
    information to help diagnose TLS issues. Not all development
    log messages survived into the production patch, but those that
    did can still convey most of the information and help at least
    zero in on where you need to add more logs later.
10. Removed two unused methods in `Context`: `available_bytes` and
    `set_require_auth`. Those were never called and had no easy
    equivalent in OpenSSL. Added exceptions for some unused parameters
    in OpenSSL's `CA` and `Cert` to make sure we never use them.
    If those never hit on any further testing or benchmarking, then
    we're safe to remove them when we clean up mbedTLS.
11. Added a number of `FIXME` comments, highlighting the assumptions
    from reading the mbedTLS code and what the tests have shown it
    does/needs. Some of them may be wrong, and if so, we need to
    fix them before we start with the mbedTLS cleanup.
12. Added a very large `get_verify_error` in `OpenSSL::Context`
    with all errors the `verify_result` can throw. This wasn't
    really necessary but was added as a debugging tool. Once we're
    happy none of those weird corner cases happen on our code, we
    should really remove all unused ones and common up in a
    `case default:`, where developers can add specific ones later
    for debugging purposes again.
13. Updated the `tls_test` to handle multi-part messages (past 16K),
    supporting large messages, like `tls_endpoint`. Also truncated
    the large messages to make it easier to read the test logs.
14. Changed the e2e_logging.py large message range from 2^10
    (instead of 2^14), to help developers see some messages pass
    before the 16K threshold, which helped me realise what the
    problem was.
15. Added a long README document with all core issues with the port,
    and discussions on how to clean up in the future.

* Trying to fix the ubsan error

* Remove unnecessary FIXMEs

* Add FIXME to check-todo.sh

* We don't need MbedTLS entropy for OpenSSL

The entropy source isn't a generic implementation, but one based on
mbedTLS, which we don't need for OpenSSL. This removes the last
FIXME.

* Restrict SSL cipher to TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

To improve security and keep the same behaviour, this commit forces
specific TLS1.2 and TLS1.3 ciphers that were used in the mbedTLS
implementation.

This fixes all problems in the tls_report but one:
Secure Client-Initiated Renegotiation
 -> VULNERABLE (NOT ok), DoS threat (6 attempts)

This will be looked at on the next patch.

* Disable renegotiation to avoid DoS attacks

This makes the tls_report identical to previous mbedTLS.

* Free temporary BIOs in CA/Cert c-tors

Detected by leak sanitizers, but I should have known better...

* Use Unique_BIO|X509 in peer_cert to avoid leaks

Following the C-style code in OpenSSL's documentation was a bad
idea. Using unique_ptr wrappers to guarantee nothing leaks.

* Simplify get_verify_error to avoid UB on memcpy

Same as previous UB, writing at the end of a string. Using std::string
to avoid any memory manipulation by hand.

* Fix typos
2022-01-09 15:16:46 +00:00
Maik Riechert 3f67461a32
v8: assume UTC+0 (#3341) 2021-12-21 16:24:13 +00:00
Julien Maffre 8a2e99a990
Infra: cleanup `e2e_logging.py` (#3333) 2021-12-20 17:29:35 +00:00
Maik Riechert 918d1d4d37
Experimental V8 app (#3258) 2021-12-16 14:55:29 +00:00
Maik Riechert e6f12578b3
Minor V8 CI fixes (#3254) 2021-11-26 09:07:04 +00:00
Maik Riechert 52d7ee31a8
Update V8 scripts (#3246) 2021-11-25 14:21:52 +00:00
Renato Golin 19ccafa6a0
Fetch and improve V8 build (#3042) 2021-10-04 22:29:45 +01:00
Renato Golin 9f34501a0e
V8 pipeline publishing artifact (#3027) 2021-09-28 14:52:51 +01:00
Amaury Chamayou 40c6647bd7
upgrade_pip (#2934) 2021-09-02 15:35:27 +01:00
Eddy Ashton 9239d03832
Fix check-format.sh script: Pass -Werror (#2859) 2021-08-03 11:30:03 +01:00
Amaury Chamayou a43fd55f38
Clang 10 toolchain & default compiler updates (#2739) 2021-08-02 20:09:32 +01:00
Amaury Chamayou 5f7a4e0a91
Upgrade base images and playbooks to Ubuntu 20.04 (focal) (#2819) 2021-07-20 16:08:06 +01:00
Amaury Chamayou a8de00a46e
Clang 10 compatibility (#2736) 2021-06-28 11:15:23 +01:00
Eddy Ashton 8b1eea2dcd
Remove Lua governance and Lua dependency (#2465) 2021-04-14 19:14:40 +01:00
Maik Riechert 34ee8ab286
ci-checks.sh: don't save package[-lock].json (#2451) 2021-04-12 17:03:32 +01:00
Eddy Ashton 67370a99b0
Use pushd to always run ci-checks.sh in the project root (#2287) 2021-03-10 16:42:19 +00:00
Eddy Ashton 4fd9f5f309
Historic queries: Range queries and app-dictated handles (#2233) 2021-03-01 16:19:14 +00:00
Maik Riechert d9de671056
only check git-tracked files (#1995)
Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
2020-12-09 18:06:13 +00:00
Amaury Chamayou 1d979d94aa
Remove pbft notice (#1985)
* remove pbft notice

* Fix assert header
2020-12-04 22:04:14 +00:00
Amaury Chamayou 50e33fb75e
Add validator for OpenAPI spec (#1883) 2020-11-13 18:21:49 +00:00
Amaury Chamayou 82e4d007fd
Make what we can prettier (#1862) 2020-11-10 10:57:56 +00:00
Eddy Ashton ff2d0ba468
Add Vegeta stress test to CI (#1763) 2020-10-15 16:57:56 +01:00
Eddy Ashton 37452c19fe
Initial dynamic endpoints in JS app (#1744) 2020-10-14 14:05:10 +01:00
Maik Riechert 7098626ee2
Exported GitHub release notes to CHANGELOG.md & automate release note extraction (#1631) 2020-09-22 15:38:59 +01:00
Amaury Chamayou 8848ba89ae
python 3.7 to 3.8 (#1592) 2020-09-11 16:33:09 +01:00
Maik Riechert bff45590b8
fix ci-checks scripts (#1542)
Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
2020-08-28 10:31:29 +01:00
Eddy Ashton f80399a576
Pin cmake-format to 0.6.11 (#1509) 2020-08-19 11:50:01 +01:00
Julien Maffre 0bcc6a3d28
Python install cleanup (#1474)
* Cleanup dependencies

* Automated python package versioning

* Pin deps

* Install wheel

* Format

* Revert requirements.txt

* Pin deps manually

* Install package requirements for Pylint

Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
Co-authored-by: Eddy Ashton <edashton@microsoft.com>
2020-08-03 13:12:34 +01:00
Eddy Ashton ff49a625cf
Redirect cmake-format --check output to /dev/null (#1477) 2020-08-03 10:29:02 +01:00
Julien Maffre beedc9568d
Python type annotations (#1449) 2020-07-29 11:03:53 +01:00
Amaury Chamayou 83d427307c
OE 0.10 rc1 (#1409) 2020-07-16 18:34:12 +01:00
Julien Maffre b53a4445ce
Start packaging Python infra (#1380) 2020-07-07 15:46:44 +01:00
Julien Maffre 052d69eceb
Improve handling of node-to-node channels and host connections (#1371) 2020-07-03 12:02:26 +01:00
Eddy Ashton d6f1ee55dd
Use gitignore in notice-check.py (#1372) 2020-07-02 16:17:20 +01:00
Amaury Chamayou 9ed9d16c76
Run scan build in Daily (#1360) 2020-07-01 13:32:57 +01:00
Amaury Chamayou 6a2030aecd
Gather CI checks in a single entry point (#1359) 2020-06-30 10:44:54 +01:00