hw_sha.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. * 64 bytes are copied to pout[0]...pout[63]. Thus, a user
  17. * should allocate at least 64 bytes at pOut in advance.
  18. * @param chunk_size chunk size for sha512
  19. */
  20. void hw_sha512(const uchar *in_addr, uint buflen, uchar *out_addr,
  21. 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. * 48 bytes are copied to pout[0]...pout[47]. Thus, a user
  29. * should allocate at least 48 bytes at pOut in advance.
  30. * @param chunk_size chunk size for sha384
  31. */
  32. void hw_sha384(const uchar *in_addr, uint buflen, uchar *out_addr,
  33. uint chunk_size);
  34. /**
  35. * Computes hash value of input pbuf using h/w acceleration
  36. *
  37. * @param in_addr A pointer to the input buffer
  38. * @param bufleni Byte length of input buffer
  39. * @param out_addr A pointer to the output buffer. When complete
  40. * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
  41. * should allocate at least 32 bytes at pOut in advance.
  42. * @param chunk_size chunk size for sha256
  43. */
  44. void hw_sha256(const uchar *in_addr, uint buflen, uchar *out_addr,
  45. uint chunk_size);
  46. /**
  47. * Computes hash value of input pbuf using h/w acceleration
  48. *
  49. * @param in_addr A pointer to the input buffer
  50. * @param bufleni Byte length of input buffer
  51. * @param out_addr A pointer to the output buffer. When complete
  52. * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
  53. * should allocate at least 32 bytes at pOut in advance.
  54. * @param chunk_size chunk_size for sha1
  55. */
  56. void hw_sha1(const uchar *in_addr, uint buflen, uchar *out_addr,
  57. uint chunk_size);
  58. /*
  59. * Create the context for sha progressive hashing using h/w acceleration
  60. *
  61. * @algo: Pointer to the hash_algo struct
  62. * @ctxp: Pointer to the pointer of the context for hashing
  63. * Return: 0 if ok, -ve on error
  64. */
  65. int hw_sha_init(struct hash_algo *algo, void **ctxp);
  66. /*
  67. * Update buffer for sha progressive hashing using h/w acceleration
  68. *
  69. * The context is freed by this function if an error occurs.
  70. *
  71. * @algo: Pointer to the hash_algo struct
  72. * @ctx: Pointer to the context for hashing
  73. * @buf: Pointer to the buffer being hashed
  74. * @size: Size of the buffer being hashed
  75. * @is_last: 1 if this is the last update; 0 otherwise
  76. * Return: 0 if ok, -ve on error
  77. */
  78. int hw_sha_update(struct hash_algo *algo, void *ctx, const void *buf,
  79. unsigned int size, int is_last);
  80. /*
  81. * Copy sha hash result at destination location
  82. *
  83. * The context is freed after completion of hash operation or after an error.
  84. *
  85. * @algo: Pointer to the hash_algo struct
  86. * @ctx: Pointer to the context for hashing
  87. * @dest_buf: Pointer to the destination buffer where hash is to be copied
  88. * @size: Size of the buffer being hashed
  89. * Return: 0 if ok, -ve on error
  90. */
  91. int hw_sha_finish(struct hash_algo *algo, void *ctx, void *dest_buf,
  92. int size);
  93. #endif