1 /*
2  * This file was transplanted with slight modifications from Linux sources
3  * (fs/cifs/md5.h) into U-Boot by Bartlomiej Sieka <tur@semihalf.com>.
4  */
5 
6 #ifndef _MD5_H
7 #define _MD5_H
8 
9 #include <linux/kconfig.h>
10 
11 #if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
12 #include <mbedtls/md5.h>
13 #endif
14 #include "compiler.h"
15 
16 #define MD5_SUM_LEN	16
17 #define MD5_DEF_CHUNK_SZ 0x10000
18 
19 #if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
20 typedef mbedtls_md5_context MD5Context;
21 #else
22 typedef struct MD5Context {
23 	__u32 buf[4];
24 	__u32 bits[2];
25 	union {
26 		unsigned char in[64];
27 		__u32 in32[16];
28 	};
29 } MD5Context;
30 #endif
31 
32 void MD5Init(MD5Context *ctx);
33 void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len);
34 void MD5Final(unsigned char digest[16], MD5Context *ctx);
35 
36 /*
37  * Calculate and store in 'output' the MD5 digest of 'len' bytes at 'input'.
38  * 'output' must have enough space to hold 16 bytes. If 'chunk' Trigger the
39  * watchdog every 'chunk_sz' bytes of input processed.
40  */
41 void md5_wd(const unsigned char *input, unsigned int len,
42 	     unsigned char output[16], unsigned int chunk_sz);
43 
44 #endif /* _MD5_H */
45