Age | Commit message (Collapse) | Author |
|
Test RSA, ECDSA, and EdDSA signature verification,
and key generation with message signing and verification.
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
|
|
Implement message digest, and RSA, ECDSA and EdDSA signing
and verification.
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
|
|
Implement message digest, and RSA and ECDSA signing
and verification.
Add NIST curve alises in order to support the same curve names
in crypto-mbetls and crypto-openssl:
* P-192
* P-224
* P-256
* P-384
* P-521
* brainpoolP256r1
* brainpoolP384r1
* brainpoolP512r1
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
|
|
uci: eliminate usage of global variables
|
|
Use the VM registry to store the last uci error code and lookup the uci
cursor resource type at resource creation time instead of caching it in
a global variable.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The previously introduced signal handler restoration logic did not take
the signal dispatching pipe into account.
Extend the `uc_vm_signal_handlers_reset()` function to also close any
related pipe handles.
Fixes: #255
Fixes: f9d2faf ("vm: reset signals when freeing VM")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
main: fix crash on printing -p output
|
|
Delete a duplicate ucv_put() line that can lead to a double-free bug.
Reproduced by running:
ucode -l nl80211 -p 'sprintf("%.J\n",
nl80211.request(nl80211.const.NL80211_CMD_GET_WIPHY,
nl80211.const.NLM_F_DUMP,
{ wiphy: 0, split_wiphy_dump: true }))'
Fixes: 0a7ff4715cb8 ("main: pretty-print `-p` output by default")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
Reenabling signal dispatching caused a new object allocation so update the
expected GC counts in the testcases.
Fixes: a362263 ("vm: fix inverted condition in uc_vm_signal_handlers_setup()")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The previous code refactoring inadvertently broke the signal setup
condition check.
Fixes: #254
Fixes: f9d2faf ("vm: reset signals when freeing VM")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
struct: Add new buffer API for incremental packing/unpacking
|
|
Drop the usage of global static variables for caching the per-VM resource
type objects in order to properly support loading the library in multiple
concurrent threads or VM instances.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
main: pretty-print `-p` output by default
|
|
Implement a new struct buffer API to support incremental packing and
unpacking of binary data. This API allows for more flexible and efficient
handling of structured data, especially for streaming or partial
processing scenarios.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lexer: Preserve keyword, regexp flags until processing non-comment to…
|
|
When outputting non-string expression results while running the cli
interpreter using the `-p` flag, pretty-print the resulting JSON data
for better readability.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When the lexer has either the `no_keyword` or `no_regexp` flag set, it
should retain these flags until it encounters a non-comment token.
Only then should it stop preventing the interpretation of tokens beginning
with a letter or forward slash as keywords or regular expression literals,
respectively.
Previously, these flags were being reset too early when processing comments,
which could cause incorrect parsing when comments appeared between relevant
tokens. The flags should only be reset after consuming an actual non-comment
token to ensure consistent parsing behavior.
Fixes: #250
Fixes: 855854f ("lexer: emit comment and template statement block tokens")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
nl80211: properly support split_wiphy_dump for single phys
|
|
When performing a `NL80211_CMD_GET_WIPHY` request for a single wiphy with
`split_wiphy_dump` set to true, the expectation is that only a single phy
object is returned, like when performing the same request without splitting,
yet the current implementation returns a sparse array with only the
requested phy index populated instead.
Fix this issue by special-casing NL80211_CMD_GET_WIPHY command requests
with a set `split_wiphy_dump` attribute. Also implicitly set the
`NLM_F_DUMP` flag in this case as it is required for the kernel to send
all information.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Since `typename` is a reserved word in C++ avoid using it to allow
successful compilation with a C++ compiler.
Fixes: #248
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: utilize `ucv_array_sort_r()` and `ucv_object_sort_r()`
|
|
Utilize the newly introduced sort functions to eliminate the global sort
context usage. This change was originally part of PR #242 but got dropped
during refactoring.
Suggested-by: Isaac de Wolff <idewolff@vincitech.nl>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Removed all global variables from libucode for thread safety
|
|
When invoking `uc_vm_free()` on a VM with enabled `.setup_signal_handlers`
configuration, reset system signal handlers back to their default actions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce an extensible private TLS context structure and use it within
libucode to store global state such as active object iterators.
This allows using libucode concurrently in multiple threads without
unintentionally sharing global state among them.
Also adjust the signal dispatching setup logic in `uc_vm_init()` to only
enable signal handling if no other VM in the same thread already handles
signals.
Suggested-by: Isaac de Wolff <idewolff@vincitech.nl>
[squash commits, move signal handler vm pointer and object iterator list
into common extensible TLS context, whitespace and naming adjustments,
extended signal setup logic]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce two new functions for ordering arrays and object keys which
utilize a different compare callback signature and allow passing a user
provided pointer to the comparison callback.
The main advantages of the `ucv_*_sort_r()` flavors are the ability to
pass custom context to comparisons via the user data pointer and the
invocation of the comparison callback with direct `uc_value_t *` pointers
instead of opaque `const void *` arguments pointing to `uc_value_t *` or
json-c internal `struct lh_entry *` pointers respectively.
Suggested-by: Isaac de Wolff <idewolff@vincitech.nl>
[align naming and whitespace with the rest of the codebase, rename some
variables for clarity, group sort related changes into two commits,
drop constness from `uc_value_t *` compare function arguments]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: Removed global variables from module fs for thread safety
|
|
lib: introduce digest library
|
|
Introduce a new default enabled CMake option `DIGEST_SUPPORT_EXTENDED`
which, when turned off, disables all but the most common md5, sha1 and
sha256 alogirthms to reduce the library size.
Also prefer statically linking libmd if possible.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This is needed for the upcoming digest library support.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Sebastian Ertz <sebastian.ertz@gmx.de>
|
|
vm: resolve upvalues before pushing them onto the stack
|
|
Some objects, such as wildcard module import namespace dictionaries may
contain upvalue type values. Extend `ucv_key_get()` to transparently
resolve such values before returning them to the caller in order to
avoid increasing the refcount of the upvalue itself, leading to a
memory leak later on when the VM indirectly dereferences it on upon
`uc_vm_stack_push()`, loosing the upvalue object reference itself
in the process.
This long standing leak was discovered while fixing another upvalue
related module import quirk.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Commit e5fe6b1 ("treewide: refactor vector usage code") accidentially dropped
the upvalue resolving logic from uc_vm_stack_push(), leading to unresolved
upvalues leaking into the script execution context.
Fixes: e5fe6b1 ("treewide: refactor vector usage code")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The OpenWrt CI runs are broken and need to be redone. In order to unblock
the PR pipeline, drop these tests for now to reintroduce fixed variants
at a later point in time.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Move last error code into a VM registry value and lookup resource types
within the current VM context at call time, allowing the proper use of
the fs module within multiple threads of a multithreaded application.
Suggested-by: Isaac de Wolff <idewolff@vincitech.nl>
[turn err_return() back into a local macro, simplify uc_fs_error(),
align whitespace style]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce a new inline convenience function ucv_resource_create() which
simplifies creating resource values by resource type name by combining
resource type lookup and resource value creation in one call.
This function will be used in subsequent refactoring to eliminate global
static variables.
Suggested-by: Isaac de Wolff <idewolff@vincitech.nl>
[separated from original commit, move ucv_resource_create() into types.h]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
nl80211: add new attributes for multi-radio support
|
|
- vif radio mask: used to assign vifs to specific radios
- monitor skip_tx flag: do not pass locally transmitted packets on the monitor interface
- radio antenna mask: radio specific part of the phy antenna mask
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
These new attributes are required when dealing with WiFi 7 radios.
Reported-by: John Crispin <john@phrozen.org>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: Removed global variables from module math for thread safety
|
|
utils: improve vector macros
|
|
Signed-off-by: Sebastian Ertz <sebastian.ertz@gmx.de>
|
|
Utilize uc_vector_push() and uc_vector_foreach() where applicable.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This commits introduces a number of new helper macros to deal with vectors
and refactors the existing code for better resource utilization.
The allocation strategy is changed from multiple of 8 to exponential growth
by factor 1.5 in order to minimize the number of reallocations and
potentially needed memory copies.
The newly introduced macros are:
- uc_vector_capacity(init_capacity, add_items)
Derive the resulting vector capacity from the given item count
and initial capacity.
- uc_vector_extend(vector, add_items)
Increase vector capacity by given amount of items, zero-initialize
added capacity and return pointer to first new item past the current
length.
- uc_vector_reduce(vector, remove_items)
Reduce vector capacity by given amount of items.
- uc_vector_pop(vector)
Return pointer to last element and decrement count, or NULL if the
vector is empty.
- uc_vector_foreach(vector, itervar)
A for() loop wrapper to iterate vectors, providing an iter variable
to the loop body.
- uc_vector_foreach_reverse(vector, itervar)
A for() loop wrapper to iterate vectors backwards, providing an iter
variable to the loop body.
The uc_vector_push() macro has been changed into a variadic macro which
internally prefixes the argument list with a cast to the vector element
type, allowing user to pass compound expressions like struct initializers
in order to simplify adding elements:
uc_vector_push(&my_collection, {
.foo = 1,
.bar = "qrx"
});
Like uc_vector_pop(), the uc_vector_last() macro has been made safe to
use on empty vectors, it'll now return NULL in this case.
Finally the vector realloc logic was moved into static functions within
the header file, allowing all vector using code of a compilation unit to
share the reallocation, shrinking the size of libucode.so by 1-2KB as a
side effect.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
socket: provide local definition of `struct fanout_args`
|
|
The `fanout_args` structure is a relatively recent addition to the kernel
so provide a local definition for it, like we already do it for other like
`timeval_old`.
Fixes: #217
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
types: fix potential use after free on adding keys during iteration
|
|
vallist: more thoroughly check for trailing garbage after numeric string
|
|
When keys are added to the object currently being iterated by a for loop,
the insert operation might cause a hashtable resize with a subsequent
memory reallocation and a different table base pointer, clobbering the
entry pointers held by iterators pointing to the containing object of the
resized table.
In order to address this issue while keeping the iteration overhead low,
extend the object key insert logic to check whether the insertion will
trigger a reallocation and backup and restore the iterator pointers when
needed.
This slightly increases the size of the iterator states but the overhead
for this should be neglectible as there'll only be a low amount of
concurrently active iterations at any time.
Fixes: #230
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|