blob: 69898fcbe4905e43d16c317b7caaa88df6c15347 [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
15
Raymond Maoa571b982024-10-03 14:50:16 -070016#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
17typedef mbedtls_md5_context MD5Context;
18#else
Raymond Maocdc93182024-05-16 14:11:51 -070019typedef struct MD5Context {
Andy Fleming72c23be2008-04-02 16:19:07 -050020 __u32 buf[4];
21 __u32 bits[2];
Marek Vasute7ab3802012-04-29 00:28:40 +020022 union {
23 unsigned char in[64];
24 __u32 in32[16];
25 };
Raymond Maocdc93182024-05-16 14:11:51 -070026} MD5Context;
Raymond Maoa571b982024-10-03 14:50:16 -070027#endif
Andy Fleming72c23be2008-04-02 16:19:07 -050028
Raymond Maocdc93182024-05-16 14:11:51 -070029void MD5Init(MD5Context *ctx);
30void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len);
31void MD5Final(unsigned char digest[16], MD5Context *ctx);
Chia-Wei Wangabc83f92021-07-30 09:08:02 +080032
Andy Fleming72c23be2008-04-02 16:19:07 -050033/*
34 * Calculate and store in 'output' the MD5 digest of 'len' bytes at
35 * 'input'. 'output' must have enough space to hold 16 bytes.
36 */
37void md5 (unsigned char *input, int len, unsigned char output[16]);
38
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020039/*
40 * Calculate and store in 'output' the MD5 digest of 'len' bytes at 'input'.
41 * 'output' must have enough space to hold 16 bytes. If 'chunk' Trigger the
42 * watchdog every 'chunk_sz' bytes of input processed.
43 */
Alexandru Gagniucf3016582021-09-02 19:54:20 -050044void md5_wd(const unsigned char *input, unsigned int len,
45 unsigned char output[16], unsigned int chunk_sz);
Bartlomiej Siekada5045d2008-04-22 12:27:56 +020046
Andy Fleming72c23be2008-04-02 16:19:07 -050047#endif /* _MD5_H */