md5.h 940 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the License); you may
  5. * not use this file except in compliance with the License.
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. */
  9. #ifndef GMSSL_MD5_H
  10. #define GMSSL_MD5_H
  11. #include <string.h>
  12. #include <stdint.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define MD5_IS_BIG_ENDIAN 0
  17. #define MD5_DIGEST_SIZE 16
  18. #define MD5_BLOCK_SIZE 64
  19. #define MD5_STATE_WORDS (MD5_BLOCK_SIZE/sizeof(uint32_t))
  20. typedef struct {
  21. uint32_t state[MD5_STATE_WORDS];
  22. uint64_t nblocks;
  23. uint8_t block[MD5_BLOCK_SIZE];
  24. size_t num;
  25. } MD5_CTX;
  26. void md5_init(MD5_CTX *ctx);
  27. void md5_update(MD5_CTX *ctx, const uint8_t *data, size_t datalen);
  28. void md5_finish(MD5_CTX *ctx, uint8_t dgst[MD5_DIGEST_SIZE]);
  29. void md5_digest(const uint8_t *data, size_t datalen, uint8_t dgst[MD5_DIGEST_SIZE]);
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif