Mistake on this page?
Report an issue in GitHub or email us
TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.h
1 /*
2  * Copyright (c) 2015-2016, Nuvoton Technology Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef MBEDTLS_SHA256_ALT_H
20 #define MBEDTLS_SHA256_ALT_H
21 
22 #include "mbedtls/sha256.h"
23 
24 #if defined(MBEDTLS_SHA256_ALT)
25 
26 #include "sha_alt_hw.h"
27 #include "sha256_alt_sw.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct mbedtls_sha256_context_s;
34 
35 /**
36  * \brief SHA-256 context structure
37  */
38 typedef struct mbedtls_sha256_context_s {
39  void *active_ctx;
40  crypto_sha_context hw_ctx;
41  mbedtls_sha256_sw_context sw_ctx;
42 }
43 mbedtls_sha256_context;
44 
45 /**
46  * \brief Initialize SHA-256 context
47  *
48  * \param ctx SHA-256 context to be initialized
49  */
50 void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
51 
52 /**
53  * \brief Clear SHA-256 context
54  *
55  * \param ctx SHA-256 context to be cleared
56  */
57 void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
58 
59 /**
60  * \brief Clone (the state of) a SHA-256 context
61  *
62  * \param dst The destination context
63  * \param src The context to be cloned
64  */
65 void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
66  const mbedtls_sha256_context *src );
67 
68 /**
69  * \brief SHA-256 context setup
70  *
71  * \param ctx context to be initialized
72  * \param is224 0 = use SHA256, 1 = use SHA224
73  *
74  * \returns error code
75  */
76 int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
77 
78 /**
79  * \brief SHA-256 process buffer
80  *
81  * \param ctx SHA-256 context
82  * \param input buffer holding the data
83  * \param ilen length of the input data
84  *
85  * \returns error code
86  */
87 int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char *input,
88  size_t ilen );
89 
90 /**
91  * \brief SHA-256 final digest
92  *
93  * \param ctx SHA-256 context
94  * \param output SHA-224/256 checksum result
95  *
96  * \returns error code
97  */
98 int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32] );
99 
100 /* Internal use */
101 int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );
102 
103 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
104 #if defined(MBEDTLS_DEPRECATED_WARNING)
105 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
106 #else
107 #define MBEDTLS_DEPRECATED
108 #endif
109 /**
110  * \brief This function starts a SHA-256 checksum calculation.
111  *
112  * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0.
113  *
114  * \param ctx The SHA-256 context to initialize.
115  * \param is224 Determines which function to use.
116  * <ul><li>0: Use SHA-256.</li>
117  * <li>1: Use SHA-224.</li></ul>
118  */
119 MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
120  int is224 );
121 
122 /**
123  * \brief This function feeds an input buffer into an ongoing
124  * SHA-256 checksum calculation.
125  *
126  * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0.
127  *
128  * \param ctx The SHA-256 context to initialize.
129  * \param input The buffer holding the data.
130  * \param ilen The length of the input data.
131  */
132 MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
133  const unsigned char *input,
134  size_t ilen );
135 
136 /**
137  * \brief This function finishes the SHA-256 operation, and writes
138  * the result to the output buffer.
139  *
140  * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0.
141  *
142  * \param ctx The SHA-256 context.
143  * \param output The SHA-224or SHA-256 checksum result.
144  */
145 MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
146  unsigned char output[32] );
147 
148 /**
149  * \brief This function processes a single data block within
150  * the ongoing SHA-256 computation. This function is for
151  * internal use only.
152  *
153  * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0.
154  *
155  * \param ctx The SHA-256 context.
156  * \param data The buffer holding one block of data.
157  */
158 MBEDTLS_DEPRECATED void mbedtls_sha256_process( mbedtls_sha256_context *ctx,
159  const unsigned char data[64] );
160 
161 #undef MBEDTLS_DEPRECATED
162 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* MBEDTLS_SHA256_ALT */
169 
170 #endif /* sha256_alt.h */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.