esp_rom_md5.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <stdint.h>
  19. /**
  20. * The MD5 functions calculate a 128-bit cryptographic digest for any number of input bytes.
  21. */
  22. /**
  23. * @brief Type defined for MD5 context
  24. *
  25. */
  26. typedef struct MD5Context {
  27. uint32_t buf[4];
  28. uint32_t bits[2];
  29. uint8_t in[64];
  30. } md5_context_t;
  31. /**
  32. * @brief Initialize the MD5 context
  33. *
  34. * @param context Context object allocated by user
  35. */
  36. void esp_rom_md5_init(md5_context_t *context);
  37. /**
  38. * @brief Running MD5 algorithm over input data
  39. *
  40. * @param context MD5 context which has been initialized by `MD5Init`
  41. * @param buf Input buffer
  42. * @param len Buffer length
  43. */
  44. void esp_rom_md5_update(md5_context_t *context, const uint8_t *buf, uint32_t len);
  45. /**
  46. * @brief Extract the MD5 result, and erase the context
  47. *
  48. * @param digest Where to store the 128-bit digest value
  49. * @param context MD5 context
  50. */
  51. void esp_rom_md5_final(uint8_t digest[16], md5_context_t *context);
  52. #ifdef __cplusplus
  53. }
  54. #endif