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