micropython/extmod
Paul Sokolovsky 9c7c082396 extmod/modussl_mbedtls: Support non-blocking handshake.
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.
2019-04-30 17:24:46 +10:00
..
axtls-include py/py.mk: Build axtls library directly from its source files. 2018-09-08 00:07:23 +10:00
crypto-algorithms extmod/crypto-algorithms/sha256: Remove non-standard memory.h header. 2017-04-27 15:01:01 +03:00
lwip-include all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
re1.5 extmod/re1.5: Fix compilecode.c compile problem on IAR tool chain. 2018-04-10 13:54:22 +10:00
uzlib extmod/uzlib: Update uzlib to v2.9.2. 2019-01-27 10:59:30 +11:00
machine_i2c.c extmod: Fix to support compiling with object representation D. 2018-07-08 23:15:44 +10:00
machine_i2c.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
machine_mem.c all: Remove inclusion of internal py header files. 2017-10-04 12:37:50 +11:00
machine_mem.h all: Use the name MicroPython consistently in comments 2017-07-31 18:35:40 +10:00
machine_pinbase.c extmod/machine_pinbase: Put PinBase singleton in ROM. 2017-09-12 16:00:21 +10:00
machine_pinbase.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
machine_pulse.c extmod/machine_pulse: Make time_pulse_us() not throw exceptions. 2017-02-05 14:20:17 +03:00
machine_pulse.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
machine_signal.c extmod/machine_signal: Fix fault when no args are passed to Signal(). 2019-04-26 14:47:31 +10:00
machine_signal.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
machine_spi.c drivers/bus: Pull out software SPI implementation to dedicated driver. 2018-03-10 00:59:43 +11:00
machine_spi.h drivers/bus: Pull out software SPI implementation to dedicated driver. 2018-03-10 00:59:43 +11:00
misc.h stm32: Make default USB_VCP stream go through uos.dupterm for main REPL. 2019-04-01 13:04:05 +11:00
modbtree.c extmod/modbtree: Update to work with new mp_stream_posix_XXX signatures. 2018-08-14 17:41:23 +10:00
modframebuf.c extmod/modframebuf: Add 8-bit greyscale format (GS8). 2017-12-14 17:36:13 +11:00
modlwip.c extmod/modlwip: Abort TCP conns that didn't close cleanly in a while. 2019-04-11 11:18:10 +10:00
modonewire.c extmod/modonewire: Fix reset timings to match 1-wire specs. 2018-10-17 15:52:07 +11:00
modubinascii.c all: Remove inclusion of internal py header files. 2017-10-04 12:37:50 +11:00
modubinascii.h all: Use the name MicroPython consistently in comments 2017-07-31 18:35:40 +10:00
moducryptolib.c extmod/moducryptolib: Don't include arpa/inet.h, it's not needed. 2018-06-27 16:44:59 +10:00
moductypes.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
moduhashlib.c extmod/moduhashlib: Include implementation of sha256 only when required. 2019-02-07 23:27:58 +11:00
moduheapq.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
modujson.c extmod: Update to use new mp_get_stream helper. 2018-06-18 12:35:56 +10:00
modurandom.c extmod/modurandom: Add init method to seed the Yasmarang generator. 2019-04-16 14:54:36 +10:00
modure.c extmod/modure: Add ure.sub() function and method, and tests. 2018-07-02 14:55:02 +10:00
moduselect.c extmod/moduselect: Adjust select_select and poll_register to use size_t. 2019-03-13 23:18:59 +11:00
modussl_axtls.c extmod/modussl_axtls: Use MP_ROM_PTR for objects in allowed args array. 2018-08-14 21:47:07 +10:00
modussl_mbedtls.c extmod/modussl_mbedtls: Support non-blocking handshake. 2019-04-30 17:24:46 +10:00
modutimeq.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
moduwebsocket.c extmod/moduwebsocket: Refactor websocket to uwebsocket. 2019-02-14 00:35:45 +11:00
moduwebsocket.h extmod/moduwebsocket: Refactor websocket to uwebsocket. 2019-02-14 00:35:45 +11:00
moduzlib.c extmod/moduzlib: Update for uzlib 2.9.2. 2019-01-27 10:59:49 +11:00
modwebrepl.c extmod/modwebrepl: Fix logic to handle a put of file of size 0. 2019-02-28 15:30:48 +11:00
uos_dupterm.c stm32: Make default USB_VCP stream go through uos.dupterm for main REPL. 2019-04-01 13:04:05 +11:00
utime_mphal.c py,extmod: Some casts and minor refactors to quiet compiler warnings. 2017-07-07 11:32:22 +10:00
utime_mphal.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00
vfs_fat_diskio.c extmod/vfs_fat: Update for new oofatfs version. 2019-03-05 15:56:39 +11:00
vfs_fat_file.c extmod/vfs_fat: Rename FileIO/TextIO types to mp_type_vfs_fat_XXX. 2018-06-06 14:28:23 +10:00
vfs_fat.c extmod/vfs_fat: Fallback to FAT32 if standard FAT16/SFD format fails. 2019-03-26 17:15:23 +11:00
vfs_fat.h extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat. 2018-06-06 14:33:42 +10:00
vfs_posix_file.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
vfs_posix.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
vfs_posix.h extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat. 2018-06-06 14:33:42 +10:00
vfs_reader.c py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str. 2017-11-16 13:17:51 +11:00
vfs.c extmod: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
vfs.h extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat. 2018-06-06 14:33:42 +10:00
virtpin.c all: Rename mp_obj_type_t::stream_p to protocol. 2016-06-18 18:44:57 +03:00
virtpin.h all: Unify header guard usage. 2017-07-18 11:57:39 +10:00