cipher.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * @src_chained: is source chained
  31. * @dst_chained: is destination chained
  32. * @result_sg: scatterlist used for result buffer
  33. * @dst_tbl: destination sg table
  34. * @dst_sg: destination sg pointer table beginning
  35. * @src_tbl: source sg table
  36. * @src_sg: source sg pointer table beginning;
  37. * @cryptlen: crypto length
  38. */
  39. struct qce_cipher_reqctx {
  40. unsigned long flags;
  41. u8 *iv;
  42. unsigned int ivsize;
  43. int src_nents;
  44. int dst_nents;
  45. bool src_chained;
  46. bool dst_chained;
  47. struct scatterlist result_sg;
  48. struct sg_table dst_tbl;
  49. struct scatterlist *dst_sg;
  50. struct sg_table src_tbl;
  51. struct scatterlist *src_sg;
  52. unsigned int cryptlen;
  53. };
  54. static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_tfm *tfm)
  55. {
  56. struct crypto_alg *alg = tfm->__crt_alg;
  57. return container_of(alg, struct qce_alg_template, alg.crypto);
  58. }
  59. extern const struct qce_algo_ops ablkcipher_ops;
  60. #endif /* _CIPHER_H_ */