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 SHA1_ALT_H |
| 7 | #define SHA1_ALT_H |
| 8 | |
| 9 | #include <image.h> |
| 10 | #include <u-boot/sha1.h> |
| 11 | |
| 12 | typedef sha1_context mbedtls_sha1_context; |
| 13 | |
| 14 | static inline void mbedtls_sha1_init(mbedtls_sha1_context *ctx) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | static inline void mbedtls_sha1_free(mbedtls_sha1_context *ctx) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | static inline void mbedtls_sha1_clone(mbedtls_sha1_context *dst, |
| 23 | const mbedtls_sha1_context *src) |
| 24 | { |
| 25 | *dst = *src; |
| 26 | } |
| 27 | |
| 28 | static inline int mbedtls_sha1_starts(mbedtls_sha1_context *ctx) |
| 29 | { |
| 30 | sha1_starts(ctx); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | static inline int mbedtls_sha1_update(mbedtls_sha1_context *ctx, |
| 35 | const unsigned char *input, |
| 36 | size_t ilen) |
| 37 | { |
| 38 | sha1_update(ctx, input, ilen); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static inline int mbedtls_sha1_finish(mbedtls_sha1_context *ctx, |
| 43 | unsigned char output[20]) |
| 44 | { |
| 45 | sha1_finish(ctx, output); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static inline int mbedtls_sha1(const unsigned char *input, |
| 50 | size_t ilen, |
| 51 | unsigned char output[20]) |
| 52 | { |
| 53 | sha1_csum_wd(input, ilen, output, CHUNKSZ_SHA1); |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | #endif /* sha1_alt.h */ |