cipher.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _CIPHER_H_
  14. #define _CIPHER_H_
  15. #include "common.h"
  16. #include "core.h"
  17. #define QCE_MAX_KEY_SIZE 64
  18. struct qce_cipher_ctx {
  19. u8 enc_key[QCE_MAX_KEY_SIZE];
  20. unsigned int enc_keylen;
  21. struct crypto_ablkcipher *fallback;
  22. };
  23. /**
  24. * struct qce_cipher_reqctx - holds private cipher objects per request
  25. * @flags: operation flags
  26. * @iv: pointer to the IV
  27. * @ivsize: IV size
  28. * @src_nents: source entries
  29. * @dst_nents: destination entries
  30. * @result_sg: scatterlist used for result buffer
  31. * @dst_tbl: destination sg table
  32. * @dst_sg: destination sg pointer table beginning
  33. * @src_tbl: source sg table
  34. * @src_sg: source sg pointer table beginning;
  35. * @cryptlen: crypto length
  36. */
  37. struct qce_cipher_reqctx {
  38. unsigned long flags;
  39. u8 *iv;
  40. unsigned int ivsize;
  41. int src_nents;
  42. int dst_nents;
  43. struct scatterlist result_sg;
  44. struct sg_table dst_tbl;
  45. struct scatterlist *dst_sg;
  46. struct sg_table src_tbl;
  47. struct scatterlist *src_sg;
  48. unsigned int cryptlen;
  49. };
  50. static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_tfm *tfm)
  51. {
  52. struct crypto_alg *alg = tfm->__crt_alg;
  53. return container_of(alg, struct qce_alg_template, alg.crypto);
  54. }
  55. extern const struct qce_algo_ops ablkcipher_ops;
  56. #endif /* _CIPHER_H_ */