aboutsummaryrefslogtreecommitdiffstats
path: root/util-src
Commit message (Collapse)AuthorAgeFilesLines
* util.signal: Fail signalfd() if unable to change signal maskKim Alvefur2024-02-281-1/+4
| | | | | By aborting early, the failure should be brought to the attention somehow.
* util.signal: Wrap signalfd in an userdatum for gc handling etcKim Alvefur2024-02-241-8/+61
|
* util.signal: Add support for signalfd(2) on LinuxKim Alvefur2024-02-241-0/+34
| | | | | | | | | signalfd allows handling signal events using the same method as sockets, via file descriptors. Thus all signal dispatch can go through the same main event loop as everything else, removing need for thread-scary signal handling where execution would just jump to the signal handler regardless of the state of Lua, and needing to keep track of Lua states/threads.
* util.strbitop: Add common_prefix_bits() methodMatthew Wild2024-02-231-0/+37
| | | | | This returns the number of bits that two strings have in common. It is significantly more efficient than similar calculations in Lua.
* util.poll: Rename things to clarify poll(2) limitsKim Alvefur2023-11-271-5/+7
| | | | | | With epoll(7), MAX_EVENTS controls how many events can be retrieved in one epoll_wait call, while with poll(2) this MAX_WATCHED controls how many sockets or other FDs can be watched at once.
* util.poll: Quadruple number of events retrieved at once from epollKim Alvefur2023-11-211-1/+1
| | | | | | Better performance under load maybe? See b890ceb1c24f for previous increase
* util.poll: Return early if given zero timeout and no pending eventsKim Alvefur2023-11-211-0/+6
| | | | | Should have been part of f33887f925e1 to ensure it won't skip processing timers at all when very busy.
* util.pposix: Add remove_blocks() for deleting parts of filesKim Alvefur2023-06-071-0/+36
| | | | | | Allows implementing e.g. a FIFO Will probably only work on some Linux file systems like ext4.
* util.pposix: Use Lua enum API for resource limit name argumentKim Alvefur2023-06-141-47/+33
| | | | Because diffstat.
* util: Add compat for prosody module name change to C sourcesKim Alvefur2023-03-1714-14/+64
|
* util.poll: Include unistd.h only for epollKim Alvefur2023-02-101-1/+1
| | | | | This defines close(), which is only used with epoll, hence we don't need to include it when building in poll or select mode.
* util.crypto: Preemptively silence 'strict-prototypes' warningKim Alvefur2023-01-311-1/+1
| | | | | | | | With `gcc-12 -Wstrict-prototypes` the following warning is shown: crypto.c:43:13: warning: function declaration isn't a prototype [-Wstrict-prototypes] 43 | static BIO* new_memory_BIO() { | ^~~~~~~~~~~~~~
* util.struct: Fix typo in commentKim Alvefur2023-01-201-1/+1
|
* util.hashes: Silence compiler warning about char pointer signednessKim Alvefur2023-01-171-1/+1
| | | | Introduced in dbe9781fd278
* util.crypto: Add support for AES-256-CTRMatthew Wild2023-01-131-21/+44
| | | | This is required by PASETO v3.local
* util.hashes: Add HKDF-HMAC-SHA256/HKDF-HMAC-SHA384Matthew Wild2023-01-131-0/+59
| | | | These are needed for PASETO v3.local.
* util.crypto, util.jwt: Generate consistent signature sizes (via padding)Matthew Wild2022-09-291-10/+17
| | | | | | This fixes the signature parsing and building to work correctly. Sometimes a signature was one or two bytes too short, and needed to be padded. OpenSSL can do this for us.
* util.crypto: Use Lua 5.2 API for predictable buffer sizeKim Alvefur2022-07-111-6/+1
| | | | | | | | In Lua 5.3 LUAL_BUFFERSIZE is a macro computed from sizeof and is thus not known at pre-processing time, so this does not work. Since Lua 5.1 is no longer supported, we can use luaL_prepbuffsize() which is available from Lua 5.2
* util.crypto: Use stack space buffersKim Alvefur2022-07-111-14/+11
| | | | | | | | | Removes assumption that LUAL_BUFFERSIZE is known at pre-processing time, which it is not in Lua 5.3 and 5.4, where it is a computed macro based on sizeof. Allocation of stack space is safer and faster, no need to worry about luaL_prepbuffer failing to allocate memory and skipping free()
* util.crypto: More digests for sign/verify, use macros for clarity/consistencyMatthew Wild2022-07-021-32/+40
|
* util.crypto: Friendlier error message on incorrect key typesMatthew Wild2022-07-021-1/+6
|
* util.crypto: Add support for RSA signatures (PKCS1-v1.5 + PSS)Matthew Wild2022-07-021-3/+31
| | | | These are used by the RS*** and PS*** family of JOSE algorithms (e.g. in JWTs)
* util.crypto: New wrapper for some operations in OpenSSL's libcryptoMatthew Wild2022-06-242-2/+557
| | | | | Specifically, ED25519 key generation/import/export, sign/verify operations, and AES encrypt/decrypt.
* util-src: Add new utility header managed_pointer.hMatthew Wild2022-07-011-0/+61
| | | | | The macros in this header allow creation of GC-managed objects from manually- managed C alloc/free APIs.
* util.table: Fix inaccurate commentKim Alvefur2022-07-111-1/+1
| | | | | | | Probably a duplicate of the comment next to Lmove, recorded by mistake Lpack can probably be removed at some point in the near future once we are confident it is not used anywhere.
* util-src: Remove Lua 5.1 compat macrosKim Alvefur2022-07-0112-56/+2
| | | | Part of #1600
* util.hashes: Revert to HMAC() convenience functionKim Alvefur2022-06-241-22/+2
| | | | | | | | | Reverts some of 1e41dd0f8353 Seems HMAC() isn't deprecated after all? Must have been at some point according to #1589 Twice as fast for some reason.
* util.hashes: Remove unused constantsKim Alvefur2022-06-241-3/+0
|
* util.hashes: Remove unused structKim Alvefur2022-06-241-8/+0
| | | | Unused since 9f1c5ae8d70b
* util.hashes: Return OpenSSL error messages on failureKim Alvefur2022-06-241-3/+4
| | | | With luck, might contain more details than just "failed"
* util.hashes: Add SHA3 bindingsKim Alvefur2020-09-101-0/+19
|
* util.hashes: Bind BLAKE2 algoritms supported by OpenSSLKim Alvefur2020-09-101-0/+21
|
* util.hashes: Refactor PBKDF2 to deduplicate codeKim Alvefur2020-09-101-17/+8
|
* util.hashes: Expose sha224 and sha384 HMAC functionsKim Alvefur2020-11-291-0/+10
| | | | For completeness and consistency with set of plain hash functions
* util.hashes: Refactor HMAC bindings (fixes #1589)Kim Alvefur2020-11-291-22/+61
| | | | | | | HMAC() is deprecated As with the regular hash functions, macros like this make it awkward to apply static analysis and code formatting.
* util.hashes: Refactor hash functions to use OpenSSL EVP methods (fix #1698)Kim Alvefur2020-09-101-20/+63
| | | | | | | MD5() is deprecated, but EVP_md5() is not. Functions in macros like this make it awkward to apply static analysis and code formatting.
* util.crand: Reduce scope here tooKim Alvefur2022-04-231-2/+2
| | | | Same as previous commit
* util.strbitop: Reduce scope of functionsKim Alvefur2022-04-231-3/+3
| | | | | | | | | Equivalent to 'local' in Lua, these functions are exported via the luaopen_ function, which is the only one needing to be visible outside of the file. Pointed out by Link Mauve at some point, but there wasn't really any rush here.
* util.table: Compatibility with Lua 5.1 lua_equalsMatthew Wild2022-03-181-1/+5
|
* util.table: Backport table.move() from Lua 5.4Matthew Wild2022-03-181-0/+42
| | | | | One difference is that 5.4 accepts "table-like" values (for this and other table.*() functions), but that would require additional backporting work.
* Spelling: Fix various spelling mistakes (thanks timeless)Kim Alvefur2022-03-071-1/+1
| | | | | | Words, sometimes I wonder how they even work Maybe I missed something.
* make: Fix build of util.struct on *BSDKim Alvefur2022-03-041-1/+2
|
* Merge config-updates+check-turn from timberMatthew Wild2022-03-042-1/+424
|\
| * util.struct: Import Roberto 'struct' library v0.3Matthew Wild2022-03-042-1/+424
| | | | | | | | | | | | | | Downloaded from http://www.inf.puc-rio.br/~roberto/struct/ This is for compatibility with Lua 5.2 (and 5.1). Eventually we can replace this with string.pack/string.unpack which are available in 5.3+.
* | util.poll: Add support for the poll() APIKim Alvefur2022-02-231-1/+129
| | | | | | | | Might be better than select(), more portable than epoll.
* | util.poll: Expose API (epoll or select) usedKim Alvefur2022-02-271-6/+6
| | | | | | | | Could he handy to know for debugging or decisions
* | util.poll: Restructure to make adding additional system APIs easierKim Alvefur2022-02-231-11/+23
|/
* util.pposix: Use mallinfo2() on glibc 2.33, fix #1649Kim Alvefur2022-01-061-5/+12
|
* util.pposix: Bind isatty(3)Kim Alvefur2021-07-041-0/+9
| | | | | Useful for disabling certain behavior, ANSI colors etc when not connected to a terminal.
* util.hashes: Expose OpenSSL versionKim Alvefur2021-05-121-0/+4
|