algapi.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Cryptographic API for algorithms (i.e., low-level API).
  3. *
  4. * Copyright (c) 2006 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_ALGAPI_H
  13. #define _CRYPTO_ALGAPI_H
  14. #include <linux/crypto.h>
  15. struct module;
  16. struct crypto_instance {
  17. struct crypto_alg alg;
  18. struct crypto_template *tmpl;
  19. struct hlist_node list;
  20. void *__ctx[] CRYPTO_MINALIGN_ATTR;
  21. };
  22. struct crypto_template {
  23. struct list_head list;
  24. struct hlist_head instances;
  25. struct module *module;
  26. struct crypto_instance *(*alloc)(void *param, unsigned int len);
  27. void (*free)(struct crypto_instance *inst);
  28. char name[CRYPTO_MAX_ALG_NAME];
  29. };
  30. struct crypto_spawn {
  31. struct list_head list;
  32. struct crypto_alg *alg;
  33. struct crypto_instance *inst;
  34. };
  35. int crypto_register_template(struct crypto_template *tmpl);
  36. void crypto_unregister_template(struct crypto_template *tmpl);
  37. struct crypto_template *crypto_lookup_template(const char *name);
  38. int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
  39. struct crypto_instance *inst);
  40. void crypto_drop_spawn(struct crypto_spawn *spawn);
  41. struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn);
  42. struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
  43. u32 type, u32 mask);
  44. struct crypto_instance *crypto_alloc_instance(const char *name,
  45. struct crypto_alg *alg);
  46. static inline void *crypto_instance_ctx(struct crypto_instance *inst)
  47. {
  48. return inst->__ctx;
  49. }
  50. #endif /* _CRYPTO_ALGAPI_H */