blob: c98b1a580882688988e4b39b252c1e2f6c36b2bb [file] [log] [blame]
Andy Fleming72c23be2008-04-02 16:19:07 -05001/*
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
Raymond Maoa571b982024-10-03 14:50:16 -07009#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
10#include <mbedtls/md5.h>
11#endif
Mike Frysinger4ad8e9f2009-07-02 19:23:25 -040012#include "compiler.h"
Andy Fleming72c23be2008-04-02 16:19:07 -050013
Alexandru Gagniucf3016582021-09-02 19:54:20 -050014#define MD5_SUM_LEN 16
Raymond Maoc35e1a42024-10-03 14:50:17 -070015#define MD5_DEF_CHUNK_SZ 0x10000
Alexandru Gagniucf3016582021-09-02 19:54:20 -050016
Raymond Maoa571b982024-10-03 14:50:16 -070017#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
18typedef mbedtls_md5_context MD5Context;
19#else
Raymond Maocdc93182024-05-16 14:11:51 -070020typedef struct MD5Context {
Andy Fleming72c23be2008-04-02 16:19:07 -050021 __u32 buf[4];
22 __u32 bits[2];
Marek Vasute7ab3802012-04-29 00:28:40 +020023 union {
24 unsigned char in[64];
25 __u32 in32[16];
26 };
Raymond Maocdc93182024-05-16 14:11:51 -070027} MD5Context;
Raymond Maoa571b982024-10-03 14:50:16 -070028#endif
Andy Fleming72c23be2008-04-02 16:19:07 -050029
Raymond Maocdc93182024-05-16 14:11:51 -070030void MD5Init(MD5Context *ctx);
31void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len);
32void MD5Final(unsigned char digest[16], MD5Context *ctx);
Chia-Wei Wangabc83f92021-07-30 09:08:02 +080033
Andy Fleming72c23be2008-04-02 16:19:07 -050034/*
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020035 * Calculate and store in 'output' the MD5 digest of 'len' bytes at 'input'.
36 * 'output' must have enough space to hold 16 bytes. If 'chunk' Trigger the
37 * watchdog every 'chunk_sz' bytes of input processed.
38 */
Alexandru Gagniucf3016582021-09-02 19:54:20 -050039void md5_wd(const unsigned char *input, unsigned int len,
40 unsigned char output[16], unsigned int chunk_sz);
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020041
Andy Fleming72c23be2008-04-02 16:19:07 -050042#endif /* _MD5_H */