lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #9823] altcp_tls_mbedtls.c: add restartable feature


From: Giuseppe Modugno
Subject: [lwip-devel] [patch #9823] altcp_tls_mbedtls.c: add restartable feature
Date: Thu, 27 Jun 2019 05:57:45 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36

URL:
  <https://savannah.nongnu.org/patch/?9823>

                 Summary: altcp_tls_mbedtls.c: add restartable feature
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: giusloq
            Submitted on: Thu 27 Jun 2019 09:57:43 AM UTC
                Category: apps
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

mbedTLS features an option named MBEDTLS_ECP_RESTARTABLE[1] that is very
useful in NO_SYS=1 platforms and when ECP calculus takes a long time (as in
many modern MCUs without crypto engine). I'm using a Cortex_M3 LPC1768 and the
TLS handshake takes around 5-10 seconds.

During this period, in cooperative multitasking,
altcp_mbedtls_lower_recv_process() blocks other tasks (except interrupts). The
restartable option splits the long calculus in steps and gives the possibility
to run other tasks.

Unfortunately altcp_tls_mbedtls isn't compatible with restartable option.
Indeed, the return value MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS isn't managed.

I tried to add restartable option, please look at the patch. I trigger an
already expired timer when mbedtls_handshake() returns CRYPTO_IN_PROGRESS. In
the timer handler I call altcp_mbedtls_lower_recv_process() again. If the
calculus is yet in progress, the timer is triggered again.

This patch works in my case, but it is experimental and mainly sub-optimal for
the following reasons.

1. There's one timer for each TLS session. An optimization could be using a
single timer for all TLS sessions, but this means that altcp_tls_mbedtls must
trace all TLS sessions (a list?). In my application I have only one TLS client
session, so one timer per session isn't so bad.

2. sys_timeout() could assert if we are out of timers.

3. MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS can be returned by mbedtls_read() and
mbedtls_write() too. I think this happens only occasionally when, during a
session, one peer decides to renegotiate something. I don't know how to manage
this situation.

[1] https://tls.mbed.org/kb/development/restartable-ecc




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 27 Jun 2019 09:57:43 AM UTC  Name: patch.diff  Size: 2KiB   By:
giusloq

<http://savannah.nongnu.org/patch/download.php?file_id=47139>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9823>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]