Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
81 lines
2.4 KiB
ReStructuredText
81 lines
2.4 KiB
ReStructuredText
.. SPDX-License-Identifier: GPL-2.0
|
|
|
|
Crypto Engine
|
|
=============
|
|
|
|
Overview
|
|
--------
|
|
The crypto engine (CE) API is a crypto queue manager.
|
|
|
|
Requirement
|
|
-----------
|
|
You must put, at the start of your transform context your_tfm_ctx, the structure
|
|
crypto_engine:
|
|
|
|
::
|
|
|
|
struct your_tfm_ctx {
|
|
struct crypto_engine engine;
|
|
...
|
|
};
|
|
|
|
The crypto engine only manages asynchronous requests in the form of
|
|
crypto_async_request. It cannot know the underlying request type and thus only
|
|
has access to the transform structure. It is not possible to access the context
|
|
using container_of. In addition, the engine knows nothing about your
|
|
structure "``struct your_tfm_ctx``". The engine assumes (requires) the placement
|
|
of the known member ``struct crypto_engine`` at the beginning.
|
|
|
|
Order of operations
|
|
-------------------
|
|
You are required to obtain a struct crypto_engine via ``crypto_engine_alloc_init()``.
|
|
Start it via ``crypto_engine_start()``. When finished with your work, shut down the
|
|
engine using ``crypto_engine_stop()`` and destroy the engine with
|
|
``crypto_engine_exit()``.
|
|
|
|
Before transferring any request, you have to fill the context enginectx by
|
|
providing functions for the following:
|
|
|
|
* ``prepare_cipher_request``/``prepare_hash_request``: Called before each
|
|
corresponding request is performed. If some processing or other preparatory
|
|
work is required, do it here.
|
|
|
|
* ``unprepare_cipher_request``/``unprepare_hash_request``: Called after each
|
|
request is handled. Clean up / undo what was done in the prepare function.
|
|
|
|
* ``cipher_one_request``/``hash_one_request``: Handle the current request by
|
|
performing the operation.
|
|
|
|
Note that these functions access the crypto_async_request structure
|
|
associated with the received request. You are able to retrieve the original
|
|
request by using:
|
|
|
|
::
|
|
|
|
container_of(areq, struct yourrequesttype_request, base);
|
|
|
|
When your driver receives a crypto_request, you must to transfer it to
|
|
the crypto engine via one of:
|
|
|
|
* crypto_transfer_aead_request_to_engine()
|
|
|
|
* crypto_transfer_akcipher_request_to_engine()
|
|
|
|
* crypto_transfer_hash_request_to_engine()
|
|
|
|
* crypto_transfer_kpp_request_to_engine()
|
|
|
|
* crypto_transfer_skcipher_request_to_engine()
|
|
|
|
At the end of the request process, a call to one of the following functions is needed:
|
|
|
|
* crypto_finalize_aead_request()
|
|
|
|
* crypto_finalize_akcipher_request()
|
|
|
|
* crypto_finalize_hash_request()
|
|
|
|
* crypto_finalize_kpp_request()
|
|
|
|
* crypto_finalize_skcipher_request()
|