Raymond Mao | 87010c3 | 2024-10-03 14:50:15 -0700 | [diff] [blame] | 1 | /* 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 | |
| 12 | typedef MD5Context mbedtls_md5_context; |
| 13 | |
| 14 | static inline void mbedtls_md5_init(mbedtls_md5_context *ctx) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | static inline void mbedtls_md5_free(mbedtls_md5_context *ctx) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | static inline void |
| 23 | mbedtls_md5_clone(mbedtls_md5_context *dst, const mbedtls_md5_context *src) |
| 24 | { |
| 25 | *dst = *src; |
| 26 | } |
| 27 | |
| 28 | static inline int mbedtls_md5_starts(mbedtls_md5_context *ctx) |
| 29 | { |
| 30 | MD5Init(ctx); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | static 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 | |
| 42 | static inline int mbedtls_md5_finish(mbedtls_md5_context *ctx, |
| 43 | unsigned char output[16]) |
| 44 | { |
| 45 | MD5Final(output, ctx); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static 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 */ |