md5.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* $MirOS: src/kern/include/md5.h,v 1.4 2014/12/20 22:28:45 tg Exp $ */
  2. #ifndef SYSKERN_MD5_H
  3. #define SYSKERN_MD5_H
  4. #ifdef __MirBSD__
  5. #include <machine/types.h>
  6. #endif
  7. #define MD5_BLOCK_LENGTH 64
  8. #define MD5_DIGEST_LENGTH 16
  9. #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
  10. typedef struct MD5Context {
  11. uint32_t state[4];
  12. uint64_t count;
  13. uint8_t buffer[MD5_BLOCK_LENGTH];
  14. } MD5_CTX;
  15. __BEGIN_DECLS
  16. /* low-level functions */
  17. void MD5Init(MD5_CTX *);
  18. void MD5Update(MD5_CTX *, const uint8_t *, size_t)
  19. __attribute__((__bounded__(__string__, 2, 3)));
  20. void MD5Pad(MD5_CTX *);
  21. void MD5Final(uint8_t *, MD5_CTX *)
  22. __attribute__((__bounded__(__minbytes__, 1, MD5_DIGEST_LENGTH)));
  23. void MD5Transform(uint32_t *, const uint8_t *)
  24. __attribute__((__bounded__(__minbytes__, 1, 16)))
  25. __attribute__((__bounded__(__minbytes__, 2, MD5_BLOCK_LENGTH)));
  26. #if !defined(_KERNEL) && !defined(_STANDALONE)
  27. /* high-level functions from helper.c */
  28. char *MD5End(MD5_CTX *, char *)
  29. __attribute__((__bounded__(__minbytes__, 2, MD5_DIGEST_STRING_LENGTH)));
  30. char *MD5File(const char *, char *)
  31. __attribute__((__bounded__(__minbytes__, 2, MD5_DIGEST_STRING_LENGTH)));
  32. char *MD5FileChunk(const char *, char *, off_t, off_t)
  33. __attribute__((__bounded__(__minbytes__, 2, MD5_DIGEST_STRING_LENGTH)));
  34. char *MD5Data(const uint8_t *, size_t, char *)
  35. __attribute__((__bounded__(__string__, 1, 2)))
  36. __attribute__((__bounded__(__minbytes__, 3, MD5_DIGEST_STRING_LENGTH)));
  37. #endif
  38. __END_DECLS
  39. #endif