esp_rom_md5.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #define ESP_ROM_MD5_DIGEST_LEN 16
  32. /**
  33. * @brief Initialize the MD5 context
  34. *
  35. * @param context Context object allocated by user
  36. */
  37. void esp_rom_md5_init(md5_context_t *context);
  38. /**
  39. * @brief Running MD5 algorithm over input data
  40. *
  41. * @param context MD5 context which has been initialized by `MD5Init`
  42. * @param buf Input buffer
  43. * @param len Buffer length in bytes
  44. */
  45. void esp_rom_md5_update(md5_context_t *context, const void *buf, uint32_t len);
  46. /**
  47. * @brief Extract the MD5 result, and erase the context
  48. *
  49. * @param digest Where to store the 128-bit digest value
  50. * @param context MD5 context
  51. */
  52. void esp_rom_md5_final(uint8_t *digest, md5_context_t *context);
  53. #ifdef __cplusplus
  54. }
  55. #endif