hash.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Hash algorithms.
  3. *
  4. * Copyright (c) 2008 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_HASH_H
  13. #define _CRYPTO_INTERNAL_HASH_H
  14. #include <crypto/algapi.h>
  15. #include <crypto/hash.h>
  16. struct ahash_request;
  17. struct scatterlist;
  18. struct crypto_hash_walk {
  19. char *data;
  20. unsigned int offset;
  21. unsigned int alignmask;
  22. struct page *pg;
  23. unsigned int entrylen;
  24. unsigned int total;
  25. struct scatterlist *sg;
  26. unsigned int flags;
  27. };
  28. extern const struct crypto_type crypto_ahash_type;
  29. int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err);
  30. int crypto_hash_walk_first(struct ahash_request *req,
  31. struct crypto_hash_walk *walk);
  32. int crypto_register_shash(struct shash_alg *alg);
  33. int crypto_unregister_shash(struct shash_alg *alg);
  34. static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
  35. {
  36. return crypto_tfm_ctx(&tfm->base);
  37. }
  38. static inline struct ahash_alg *crypto_ahash_alg(
  39. struct crypto_ahash *tfm)
  40. {
  41. return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
  42. }
  43. static inline int ahash_enqueue_request(struct crypto_queue *queue,
  44. struct ahash_request *request)
  45. {
  46. return crypto_enqueue_request(queue, &request->base);
  47. }
  48. static inline struct ahash_request *ahash_dequeue_request(
  49. struct crypto_queue *queue)
  50. {
  51. return ahash_request_cast(crypto_dequeue_request(queue));
  52. }
  53. static inline void *ahash_request_ctx(struct ahash_request *req)
  54. {
  55. return req->__ctx;
  56. }
  57. static inline int ahash_tfm_in_queue(struct crypto_queue *queue,
  58. struct crypto_ahash *tfm)
  59. {
  60. return crypto_tfm_in_queue(queue, crypto_ahash_tfm(tfm));
  61. }
  62. static inline void *crypto_shash_ctx(struct crypto_shash *tfm)
  63. {
  64. return crypto_tfm_ctx(&tfm->base);
  65. }
  66. #endif /* _CRYPTO_INTERNAL_HASH_H */