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