engine.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Crypto engine API
  4. *
  5. * Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org>
  6. */
  7. #ifndef _CRYPTO_ENGINE_H
  8. #define _CRYPTO_ENGINE_H
  9. #include <crypto/aead.h>
  10. #include <crypto/akcipher.h>
  11. #include <crypto/hash.h>
  12. #include <crypto/kpp.h>
  13. #include <crypto/skcipher.h>
  14. #include <linux/types.h>
  15. struct crypto_engine;
  16. struct device;
  17. /*
  18. * struct crypto_engine_op - crypto hardware engine operations
  19. * @do_one_request: do encryption for current request
  20. */
  21. struct crypto_engine_op {
  22. int (*do_one_request)(struct crypto_engine *engine,
  23. void *areq);
  24. };
  25. struct aead_engine_alg {
  26. struct aead_alg base;
  27. struct crypto_engine_op op;
  28. };
  29. struct ahash_engine_alg {
  30. struct ahash_alg base;
  31. struct crypto_engine_op op;
  32. };
  33. struct akcipher_engine_alg {
  34. struct akcipher_alg base;
  35. struct crypto_engine_op op;
  36. };
  37. struct kpp_engine_alg {
  38. struct kpp_alg base;
  39. struct crypto_engine_op op;
  40. };
  41. struct skcipher_engine_alg {
  42. struct skcipher_alg base;
  43. struct crypto_engine_op op;
  44. };
  45. int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine,
  46. struct aead_request *req);
  47. int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine,
  48. struct akcipher_request *req);
  49. int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine,
  50. struct ahash_request *req);
  51. int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine,
  52. struct kpp_request *req);
  53. int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine,
  54. struct skcipher_request *req);
  55. void crypto_finalize_aead_request(struct crypto_engine *engine,
  56. struct aead_request *req, int err);
  57. void crypto_finalize_akcipher_request(struct crypto_engine *engine,
  58. struct akcipher_request *req, int err);
  59. void crypto_finalize_hash_request(struct crypto_engine *engine,
  60. struct ahash_request *req, int err);
  61. void crypto_finalize_kpp_request(struct crypto_engine *engine,
  62. struct kpp_request *req, int err);
  63. void crypto_finalize_skcipher_request(struct crypto_engine *engine,
  64. struct skcipher_request *req, int err);
  65. int crypto_engine_start(struct crypto_engine *engine);
  66. int crypto_engine_stop(struct crypto_engine *engine);
  67. struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
  68. struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
  69. bool retry_support,
  70. bool rt, int qlen);
  71. void crypto_engine_exit(struct crypto_engine *engine);
  72. int crypto_engine_register_aead(struct aead_engine_alg *alg);
  73. void crypto_engine_unregister_aead(struct aead_engine_alg *alg);
  74. int crypto_engine_register_aeads(struct aead_engine_alg *algs, int count);
  75. void crypto_engine_unregister_aeads(struct aead_engine_alg *algs, int count);
  76. int crypto_engine_register_ahash(struct ahash_engine_alg *alg);
  77. void crypto_engine_unregister_ahash(struct ahash_engine_alg *alg);
  78. int crypto_engine_register_ahashes(struct ahash_engine_alg *algs, int count);
  79. void crypto_engine_unregister_ahashes(struct ahash_engine_alg *algs,
  80. int count);
  81. int crypto_engine_register_akcipher(struct akcipher_engine_alg *alg);
  82. void crypto_engine_unregister_akcipher(struct akcipher_engine_alg *alg);
  83. int crypto_engine_register_kpp(struct kpp_engine_alg *alg);
  84. void crypto_engine_unregister_kpp(struct kpp_engine_alg *alg);
  85. int crypto_engine_register_skcipher(struct skcipher_engine_alg *alg);
  86. void crypto_engine_unregister_skcipher(struct skcipher_engine_alg *alg);
  87. int crypto_engine_register_skciphers(struct skcipher_engine_alg *algs,
  88. int count);
  89. void crypto_engine_unregister_skciphers(struct skcipher_engine_alg *algs,
  90. int count);
  91. #endif /* _CRYPTO_ENGINE_H */