aead.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, Linaro Limited. All rights reserved.
  4. */
  5. #ifndef _AEAD_H_
  6. #define _AEAD_H_
  7. #include "common.h"
  8. #include "core.h"
  9. #define QCE_MAX_KEY_SIZE 64
  10. #define QCE_CCM4309_SALT_SIZE 3
  11. struct qce_aead_ctx {
  12. u8 enc_key[QCE_MAX_KEY_SIZE];
  13. u8 auth_key[QCE_MAX_KEY_SIZE];
  14. u8 ccm4309_salt[QCE_CCM4309_SALT_SIZE];
  15. unsigned int enc_keylen;
  16. unsigned int auth_keylen;
  17. unsigned int authsize;
  18. bool need_fallback;
  19. struct crypto_aead *fallback;
  20. };
  21. struct qce_aead_reqctx {
  22. unsigned long flags;
  23. u8 *iv;
  24. unsigned int ivsize;
  25. int src_nents;
  26. int dst_nents;
  27. struct scatterlist result_sg;
  28. struct scatterlist adata_sg;
  29. struct sg_table dst_tbl;
  30. struct sg_table src_tbl;
  31. struct scatterlist *dst_sg;
  32. struct scatterlist *src_sg;
  33. unsigned int cryptlen;
  34. unsigned int assoclen;
  35. unsigned char *adata;
  36. u8 ccm_nonce[QCE_MAX_NONCE];
  37. u8 ccmresult_buf[QCE_BAM_BURST_SIZE];
  38. u8 ccm_rfc4309_iv[QCE_MAX_IV_SIZE];
  39. struct aead_request fallback_req;
  40. };
  41. static inline struct qce_alg_template *to_aead_tmpl(struct crypto_aead *tfm)
  42. {
  43. struct aead_alg *alg = crypto_aead_alg(tfm);
  44. return container_of(alg, struct qce_alg_template, alg.aead);
  45. }
  46. extern const struct qce_algo_ops aead_ops;
  47. #endif /* _AEAD_H_ */