Commit ae400be9 authored by Hook, Gary's avatar Hook, Gary Committed by Herbert Xu

crypto: doc - Fix formatting of new crypto engine content

Tidy up the formatting/grammar in crypto_engine.rst. Use bulleted lists
where appropriate.
Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 5a35316d
============= .. SPDX-License-Identifier: GPL-2.0
CRYPTO ENGINE Crypto Engine
============= =============
Overview Overview
-------- --------
The crypto engine API (CE), is a crypto queue manager. The crypto engine (CE) API is a crypto queue manager.
Requirement Requirement
----------- -----------
You have to put at start of your tfm_ctx the struct crypto_engine_ctx:: You must put, at the start of your transform context your_tfm_ctx, the structure
crypto_engine:
::
struct your_tfm_ctx { struct your_tfm_ctx {
struct crypto_engine_ctx enginectx; struct crypto_engine engine;
... ...
}; };
Why: Since CE manage only crypto_async_request, it cannot know the underlying The crypto engine only manages asynchronous requests in the form of
request_type and so have access only on the TFM. crypto_async_request. It cannot know the underlying request type and thus only
So using container_of for accessing __ctx is impossible. has access to the transform structure. It is not possible to access the context
Furthermore, the crypto engine cannot know the "struct your_tfm_ctx", using container_of. In addition, the engine knows nothing about your
so it must assume that crypto_engine_ctx is at start of it. structure "``struct your_tfm_ctx``". The engine assumes (requires) the placement
of the known member ``struct crypto_engine`` at the beginning.
Order of operations Order of operations
------------------- -------------------
You have to obtain a struct crypto_engine via crypto_engine_alloc_init(). You are required to obtain a struct crypto_engine via ``crypto_engine_alloc_init()``.
And start it via crypto_engine_start(). Start it via ``crypto_engine_start()``. When finished with your work, shut down the
engine using ``crypto_engine_stop()`` and destroy the engine with
Before transferring any request, you have to fill the enginectx. ``crypto_engine_exit()``.
- prepare_request: (taking a function pointer) If you need to do some processing before doing the request
- unprepare_request: (taking a function pointer) Undoing what's done in prepare_request Before transferring any request, you have to fill the context enginectx by
- do_one_request: (taking a function pointer) Do encryption for current request providing functions for the following:
Note: that those three functions get the crypto_async_request associated with the received request. * ``prepare_crypt_hardware``: Called once before any prepare functions are
So your need to get the original request via container_of(areq, struct yourrequesttype_request, base); called.
When your driver receive a crypto_request, you have to transfer it to * ``unprepare_crypt_hardware``: Called once after all unprepare functions have
the cryptoengine via one of: been called.
- crypto_transfer_ablkcipher_request_to_engine()
- crypto_transfer_aead_request_to_engine() * ``prepare_cipher_request``/``prepare_hash_request``: Called before each
- crypto_transfer_akcipher_request_to_engine() corresponding request is performed. If some processing or other preparatory
- crypto_transfer_hash_request_to_engine() work is required, do it here.
- crypto_transfer_skcipher_request_to_engine()
* ``unprepare_cipher_request``/``unprepare_hash_request``: Called after each
At the end of the request process, a call to one of the following function is needed: request is handled. Clean up / undo what was done in the prepare function.
- crypto_finalize_ablkcipher_request
- crypto_finalize_aead_request * ``cipher_one_request``/``hash_one_request``: Handle the current request by
- crypto_finalize_akcipher_request performing the operation.
- crypto_finalize_hash_request
- crypto_finalize_skcipher_request 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_ablkcipher_request_to_engine()
* crypto_transfer_aead_request_to_engine()
* crypto_transfer_akcipher_request_to_engine()
* crypto_transfer_hash_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_ablkcipher_request()
* crypto_finalize_aead_request()
* crypto_finalize_akcipher_request()
* crypto_finalize_hash_request()
* crypto_finalize_skcipher_request()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment