Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/mbedtls-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# The compatibility layer needs wolfSSL master, not a release
wolfssl-ref: [ master ]
# The compatibility layer needs wolfSSL master, not a release. The
# verify callbacks need this pull request until it merges.
wolfssl-ref: [ pull/11110/head ]
options: [ "", "MBEDTLS_THREADING_C=1 ASAN=1" ]

steps:
Expand All @@ -27,8 +28,12 @@ jobs:
sudo apt-get update
sudo apt-get install -y build-essential autoconf automake libtool libtool-bin pkg-config python3-jinja2 faketime

- name: Clone sibling wolfSSL
run: git clone --depth 1 --branch ${{ matrix.wolfssl-ref }} https://github.com/wolfSSL/wolfssl ../wolfssl
# Fetched by ref, which may be a pull request's
- name: Fetch sibling wolfSSL
run: |
git init -q ../wolfssl
git -C ../wolfssl fetch -q --depth 1 https://github.com/wolfSSL/wolfssl ${{ matrix.wolfssl-ref }}
git -C ../wolfssl checkout -q FETCH_HEAD

# The tests need framework's data files, and tf-psa-crypto's headers for
# the test certificates
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ make MBEDTLS_COMPAT=1
for example with `WOLFCRYPT_ONLY`, `MBEDTLS_SSL_TLS_C` is not defined.
`MBEDTLS_NET_C` needs TLS and wolfSSL's socket I/O (no `WOLFSSL_USER_IO`).
`MBEDTLS_PEM_PARSE_C` needs wolfCrypt's Base64 decoding (no `NO_CODING`).
- The verify callbacks need `WOLFSSL_ALWAYS_VERIFY_CB`, which wolfPSA's
`user_settings.h` defines. A build with its own `USER_SETTINGS_PATH`
defines it too.

Mapped so far:

Expand All @@ -134,28 +137,30 @@ Mapped so far:
- x509_crt: init, free, parse, parse_der, parse_file, parse_path; the
default, next and suiteb profiles, as names only
- ssl_config: init, free, defaults; ssl_conf: authmode, ca_chain, own_cert,
min_tls_version, max_tls_version, ciphersuites, cert_profile, dbg,
min_tls_version, max_tls_version, ciphersuites, cert_profile, dbg, verify,
endpoint, transport, get_endpoint, set_user_data_p, set_user_data_n,
get_user_data_p, get_user_data_n
- ssl: init, free, setup, context_get_config, session_reset, set_bio,
set_hostname, set_session, get_session, handshake, is_handshake_over,
get_verify_result, get_ciphersuite, get_ciphersuite_id_from_ssl,
get_version, get_version_number, get_bytes_avail, read, write,
close_notify, set_user_data_p, set_user_data_n, get_user_data_p,
get_user_data_n; list_ciphersuites, get_ciphersuite_name,
get_ciphersuite_id
set_verify, set_hostname, set_session, get_session, handshake,
is_handshake_over, get_verify_result, get_ciphersuite,
get_ciphersuite_id_from_ssl, get_version, get_version_number,
get_bytes_avail, read, write, close_notify, set_user_data_p,
set_user_data_n, get_user_data_p, get_user_data_n; list_ciphersuites,
get_ciphersuite_name, get_ciphersuite_id
- ssl_session: init, free; save and load return
`MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`

Known differences from Mbed TLS:

- `MBEDTLS_SSL_VERIFY_OPTIONAL`, `mbedtls_ssl_conf_verify` and
`mbedtls_ssl_set_verify` are not available yet, so an application that
uses them does not build.
- With `MBEDTLS_SSL_VERIFY_REQUIRED`, the handshake stops at the first check
of the peer's chain that fails, and `mbedtls_ssl_get_verify_result` has
only its flag. Mbed TLS checks the whole chain first and reports the flag
of each failure.
- The verify flags come from wolfSSL, which reports one failure from each
certificate's signature and date checks, and one from the later checks of
the peer's own, such as the host name. So the verify callback and
`mbedtls_ssl_get_verify_result` can report fewer flags than Mbed TLS: an
untrusted certificate that has also expired is only `NOT_TRUSTED`.
- The verify callback gets the certificates the peer sent, in that order,
then above them the CA from the CA list that issued the last one. Mbed TLS
builds the chain itself, and leaves out a certificate the peer sent once
it reaches a CA from the list.
- A wolfSSL error with no Mbed TLS match returns a general code for the
call, such as `MBEDTLS_ERR_SSL_INTERNAL_ERROR`. wolfSSL's own codes are not
returned: some Mbed TLS 4.x codes are PSA values (-128 to -160), which
Expand Down Expand Up @@ -232,12 +237,13 @@ runs these against `libwolfpsa.a`. Each is also a target of its own.

- `mbedtls-compat-unit`: `test/mbedtls_compat/x509_crt_test.c`,
`pk_test.c` and `pem_test.c` parse Mbed TLS's test certificates and keys.
`ssl_test.c` checks return codes and verify results, client and server in
one process.
`ssl_test.c` checks return codes, verify results and the verify
callbacks, client and server in one process.
- `mbedtls-compat-programs`: the Mbed TLS migration guide client
(`test/mbedtls_compat/client-tls-mbedtls.c`) and Mbed TLS's sample
programs, built unchanged, run against the wolfSSL example server. Mbed
TLS's server programs run against the wolfSSL example client. With
TLS's server programs run against the wolfSSL example client and
`ssl_client1`. With
`MBEDTLS_THREADING_C=1`, `ssl_pthread_server` serves clients at the same
time.

Expand Down
10 changes: 8 additions & 2 deletions src/mbedtls/mbedtls_compat_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

/* Shared by ssl.c and net.c. Not part of the public API. */
/* Shared by ssl.c, net.c and x509.c. Not part of the public API. */

#ifndef MBEDTLS_COMPAT_INTERNAL_H
#define MBEDTLS_COMPAT_INTERNAL_H

#include <stddef.h>
#include <wolfssl/wolfcrypt/visibility.h>
#include <wolfssl/wolfcrypt/types.h>

enum {
MBED_IO_RECV = 0,
Expand All @@ -37,4 +37,10 @@ WOLFSSL_LOCAL int MbedIoErr(int code, int dir, int toWolf);
/* An I/O length as an int, at most max */
WOLFSSL_LOCAL int MbedIoLen(size_t len, int max);

struct DecodedCert;
/* Decodes der without verifying it. Free cert with wc_FreeDecodedCert()
* regardless of result. */
WOLFSSL_LOCAL int MbedCertDecode(struct DecodedCert* cert, const byte* der,
word32 len);

#endif /* MBEDTLS_COMPAT_INTERNAL_H */
Loading
Loading