blob: 2a52e1690512284c903927512b07804010b2912d [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
Heinrich Schuchardtbd198b32024-12-06 12:37:09 +01009#include <linux/kconfig.h>
10
11#if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
Raymond Maoa571b982024-10-03 14:50:16 -070012#include <mbedtls/md5.h>
13#endif
Mike Frysinger4ad8e9f2009-07-02 19:23:25 -040014#include "compiler.h"
Andy Fleming72c23be2008-04-02 16:19:07 -050015
Alexandru Gagniucf3016582021-09-02 19:54:20 -050016#define MD5_SUM_LEN 16
Raymond Maoc35e1a42024-10-03 14:50:17 -070017#define MD5_DEF_CHUNK_SZ 0x10000
Alexandru Gagniucf3016582021-09-02 19:54:20 -050018
Heinrich Schuchardtbd198b32024-12-06 12:37:09 +010019#if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
Raymond Maoa571b982024-10-03 14:50:16 -070020typedef mbedtls_md5_context MD5Context;
21#else
Raymond Maocdc93182024-05-16 14:11:51 -070022typedef struct MD5Context {
Andy Fleming72c23be2008-04-02 16:19:07 -050023 __u32 buf[4];
24 __u32 bits[2];
Marek Vasute7ab3802012-04-29 00:28:40 +020025 union {
26 unsigned char in[64];
27 __u32 in32[16];
28 };
Raymond Maocdc93182024-05-16 14:11:51 -070029} MD5Context;
Raymond Maoa571b982024-10-03 14:50:16 -070030#endif
Andy Fleming72c23be2008-04-02 16:19:07 -050031
Raymond Maocdc93182024-05-16 14:11:51 -070032void MD5Init(MD5Context *ctx);
33void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len);
34void MD5Final(unsigned char digest[16], MD5Context *ctx);
Chia-Wei Wangabc83f92021-07-30 09:08:02 +080035
Andy Fleming72c23be2008-04-02 16:19:07 -050036/*
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020037 * 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 */
Alexandru Gagniucf3016582021-09-02 19:54:20 -050041void md5_wd(const unsigned char *input, unsigned int len,
42 unsigned char output[16], unsigned int chunk_sz);
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020043
Andy Fleming72c23be2008-04-02 16:19:07 -050044#endif /* _MD5_H */