Merge tag 'armsoc-late' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[sfrench/cifs-2.6.git] / Documentation / crypto / crypto_engine.rst
1 =============
2 CRYPTO ENGINE
3 =============
4
5 Overview
6 --------
7 The crypto engine API (CE), is a crypto queue manager.
8
9 Requirement
10 -----------
11 You have to put at start of your tfm_ctx the struct crypto_engine_ctx::
12
13   struct your_tfm_ctx {
14         struct crypto_engine_ctx enginectx;
15         ...
16   };
17
18 Why: Since CE manage only crypto_async_request, it cannot know the underlying
19 request_type and so have access only on the TFM.
20 So using container_of for accessing __ctx is impossible.
21 Furthermore, the crypto engine cannot know the "struct your_tfm_ctx",
22 so it must assume that crypto_engine_ctx is at start of it.
23
24 Order of operations
25 -------------------
26 You have to obtain a struct crypto_engine via crypto_engine_alloc_init().
27 And start it via crypto_engine_start().
28
29 Before transferring any request, you have to fill the enginectx.
30 - prepare_request: (taking a function pointer) If you need to do some processing before doing the request
31 - unprepare_request: (taking a function pointer) Undoing what's done in prepare_request
32 - do_one_request: (taking a function pointer) Do encryption for current request
33
34 Note: that those three functions get the crypto_async_request associated with the received request.
35 So your need to get the original request via container_of(areq, struct yourrequesttype_request, base);
36
37 When your driver receive a crypto_request, you have to transfer it to
38 the cryptoengine via one of:
39 - crypto_transfer_ablkcipher_request_to_engine()
40 - crypto_transfer_aead_request_to_engine()
41 - crypto_transfer_akcipher_request_to_engine()
42 - crypto_transfer_hash_request_to_engine()
43 - crypto_transfer_skcipher_request_to_engine()
44
45 At the end of the request process, a call to one of the following function is needed:
46 - crypto_finalize_ablkcipher_request
47 - crypto_finalize_aead_request
48 - crypto_finalize_akcipher_request
49 - crypto_finalize_hash_request
50 - crypto_finalize_skcipher_request