]> Git Repo - u-boot.git/blob - lib/mbedtls/port/sha256_alt.h
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh
[u-boot.git] / lib / mbedtls / port / sha256_alt.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2024 Linaro Limited
4  * Author: Raymond Mao <[email protected]>
5  */
6 #ifndef SHA256_ALT_H
7 #define SHA256_ALT_H
8
9 #include <image.h>
10 #include <u-boot/sha256.h>
11
12 typedef sha256_context mbedtls_sha256_context;
13
14 static inline void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
15 {
16 }
17
18 static inline void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
19 {
20 }
21
22 static inline void mbedtls_sha256_clone(mbedtls_sha256_context *dst,
23                                         const mbedtls_sha256_context *src)
24 {
25         *dst = *src;
26 }
27
28 static inline int mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
29 {
30         if (is224)
31                 return -EOPNOTSUPP;
32
33         sha256_starts(ctx);
34         return 0;
35 }
36
37 static inline int mbedtls_sha256_update(mbedtls_sha256_context *ctx,
38                                         const unsigned char *input,
39                                         size_t ilen)
40 {
41         sha256_update(ctx, input, ilen);
42         return 0;
43 }
44
45 static inline int mbedtls_sha256_finish(mbedtls_sha256_context *ctx,
46                                         unsigned char *output)
47 {
48         sha256_finish(ctx, output);
49         return 0;
50 }
51
52 static inline int mbedtls_sha256(const unsigned char *input,
53                                  size_t ilen,
54                                  unsigned char *output,
55                                  int is224)
56 {
57         if (is224)
58                 return -EOPNOTSUPP;
59
60         sha256_csum_wd(input, ilen, output, CHUNKSZ_SHA256);
61         return 0;
62 }
63
64 #endif /* sha256_alt.h */
This page took 0.030491 seconds and 4 git commands to generate.