;sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget(/translations/zh_CN/crypto/crypto_enginemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/zh_TW/crypto/crypto_enginemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/it_IT/crypto/crypto_enginemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ja_JP/crypto/crypto_enginemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ko_KR/crypto/crypto_enginemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/sp_SP/crypto/crypto_enginemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhB/var/lib/git/docbuild/linux/Documentation/crypto/crypto_engine.rsthKubhsection)}(hhh](htitle)}(h Crypto Engineh]h Crypto Engine}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(h5The crypto engine (CE) API is a crypto queue manager.h]h5The crypto engine (CE) API is a crypto queue manager.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Requirementh]h Requirement}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(h_You must put, at the start of your transform context your_tfm_ctx, the structure crypto_engine:h]h_You must put, at the start of your transform context your_tfm_ctx, the structure crypto_engine:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh literal_block)}(hIstruct your_tfm_ctx { struct crypto_engine engine; ... };h]hIstruct your_tfm_ctx { struct crypto_engine engine; ... };}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhhhhubh)}(hXThe 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.h](hX5The 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 “}(hj!hhhNhNubhliteral)}(h``struct your_tfm_ctx``h]hstruct your_tfm_ctx}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1j)hj!ubhE”. The engine assumes (requires) the placement of the known member }(hj!hhhNhNubj*)}(h``struct crypto_engine``h]hstruct crypto_engine}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1j)hj!ubh at the beginning.}(hj!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h] requirementah ]h"] requirementah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(hOrder of operationsh]hOrder of operations}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj]hhhhhKubh)}(hXYou 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()``.h](h6You are required to obtain a struct crypto_engine via }(hjnhhhNhNubj*)}(h``crypto_engine_alloc_init()``h]hcrypto_engine_alloc_init()}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjnubh. Start it via }(hjnhhhNhNubj*)}(h``crypto_engine_start()``h]hcrypto_engine_start()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjnubh;. When finished with your work, shut down the engine using }(hjnhhhNhNubj*)}(h``crypto_engine_stop()``h]hcrypto_engine_stop()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjnubh and destroy the engine with }(hjnhhhNhNubj*)}(h``crypto_engine_exit()``h]hcrypto_engine_exit()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjnubh.}(hjnhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj]hhubh)}(hqBefore transferring any request, you have to fill the context enginectx by providing functions for the following:h]hqBefore transferring any request, you have to fill the context enginectx by providing functions for the following:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hj]hhubh bullet_list)}(hhh](h list_item)}(h``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. h]h)}(h``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.h](j*)}(h``prepare_cipher_request``h]hprepare_cipher_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjubh/}(hjhhhNhNubj*)}(h``prepare_hash_request``h]hprepare_hash_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjubh~: Called before each corresponding request is performed. If some processing or other preparatory work is required, do it here.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK'hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h``unprepare_cipher_request``/``unprepare_hash_request``: Called after each request is handled. Clean up / undo what was done in the prepare function. h]h)}(h``unprepare_cipher_request``/``unprepare_hash_request``: Called after each request is handled. Clean up / undo what was done in the prepare function.h](j*)}(h``unprepare_cipher_request``h]hunprepare_cipher_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjubh/}(hjhhhNhNubj*)}(h``unprepare_hash_request``h]hunprepare_hash_request}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjubh^: Called after each request is handled. Clean up / undo what was done in the prepare function.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK+hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(he``cipher_one_request``/``hash_one_request``: Handle the current request by performing the operation. h]h)}(hd``cipher_one_request``/``hash_one_request``: Handle the current request by performing the operation.h](j*)}(h``cipher_one_request``h]hcipher_one_request}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjMubh/}(hjMhhhNhNubj*)}(h``hash_one_request``h]hhash_one_request}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1j)hjMubh9: Handle the current request by performing the operation.}(hjMhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK.hjIubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1jhhhK'hj]hhubh)}(hNote that these functions access the crypto_async_request structure associated with the received request. You are able to retrieve the original request by using:h]hNote that these functions access the crypto_async_request structure associated with the received request. You are able to retrieve the original request by using:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hj]hhubj)}(h9container_of(areq, struct yourrequesttype_request, base);h]h9container_of(areq, struct yourrequesttype_request, base);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK7hj]hhubh)}(hdWhen your driver receives a crypto_request, you must to transfer it to the crypto engine via one of:h]hdWhen your driver receives a crypto_request, you must to transfer it to the crypto engine via one of:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hj]hhubj)}(hhh](j)}(h)crypto_transfer_aead_request_to_engine() h]h)}(h(crypto_transfer_aead_request_to_engine()h]h(crypto_transfer_aead_request_to_engine()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h)crypto_transfer_hash_request_to_engine() h]h)}(h(crypto_transfer_hash_request_to_engine()h]h(crypto_transfer_hash_request_to_engine()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h(crypto_transfer_kpp_request_to_engine() h]h)}(h'crypto_transfer_kpp_request_to_engine()h]h'crypto_transfer_kpp_request_to_engine()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKBhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h-crypto_transfer_skcipher_request_to_engine() h]h)}(h,crypto_transfer_skcipher_request_to_engine()h]h,crypto_transfer_skcipher_request_to_engine()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhK