checksum.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2011-2014 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_CHECKSUM_H
  23. #define __ELL_CHECKSUM_H
  24. #include <stdbool.h>
  25. #include <stdint.h>
  26. #include <sys/uio.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. struct l_checksum;
  31. enum l_checksum_type {
  32. L_CHECKSUM_NONE,
  33. L_CHECKSUM_MD4,
  34. L_CHECKSUM_MD5,
  35. L_CHECKSUM_SHA1,
  36. L_CHECKSUM_SHA224,
  37. L_CHECKSUM_SHA256,
  38. L_CHECKSUM_SHA384,
  39. L_CHECKSUM_SHA512,
  40. };
  41. struct l_checksum *l_checksum_new(enum l_checksum_type type);
  42. struct l_checksum *l_checksum_new_cmac_aes(const void *key, size_t key_len);
  43. struct l_checksum *l_checksum_new_hmac(enum l_checksum_type type,
  44. const void *key, size_t key_len);
  45. struct l_checksum *l_checksum_clone(struct l_checksum *checksum);
  46. void l_checksum_free(struct l_checksum *checksum);
  47. void l_checksum_reset(struct l_checksum *checksum);
  48. bool l_checksum_update(struct l_checksum *checksum,
  49. const void *data, size_t len);
  50. bool l_checksum_updatev(struct l_checksum *checksum,
  51. const struct iovec *iov,
  52. size_t iov_len);
  53. ssize_t l_checksum_get_digest(struct l_checksum *checksum,
  54. void *digest, size_t len);
  55. char *l_checksum_get_string(struct l_checksum *checksum);
  56. bool l_checksum_is_supported(enum l_checksum_type type, bool check_hmac);
  57. bool l_checksum_cmac_aes_supported(void);
  58. ssize_t l_checksum_digest_length(enum l_checksum_type type);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif /* __ELL_CHECKSUM_H */