aead.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask);
  28. int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name,
  29. u32 type, u32 mask);
  30. static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
  31. {
  32. crypto_drop_spawn(&spawn->base);
  33. }
  34. static inline struct crypto_alg *crypto_aead_spawn_alg(
  35. struct crypto_aead_spawn *spawn)
  36. {
  37. return spawn->base.alg;
  38. }
  39. static inline struct crypto_aead *crypto_spawn_aead(
  40. struct crypto_aead_spawn *spawn)
  41. {
  42. return __crypto_aead_cast(
  43. crypto_spawn_tfm(&spawn->base, CRYPTO_ALG_TYPE_AEAD,
  44. CRYPTO_ALG_TYPE_MASK));
  45. }
  46. struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl,
  47. struct rtattr **tb, u32 type,
  48. u32 mask);
  49. void aead_geniv_free(struct crypto_instance *inst);
  50. int aead_geniv_init(struct crypto_tfm *tfm);
  51. void aead_geniv_exit(struct crypto_tfm *tfm);
  52. static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv)
  53. {
  54. return crypto_aead_crt(geniv)->base;
  55. }
  56. static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req)
  57. {
  58. return aead_request_ctx(&req->areq);
  59. }
  60. static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req,
  61. int err)
  62. {
  63. aead_request_complete(&req->areq, err);
  64. }
  65. #endif /* _CRYPTO_INTERNAL_AEAD_H */