aead.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * AEAD: Authenticated Encryption with Associated Data
  3. *
  4. * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. */
  12. #ifndef _CRYPTO_INTERNAL_AEAD_H
  13. #define _CRYPTO_INTERNAL_AEAD_H
  14. #include <crypto/aead.h>
  15. #include <crypto/algapi.h>
  16. #include <linux/types.h>
  17. struct rtattr;
  18. struct crypto_aead_spawn {
  19. struct crypto_spawn base;
  20. };
  21. extern const struct crypto_type crypto_nivaead_type;
  22. static inline void crypto_set_aead_spawn(
  23. struct crypto_aead_spawn *spawn, struct crypto_instance *inst)
  24. {
  25. crypto_set_spawn(&spawn->base, inst);
  26. }
  27. int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name,
  28. u32 type, u32 mask);
  29. static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
  30. {
  31. crypto_drop_spawn(&spawn->base);
  32. }
  33. static inline struct crypto_alg *crypto_aead_spawn_alg(
  34. struct crypto_aead_spawn *spawn)
  35. {
  36. return spawn->base.alg;
  37. }
  38. static inline struct crypto_aead *crypto_spawn_aead(
  39. struct crypto_aead_spawn *spawn)
  40. {
  41. return __crypto_aead_cast(
  42. crypto_spawn_tfm(&spawn->base, CRYPTO_ALG_TYPE_AEAD,
  43. CRYPTO_ALG_TYPE_MASK));
  44. }
  45. struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl,
  46. struct rtattr **tb, u32 type,
  47. u32 mask);
  48. void aead_geniv_free(struct crypto_instance *inst);
  49. int aead_geniv_init(struct crypto_tfm *tfm);
  50. void aead_geniv_exit(struct crypto_tfm *tfm);
  51. static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv)
  52. {
  53. return crypto_aead_crt(geniv)->base;
  54. }
  55. static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req)
  56. {
  57. return aead_request_ctx(&req->areq);
  58. }
  59. static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req,
  60. int err)
  61. {
  62. aead_request_complete(&req->areq, err);
  63. }
  64. #endif /* _CRYPTO_INTERNAL_AEAD_H */