Skip to content
Snippets Groups Projects
  1. May 20, 2019
  2. May 17, 2019
  3. May 14, 2019
  4. May 06, 2019
  5. Apr 30, 2019
    • Paul Sokolovsky's avatar
      extmod/modussl_axtls: Add non-blocking mode support. · c7644531
      Paul Sokolovsky authored
      It consists of:
      
      1. "do_handhake" param (default True) to wrap_socket(). If it's False,
      handshake won't be performed by wrap_socket(), as it would be done in
      blocking way normally. Instead, SSL socket can be set to non-blocking mode,
      and handshake would be performed before the first read/write request (by
      just returning EAGAIN to these requests, while instead reading/writing/
      processing handshake over the connection). Unfortunately, axTLS doesn't
      really support non-blocking handshake correctly. So, while framework for
      this is implemented on MicroPython's module side, in case of axTLS, it
      won't work reliably.
      
      2. Implementation of .setblocking() method. It must be called on SSL socket
      for blocking vs non-blocking operation to be handled correctly (for
      example, it's not enough to wrap non-blocking socket with wrap_socket()
      call - resulting SSL socket won't be itself non-blocking).  Note that
      .setblocking() propagates call to the underlying socket object, as
      expected.
      c7644531
    • Paul Sokolovsky's avatar
      extmod/modussl_mbedtls: Support non-blocking handshake. · 9c7c0823
      Paul Sokolovsky authored
      For this, add wrap_socket(do_handshake=False) param. CPython doesn't have
      such a param at a module's global function, and at SSLContext.wrap_socket()
      it has do_handshake_on_connect param, but that uselessly long.
      
      Beyond that, make write() handle not just MBEDTLS_ERR_SSL_WANT_WRITE, but
      also MBEDTLS_ERR_SSL_WANT_READ, as during handshake, write call may be
      actually preempted by need to read next handshake message from peer.
      Likewise, for read(). And even after the initial negotiation, situations
      like that may happen e.g. with renegotiation. Both
      MBEDTLS_ERR_SSL_WANT_READ and MBEDTLS_ERR_SSL_WANT_WRITE are however mapped
      to the same None return code. The idea is that if the same read()/write()
      method is called repeatedly, the progress will be made step by step anyway.
      The caveat is if user wants to add the underlying socket to uselect.poll().
      To be reliable, in this case, the socket should be polled for both POLL_IN
      and POLL_OUT, as we don't know the actual expected direction. But that's
      actually problematic. Consider for example that write() ends with
      MBEDTLS_ERR_SSL_WANT_READ, but gets converted to None. We put the
      underlying socket on pull using POLL_IN|POLL_OUT but that probably returns
      immediately with POLL_OUT, as underlyings socket is writable. We call the
      same ussl write() again, which again results in MBEDTLS_ERR_SSL_WANT_READ,
      etc. We thus go into busy-loop.
      
      So, the handling in this patch is temporary and needs fixing. But exact way
      to fix it is not clear. One way is to provide explicit function for
      handshake (CPython has do_handshake()), and let *that* return distinct
      codes like WANT_READ/WANT_WRITE. But as mentioned above, past the initial
      handshake, such situation may happen again with at least renegotiation. So
      apparently, the only robust solution is to return "out of bound" special
      sentinels like WANT_READ/WANT_WRITE from read()/write() directly. CPython
      throws exceptions for these, but those are expensive to adopt that way for
      efficiency-conscious implementation like MicroPython.
      9c7c0823
  6. Apr 26, 2019
  7. Apr 16, 2019
  8. Apr 11, 2019
  9. Apr 03, 2019
  10. Apr 01, 2019
  11. Mar 26, 2019
  12. Mar 13, 2019
  13. Mar 12, 2019
  14. Mar 05, 2019
  15. Feb 28, 2019
  16. Feb 26, 2019
  17. Feb 18, 2019
    • Damien George's avatar
      extmod/modlwip: Fix bug when polling listening socket with backlog=1. · 42c0e440
      Damien George authored
      The bug polling for readability was: if alloc==0 and tcp.item==NULL then
      the code would incorrectly check tcp.array[iget] which is an invalid
      dereference when alloc==0.  This patch refactors the code to use a helper
      function lwip_socket_incoming_array() to return the correct pointer for the
      incomming connection array.
      
      Fixes issue #4511.
      42c0e440
  18. Feb 15, 2019
  19. Feb 13, 2019
  20. Feb 12, 2019
  21. Feb 07, 2019
  22. Jan 31, 2019
  23. Jan 27, 2019
  24. Jan 26, 2019
  25. Dec 21, 2018
  26. Dec 10, 2018
  27. Dec 03, 2018
  28. Dec 01, 2018
Loading