Merge tag 'drm-fixes-for-v4.17-rc2' of git://people.freedesktop.org/~airlied/linux
[linux-2.6-microblaze.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 struct your_tfm_ctx {
13         struct crypto_engine_ctx enginectx;
14         ...
15 };
16 Why: Since CE manage only crypto_async_request, it cannot know the underlying
17 request_type and so have access only on the TFM.
18 So using container_of for accessing __ctx is impossible.
19 Furthermore, the crypto engine cannot know the "struct your_tfm_ctx",
20 so it must assume that crypto_engine_ctx is at start of it.
21
22 Order of operations
23 -------------------
24 You have to obtain a struct crypto_engine via crypto_engine_alloc_init().
25 And start it via crypto_engine_start().
26
27 Before transferring any request, you have to fill the enginectx.
28 - prepare_request: (taking a function pointer) If you need to do some processing before doing the request
29 - unprepare_request: (taking a function pointer) Undoing what's done in prepare_request
30 - do_one_request: (taking a function pointer) Do encryption for current request
31
32 Note: that those three functions get the crypto_async_request associated with the received request.
33 So your need to get the original request via container_of(areq, struct yourrequesttype_request, base);
34
35 When your driver receive a crypto_request, you have to transfer it to
36 the cryptoengine via one of:
37 - crypto_transfer_ablkcipher_request_to_engine()
38 - crypto_transfer_aead_request_to_engine()
39 - crypto_transfer_akcipher_request_to_engine()
40 - crypto_transfer_hash_request_to_engine()
41 - crypto_transfer_skcipher_request_to_engine()
42
43 At the end of the request process, a call to one of the following function is needed:
44 - crypto_finalize_ablkcipher_request
45 - crypto_finalize_aead_request
46 - crypto_finalize_akcipher_request
47 - crypto_finalize_hash_request
48 - crypto_finalize_skcipher_request