Mistake on this page?
Report an issue in GitHub or email us
TARGET_NUVOTON/TARGET_NUC472/sha/sha1_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_SHA1_ALT_H
17 #define MBEDTLS_SHA1_ALT_H
18 
19 #include "mbedtls/sha1.h"
20 
21 #if defined(MBEDTLS_SHA1_ALT)
22 
23 #include "sha_alt_hw.h"
24 #include "sha1_alt_sw.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct mbedtls_sha1_context_s;
31 
32 /**
33  * \brief SHA-1 context structure
34  */
35 typedef struct mbedtls_sha1_context_s {
36  void *active_ctx;
37  crypto_sha_context hw_ctx;
38  mbedtls_sha1_sw_context sw_ctx;
39 }
40 mbedtls_sha1_context;
41 
42 /**
43  * \brief Initialize SHA-1 context
44  *
45  * \param ctx SHA-1 context to be initialized
46  */
47 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
48 
49 /**
50  * \brief Clear SHA-1 context
51  *
52  * \param ctx SHA-1 context to be cleared
53  */
54 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
55 
56 /**
57  * \brief Clone (the state of) a SHA-1 context
58  *
59  * \param dst The destination context
60  * \param src The context to be cloned
61  */
62 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
63  const mbedtls_sha1_context *src );
64 
65 /**
66  * \brief SHA-1 context setup
67  *
68  * \param ctx context to be initialized
69  *
70  * \returns error code
71  */
72 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
73 
74 /**
75  * \brief SHA-1 process buffer
76  *
77  * \param ctx SHA-1 context
78  * \param input buffer holding the data
79  * \param ilen length of the input data
80  *
81  * \returns error code
82  */
83 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
84 
85 /**
86  * \brief SHA-1 final digest
87  *
88  * \param ctx SHA-1 context
89  * \param output SHA-1 checksum result
90  *
91  * \returns error code
92  */
93 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
94 
95 /* Internal use */
96 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
97 
98 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
99 #if defined(MBEDTLS_DEPRECATED_WARNING)
100 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
101 #else
102 #define MBEDTLS_DEPRECATED
103 #endif
104 /**
105  * \brief SHA-1 context setup
106  *
107  * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0
108  *
109  * \param ctx The SHA-1 context to be initialized.
110  *
111  * \warning SHA-1 is considered a weak message digest and its use
112  * constitutes a security risk. We recommend considering
113  * stronger message digests instead.
114  *
115  */
116 MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
117 
118 /**
119  * \brief SHA-1 process buffer
120  *
121  * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0
122  *
123  * \param ctx The SHA-1 context.
124  * \param input The buffer holding the input data.
125  * \param ilen The length of the input data.
126  *
127  * \warning SHA-1 is considered a weak message digest and its use
128  * constitutes a security risk. We recommend considering
129  * stronger message digests instead.
130  *
131  */
132 MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
133  const unsigned char *input,
134  size_t ilen );
135 
136 /**
137  * \brief SHA-1 final digest
138  *
139  * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0
140  *
141  * \param ctx The SHA-1 context.
142  * \param output The SHA-1 checksum result.
143  *
144  * \warning SHA-1 is considered a weak message digest and its use
145  * constitutes a security risk. We recommend considering
146  * stronger message digests instead.
147  *
148  */
149 MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
150  unsigned char output[20] );
151 
152 /**
153  * \brief SHA-1 process data block (internal use only)
154  *
155  * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0
156  *
157  * \param ctx The SHA-1 context.
158  * \param data The data block being processed.
159  *
160  * \warning SHA-1 is considered a weak message digest and its use
161  * constitutes a security risk. We recommend considering
162  * stronger message digests instead.
163  *
164  */
165 MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
166  const unsigned char data[64] );
167 
168 #undef MBEDTLS_DEPRECATED
169 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* MBEDTLS_SHA1_ALT */
176 
177 #endif /* sha1_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.