aboutsummaryrefslogtreecommitdiff
path: root/extmod
AgeCommit message (Collapse)Author
2019-02-07extmod/moduhashlib: Include implementation of sha256 only when required.Yonatan Goldschmidt
Previously crypto-algorithms impl was included even if MICROPY_SSL_MBEDTLS was in effect, thus we relied on the compiler/linker to cut out the unused functions.
2019-01-31py/warning: Support categories for warnings.Paul Sokolovsky
Python defines warnings as belonging to categories, where category is a warning type (descending from exception type). This is useful, as e.g. allows to disable warnings selectively and provide user-defined warning types. So, implement this in MicroPython, except that categories are represented just with strings. However, enough hooks are left to implement categories differently per-port (e.g. as types), without need to patch each and every usage.
2019-01-31extmod/modlwip: Add support for polling UDP sockets for writability.Damien George
2019-01-27extmod/modussl_mbedtls: Remove deprecated mbedtls/net.h header include.Paul Sokolovsky
This header is deprecated as of mbedtls 2.8.0, as shipped with Ubuntu 18.04. Leads to #warning which is promoted to error with uPy compile options. Note that the current version of mbedtls is 2.14 at the time of writing.
2019-01-27extmod/moduzlib: Update for uzlib 2.9.2.Paul Sokolovsky
2019-01-27extmod/uzlib: Update uzlib to v2.9.2.Paul Sokolovsky
Major changes include robust parsing of erroneous compressed streams and updated API.
2018-12-22py/mpconfig: Move MICROPY_VERSION macros to static ones in mpconfig.h.Damien George
It's more robust to have the version defined statically in a header file, rather than dynamically generating it via git using a git tag. In case git doesn't exist, or a different source control tool is used, it's important to still have the uPy version number available.
2018-12-10extmod/moductypes: Add aliases for native C types.Paul Sokolovsky
SHORT, INT, LONG, LONGLONG, and unsigned (U*) variants are being defined. This is done at compile using GCC-style predefined macros like __SIZEOF_INT__. If the compiler doesn't have such defines, no such types will be defined.
2018-12-10extmod/moductypes: Implement __int__ for PTR.Paul Sokolovsky
Allows to get address a pointer contains, as an integer.
2018-12-03extmod/modlwip: Fix read-polling of listening socket with a backlog.Damien George
The recent implementation of the listen backlog meant that the logic to test for readability of such a socket changed, and this commit updates the logic to work again.
2018-12-01extmod/modlwip: Implement TCP listen/accept backlog.Damien George
Array to hold waiting connections is in-place if backlog=1, else is a dynamically allocated array. Incoming connections are processed FIFO style to maintain fairness.
2018-10-23extmod/moductypes: Make sizeof() accept "layout" parameter.Paul Sokolovsky
sizeof() can work in two ways: a) calculate size of already instantiated structure ("sizeof variable") - in this case we already no layout; b) size of structure decsription ("sizeof type"). In the latter case, LAYOUT_NATIVE was assumed, but there should possibility to calculate size for other layouts too. So, with this patch, there're now 2 forms: uctypes.sizeof(struct) uctypes.sizeof(struct_desc, layout)
2018-10-17extmod/modonewire: Fix reset timings to match 1-wire specs.Damien George
Fixes issue #4116.
2018-10-13extmod/moductypes: Accept OrderedDict as a structure description.Paul Sokolovsky
Using OrderedDict (i.e. stable order of fields) would for example allow to automatically calculate field offsets in structures.
2018-10-05extmod/moductypes: Remove BITFIELD from aggregate types enum.Paul Sokolovsky
This value is unused. It was an artifact of early draft design, but bitfields were optimized to use scalar one-word encoding, to allow compact encoding of typical multiple bitfields in MCU control registers.
2018-09-12extmod/moduhashlib: Add md5 implementation using mbedtls.Damien George
2018-09-12extmod/moduhashlib: Use newer message digest API for mbedtls >=2.7.0.Damien George
Since mbedtls 2.7.0 new digest functions were introduced with a "_ret" suffix to allow the functions to return an error message (eg, if the underlying hardware acceleration failed). These new functions must be used instead of the old ones to prevent deprecation warnings, or link errors for missing functions, depending on the mbedtls configuration.
2018-09-11extmod/moduhashlib: Add md5 implementation, using axTLS.Paul Sokolovsky
MD5 is still widely used, and may be important in some cases for networking interoperability, e.g. HTTP Digest authentication.
2018-09-08py/py.mk: Build axtls library directly from its source files.Damien George
This removes the need for a separate axtls build stage, and builds all axtls object files along with other code. This simplifies and cleans up the build process, automatically builds axtls when needed, and puts the axtls object files in the correct $(BUILD) location. The MicroPython axtls configuration file is provided in extmod/axtls-include/config.h
2018-08-14extmod/modussl_axtls: Use MP_ROM_PTR for objects in allowed args array.Damien George
2018-08-14extmod/modbtree: Update to work with new mp_stream_posix_XXX signatures.Damien George
2018-07-20extmod/modussl: Support polling in ussl objects by passing through ioctlDamien George
The underlying socket can handling polling, and any other transparent ioctl requests. Note that CPython handles the case of polling an ssl object by polling the file descriptor of the underlying socket file, and that behaviour is emulated here.
2018-07-20extmod/modlwip: Deregister all lwIP callbacks when closing a socket.Damien George
Otherwise they may be called on a socket that no longer exists. For example, if the GC calls the finaliser on the socket and then reuses its heap memory, the "callback" entry of the old socket may contain invalid data. If lwIP then calls the TCP callback the code may try to call the user callback object which is now invalid. The lwIP callbacks must be deregistered during the closing of the socket, before all the pcb pointers are set to NULL.
2018-07-11extmod/vfs_posix: Use DTTOIF if available to convert type in ilistdir.Damien George
2018-07-10extmod/vfs_posix: Support ilistdir with no (or empty) argument.Damien George
2018-07-08extmod: Fix to support compiling with object representation D.Damien George
2018-07-03extmod/vfs: Support opening a file descriptor (int) with VfsPosix.Damien George
Fixes issue #3865.
2018-07-02extmod/modure: Add ure.sub() function and method, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_SUB, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02extmod/modure: Add match.span(), start() and end() methods, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_SPAN_START_END, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02extmod/modure: Add match.groups() method, and tests.Damien George
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_GROUPS, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-06-27extmod/moducryptolib: Don't include arpa/inet.h, it's not needed.Damien George
And some ports (eg esp8266) don't have it.
2018-06-27extmod/moducryptolib: Shorten exception messages to reduce code size.Yonatan Goldschmidt
2018-06-27extmod/moducryptolib: Prefix all Python methods/objects with ucryptolib.Yonatan Goldschmidt
Follows what was done in b045ebd35 for uhashlib.
2018-06-27extmod/moducryptolib: Add an mbedTLS implementation for this module.Yonatan Goldschmidt
2018-06-27extmod/moducryptolib: Refactor functions for clean interface with axTLS.Yonatan Goldschmidt
This will allow implementations other than axTLS. This commit includes additions of checks and clarifications of exceptions related to user input. To make the interface cleaner, I've disallowed switching from encrypt to decrypt in the same object, as this is not always possible with other crypto libraries (not all libraries have AES_convert_key like axTLS).
2018-06-27extmod/moducryptolib: Optionally export MODE_* constants to Python.Yonatan Goldschmidt
Allow including crypto consts based on compilation settings. Disabled by default to reduce code size; if one wants extra code readability, can enable them.
2018-06-27extmod/moducryptolib: Add ucryptolib module with crypto functions.Paul Sokolovsky
The API follows guidelines of https://www.python.org/dev/peps/pep-0272/, but is optimized for code size, with the idea that full PEP 0272 compatibility can be added with a simple Python wrapper mode. The naming of the module follows (u)hashlib pattern. At the bare minimum, this module is expected to provide: * AES128, ECB (i.e. "null") mode, encrypt only Implementation in this commit is based on axTLS routines, and implements following: * AES 128 and 256 * ECB and CBC modes * encrypt and decrypt
2018-06-18extmod: Update to use new mp_get_stream helper.Damien George
With this patch objects are only checked that they have the stream protocol at the start of their use as a stream, and afterwards the efficient mp_get_stream() helper is used to extract the stream protocol C methods.
2018-06-16extmod/vfs_fat_diskio: Factor disk ioctl code to reduce code size.Damien George
Functionality is unchanged.
2018-06-13extmod/modussl_axtls: Fix __del__ to point to mp_stream_close_obj.Damien George
2018-06-12extmod/uos_dupterm: Use native C stream methods on dupterm object.Damien George
This patch changes dupterm to call the native C stream methods on the connected stream objects, instead of calling the Python readinto/write methods. This is much more efficient for native stream objects like UART and webrepl and doesn't require allocating a special dupterm array. This change is a minor breaking change from the user's perspective because dupterm no longer accepts pure user stream objects to duplicate on. But with the recent addition of uio.IOBase it is possible to still create such classes just by inheriting from uio.IOBase, for example: import uio, uos class MyStream(uio.IOBase): def write(self, buf): # existing write implementation def readinto(self, buf): # existing readinto implementation uos.dupterm(MyStream())
2018-06-12extmod/moduhashlib: Make function objects STATIC.Yonatan Goldschmidt
These are not exported to anyone anyway.
2018-06-12extmod/moduhashlib: Allow using the sha256 implementation of mbedTLS.Yonatan Goldschmidt
2018-06-12extmod/moduhashlib: Allow to disable the sha256 class.Yonatan Goldschmidt
Via the config value MICROPY_PY_UHASHLIB_SHA256. Default to enabled to keep backwards compatibility. Also add default value for the sha1 class, to at least document its existence.
2018-06-12extmod/moduhashlib: Reorder funcs so that they are grouped by hash type.Yonatan Goldschmidt
Makes the code much more readable by reducing the number of #ifdefs and keeping related functions close.
2018-06-12extmod/moduhashlib: Prefix all Python methods and objects with uhashlib.Yonatan Goldschmidt
For consistency with other modules, and to help avoid clashes with the actual underlying functions that do the hashing (eg crypto-algorithms/sha256.c:sha256_update).
2018-06-06extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat.Damien George
Following other C-level protocols, this VFS protocol is added to help abstract away implementation details of the underlying VFS in an efficient way. As a starting point, the import_stat function is put into this protocol so that the VFS sub-system does not need to know about every VFS implementation in order to do an efficient stat for importing files. In the future it might be worth adding other functions to this protocol.
2018-06-06extmod/vfs: Add fast path for stating VfsPosix filesystem.Damien George
2018-06-06extmod: Add VfsPosix filesystem component.Damien George
This VFS component allows to mount a host POSIX filesystem within the uPy VFS sub-system. All traditional POSIX file access then goes through the VFS, allowing to sandbox a uPy process to a certain sub-dir of the host system, as well as mount other filesystem types alongside the host filesystem.
2018-06-06extmod/vfs_fat: Rename FileIO/TextIO types to mp_type_vfs_fat_XXX.Damien George
So they don't clash with other VFS implementations.