hw_sha.h 2.4 KB

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