hash.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
  33. {
  34. return crypto_tfm_ctx(&tfm->base);
  35. }
  36. static inline struct ahash_alg *crypto_ahash_alg(
  37. struct crypto_ahash *tfm)
  38. {
  39. return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
  40. }
  41. static inline int ahash_enqueue_request(struct crypto_queue *queue,
  42. struct ahash_request *request)
  43. {
  44. return crypto_enqueue_request(queue, &request->base);
  45. }
  46. static inline struct ahash_request *ahash_dequeue_request(
  47. struct crypto_queue *queue)
  48. {
  49. return ahash_request_cast(crypto_dequeue_request(queue));
  50. }
  51. static inline void *ahash_request_ctx(struct ahash_request *req)
  52. {
  53. return req->__ctx;
  54. }
  55. static inline int ahash_tfm_in_queue(struct crypto_queue *queue,
  56. struct crypto_ahash *tfm)
  57. {
  58. return crypto_tfm_in_queue(queue, crypto_ahash_tfm(tfm));
  59. }
  60. #endif /* _CRYPTO_INTERNAL_HASH_H */