cipher.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CIPHER_H_
  6. #define _CIPHER_H_
  7. #include "common.h"
  8. #include "core.h"
  9. #define QCE_MAX_KEY_SIZE 64
  10. struct qce_cipher_ctx {
  11. u8 enc_key[QCE_MAX_KEY_SIZE];
  12. unsigned int enc_keylen;
  13. struct crypto_skcipher *fallback;
  14. };
  15. /**
  16. * struct qce_cipher_reqctx - holds private cipher objects per request
  17. * @flags: operation flags
  18. * @iv: pointer to the IV
  19. * @ivsize: IV size
  20. * @src_nents: source entries
  21. * @dst_nents: destination entries
  22. * @result_sg: scatterlist used for result buffer
  23. * @dst_tbl: destination sg table
  24. * @dst_sg: destination sg pointer table beginning
  25. * @src_tbl: source sg table
  26. * @src_sg: source sg pointer table beginning;
  27. * @cryptlen: crypto length
  28. */
  29. struct qce_cipher_reqctx {
  30. unsigned long flags;
  31. u8 *iv;
  32. unsigned int ivsize;
  33. int src_nents;
  34. int dst_nents;
  35. struct scatterlist result_sg;
  36. struct sg_table dst_tbl;
  37. struct scatterlist *dst_sg;
  38. struct sg_table src_tbl;
  39. struct scatterlist *src_sg;
  40. unsigned int cryptlen;
  41. struct skcipher_request fallback_req; // keep at the end
  42. };
  43. static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_skcipher *tfm)
  44. {
  45. struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
  46. return container_of(alg, struct qce_alg_template, alg.skcipher);
  47. }
  48. extern const struct qce_algo_ops skcipher_ops;
  49. #endif /* _CIPHER_H_ */