blob: cbfe0ddc4788a2f1e3b63ec47926f9eb80384266 [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 SHA1_ALT_H
7#define SHA1_ALT_H
8
9#include <image.h>
10#include <u-boot/sha1.h>
11
12typedef sha1_context mbedtls_sha1_context;
13
14static inline void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
15{
16}
17
18static inline void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
19{
20}
21
22static inline void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
23 const mbedtls_sha1_context *src)
24{
25 *dst = *src;
26}
27
28static inline int mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
29{
30 sha1_starts(ctx);
31 return 0;
32}
33
34static 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
42static 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
49static 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 */