qcrypto.h 2.0 KB

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