hw_sha.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Header file for SHA hardware acceleration
  4. *
  5. * Copyright (c) 2012 Samsung Electronics
  6. */
  7. #ifndef __HW_SHA_H
  8. #define __HW_SHA_H
  9. #include <hash.h>
  10. /**
  11. * Computes hash value of input pbuf using h/w acceleration
  12. *
  13. * @param in_addr A pointer to the input buffer
  14. * @param bufleni Byte length of input buffer
  15. * @param out_addr A pointer to the output buffer. When complete
  16. * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
  17. * should allocate at least 32 bytes at pOut in advance.
  18. * @param chunk_size chunk size for sha256
  19. */
  20. void hw_sha256(const uchar * in_addr, uint buflen,
  21. uchar * out_addr, uint chunk_size);
  22. /**
  23. * Computes hash value of input pbuf using h/w acceleration
  24. *
  25. * @param in_addr A pointer to the input buffer
  26. * @param bufleni Byte length of input buffer
  27. * @param out_addr A pointer to the output buffer. When complete
  28. * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
  29. * should allocate at least 32 bytes at pOut in advance.
  30. * @param chunk_size chunk_size for sha1
  31. */
  32. void hw_sha1(const uchar * in_addr, uint buflen,
  33. uchar * out_addr, uint chunk_size);
  34. /*
  35. * Create the context for sha progressive hashing using h/w acceleration
  36. *
  37. * @algo: Pointer to the hash_algo struct
  38. * @ctxp: Pointer to the pointer of the context for hashing
  39. * @return 0 if ok, -ve on error
  40. */
  41. int hw_sha_init(struct hash_algo *algo, void **ctxp);
  42. /*
  43. * Update buffer for sha progressive hashing using h/w acceleration
  44. *
  45. * The context is freed by this function if an error occurs.
  46. *
  47. * @algo: Pointer to the hash_algo struct
  48. * @ctx: Pointer to the context for hashing
  49. * @buf: Pointer to the buffer being hashed
  50. * @size: Size of the buffer being hashed
  51. * @is_last: 1 if this is the last update; 0 otherwise
  52. * @return 0 if ok, -ve on error
  53. */
  54. int hw_sha_update(struct hash_algo *algo, void *ctx, const void *buf,
  55. unsigned int size, int is_last);
  56. /*
  57. * Copy sha hash result at destination location
  58. *
  59. * The context is freed after completion of hash operation or after an error.
  60. *
  61. * @algo: Pointer to the hash_algo struct
  62. * @ctx: Pointer to the context for hashing
  63. * @dest_buf: Pointer to the destination buffer where hash is to be copied
  64. * @size: Size of the buffer being hashed
  65. * @return 0 if ok, -ve on error
  66. */
  67. int hw_sha_finish(struct hash_algo *algo, void *ctx, void *dest_buf,
  68. int size);
  69. #endif