blob: c6e8eabf68a77f5a8c67e51ff5d8a78001ee571d [file] [log] [blame]
Raymond Mao87010c32024-10-03 14:50:15 -07001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2024 Linaro Limited
4 * Author: Raymond Mao <raymond.mao@linaro.org>
5 */
6#ifndef MD5_ALT_H
7#define MD5_ALT_H
8
9#include <image.h>
10#include <u-boot/md5.h>
11
12typedef MD5Context mbedtls_md5_context;
13
14static inline void mbedtls_md5_init(mbedtls_md5_context *ctx)
15{
16}
17
18static inline void mbedtls_md5_free(mbedtls_md5_context *ctx)
19{
20}
21
22static inline void
23mbedtls_md5_clone(mbedtls_md5_context *dst, const mbedtls_md5_context *src)
24{
25 *dst = *src;
26}
27
28static inline int mbedtls_md5_starts(mbedtls_md5_context *ctx)
29{
30 MD5Init(ctx);
31 return 0;
32}
33
34static inline int mbedtls_md5_update(mbedtls_md5_context *ctx,
35 const unsigned char *input,
36 size_t ilen)
37{
38 MD5Update(ctx, input, ilen);
39 return 0;
40}
41
42static inline int mbedtls_md5_finish(mbedtls_md5_context *ctx,
43 unsigned char output[16])
44{
45 MD5Final(output, ctx);
46 return 0;
47}
48
49static inline int mbedtls_md5(const unsigned char *input,
50 size_t ilen,
51 unsigned char output[16])
52{
53 md5_wd(input, ilen, output, CHUNKSZ_MD5);
54 return 0;
55}
56
57#endif /* md5_alt.h */