-
Notifications
You must be signed in to change notification settings - Fork 39
crypto_acompress #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
crypto_acompress #311
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the synchronous compression implementation with an asynchronous one using the Linux kernel's acompress API. The change introduces a new low-level crypto.acompress module that provides asynchronous compression operations, while maintaining backward compatibility through a high-level crypto.comp Lua module that wraps the async operations to provide a synchronous interface.
Key changes:
- Replaces synchronous
luacrypto_comp.cwith asynchronousluacrypto_acompress.c - Adds high-level Lua wrapper
crypto/comp.luato maintain synchronous API compatibility - Updates build configuration to use the new acompress module
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/luacrypto_comp.c | Removed - old synchronous compression implementation |
| lib/luacrypto_acompress.c | Added - new asynchronous compression implementation using kernel acompress API |
| lib/crypto/comp.lua | Added - high-level Lua wrapper providing synchronous interface over async operations |
| tests/crypto/comp.lua | Minor error message improvement for clarity |
| config.ld | Updated documentation config to reference new files |
| Makefile | Updated build config to use acompress module |
| Kbuild | Updated kernel build config to use acompress module |
723e663 to
1df9379
Compare
9a9b7c6 to
c0e8987
Compare
c0e8987 to
59c56ec
Compare
lib/luacrypto_acompress.c
Outdated
| req->cb = LUA_NOREF; | ||
| req->buf = LUA_NOREF; | ||
| req->self = LUA_NOREF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using a lua table for all you need will simplify a bit the implementation..
lib/luacrypto_acompress.c
Outdated
| if (ret != -EINPROGRESS) \ | ||
| luacrypto_acomp_req_docall(obj, ret); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this.. shouldn't this function be called by the crypto_acomp request itself? why you are calling synchronously here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks to me that we are trying to turn an async API into sync.. I would follow the same approach the clients of this kernel API are doing.. can you point to kernel usage example, btw? my bet is that they have an API for checking result later on.. we could do the same..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We call it synchronously only in the case when crypto_acomp_… has already completed (synchronously), in which case the callback would never be invoked automatically. If ret == -EINPROGRESS, the behavior remains asynchronous.
This follows the standard pattern used in the kernel. For example:
In xfrm_ipcomp.c: https://github.com/jonmason/ntb/blob/09ca5e67c4ab3c8bff7aef6085ee0cbb4337c3f8/net/xfrm/xfrm_ipcomp.c#L272
In crypto/acompress.c: https://github.com/torvalds/linux/blob/master/crypto/acompress.c#L278
lib/luacrypto_acompress.c
Outdated
| lua_pushvalue(L, 1); /* push TFM object */ | ||
| req->tfm = luaL_ref(L, LUA_REGISTRYINDEX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a macro for this pattern on lunatik.h, right? couldn't we use it?
| obj-$(CONFIG_LUNATIK_CRYPTO_AEAD) += lib/luacrypto_aead.o | ||
| obj-$(CONFIG_LUNATIK_CRYPTO_RNG) += lib/luacrypto_rng.o | ||
| obj-$(CONFIG_LUNATIK_CRYPTO_COMP) += lib/luacrypto_comp.o | ||
| obj-$(CONFIG_LUNATIK_CRYPTO_ACOMPRESS) += lib/luacrypto_acompress.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we keep comp for older kernels?
Fixes #307