qcrypto.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DRIVERS_CRYPTO_MSM_QCRYPTO_H_
  6. #define _DRIVERS_CRYPTO_MSM_QCRYPTO_H_
  7. #include <linux/crypto.h>
  8. #include <crypto/hash.h>
  9. #include <crypto/skcipher.h>
  10. #include <crypto/aead.h>
  11. #define QCRYPTO_CTX_KEY_MASK 0x000000ff
  12. #define QCRYPTO_CTX_USE_HW_KEY 0x00000001
  13. #define QCRYPTO_CTX_USE_PIPE_KEY 0x00000002
  14. #define QCRYPTO_CTX_XTS_MASK 0x0000ff00
  15. #define QCRYPTO_CTX_XTS_DU_SIZE_512B 0x00000100
  16. #define QCRYPTO_CTX_XTS_DU_SIZE_1KB 0x00000200
  17. int qcrypto_cipher_set_device(struct skcipher_request *req, unsigned int dev);
  18. int qcrypto_ahash_set_device(struct ahash_request *req, unsigned int dev);
  19. int qcrypto_aead_set_device(struct aead_request *req, unsigned int dev);
  20. int qcrypto_cipher_set_flag(struct skcipher_request *req, unsigned int flags);
  21. int qcrypto_ahash_set_flag(struct ahash_request *req, unsigned int flags);
  22. int qcrypto_aead_set_flag(struct aead_request *req, unsigned int flags);
  23. int qcrypto_cipher_clear_flag(struct skcipher_request *req,
  24. unsigned int flags);
  25. int qcrypto_ahash_clear_flag(struct ahash_request *req, unsigned int flags);
  26. int qcrypto_aead_clear_flag(struct aead_request *req, unsigned int flags);
  27. struct crypto_engine_entry {
  28. u32 hw_instance;
  29. u32 ce_device;
  30. int shared;
  31. };
  32. int qcrypto_get_num_engines(void);
  33. void qcrypto_get_engine_list(size_t num_engines,
  34. struct crypto_engine_entry *arr);
  35. int qcrypto_cipher_set_device_hw(struct skcipher_request *req,
  36. unsigned int fde_pfe,
  37. unsigned int hw_inst);
  38. struct qcrypto_func_set {
  39. int (*cipher_set)(struct skcipher_request *req,
  40. unsigned int fde_pfe,
  41. unsigned int hw_inst);
  42. int (*cipher_flag)(struct skcipher_request *req, unsigned int flags);
  43. int (*get_num_engines)(void);
  44. void (*get_engine_list)(size_t num_engines,
  45. struct crypto_engine_entry *arr);
  46. };
  47. #endif /* _DRIVERS_CRYPTO_MSM_QCRYPTO_H */