hash.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_hash_walk_first_compat(struct hash_desc *hdesc,
  33. struct crypto_hash_walk *walk,
  34. struct scatterlist *sg, unsigned int len);
  35. int crypto_register_shash(struct shash_alg *alg);
  36. int crypto_unregister_shash(struct shash_alg *alg);
  37. static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
  38. {
  39. return crypto_tfm_ctx(&tfm->base);
  40. }
  41. static inline struct ahash_alg *crypto_ahash_alg(
  42. struct crypto_ahash *tfm)
  43. {
  44. return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
  45. }
  46. static inline int ahash_enqueue_request(struct crypto_queue *queue,
  47. struct ahash_request *request)
  48. {
  49. return crypto_enqueue_request(queue, &request->base);
  50. }
  51. static inline struct ahash_request *ahash_dequeue_request(
  52. struct crypto_queue *queue)
  53. {
  54. return ahash_request_cast(crypto_dequeue_request(queue));
  55. }
  56. static inline int ahash_tfm_in_queue(struct crypto_queue *queue,
  57. struct crypto_ahash *tfm)
  58. {
  59. return crypto_tfm_in_queue(queue, crypto_ahash_tfm(tfm));
  60. }
  61. static inline void *crypto_shash_ctx(struct crypto_shash *tfm)
  62. {
  63. return crypto_tfm_ctx(&tfm->base);
  64. }
  65. #endif /* _CRYPTO_INTERNAL_HASH_H */