crypto_engine.rst 1.9 KB

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