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