Mistake on this page?
Report an issue in GitHub or email us
TARGET_Silicon_Labs/sha1_alt.h
1 /**
2  * \file sha1_alt.h
3  *
4  * \brief SHA-1 cryptographic hash function
5  *
6  * Copyright (C) 2015-2016, Silicon Labs, http://www.silabs.com
7  * SPDX-License-Identifier: Apache-2.0
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License"); you may
10  * not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 #ifndef MBEDTLS_SHA1_ALT_H
22 #define MBEDTLS_SHA1_ALT_H
23 
24 /***************************************************************************//**
25  * \addtogroup sl_crypto
26  * \{
27  ******************************************************************************/
28 
29 /***************************************************************************//**
30  * \addtogroup sl_crypto_sha1 SHA-1 cryptographic hash function
31  * \brief CRYPTO hardware accelerated SHA-1 cryptographic hash function.
32  * \{
33  ******************************************************************************/
34 
35 #if defined(MBEDTLS_SHA1_ALT)
36 
37 #include <stdint.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /**
44  * \brief SHA-1 context structure
45  */
46 typedef struct
47 {
48  uint32_t state[8]; /*!< intermediate digest state */
49  uint32_t total[2]; /*!< number of bytes processed */
50  unsigned char buffer[64]; /*!< data block being processed */
51 }
52 mbedtls_sha1_context;
53 
54 /**
55  * \brief Initialize SHA-1 context
56  *
57  * \param ctx SHA-1 context to be initialized
58  */
59 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
60 
61 /**
62  * \brief Clear SHA-1 context
63  *
64  * \param ctx SHA-1 context to be cleared
65  */
66 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
67 
68 /**
69  * \brief Clone (the state of) a SHA-1 context
70  *
71  * \param dst The destination context
72  * \param src The context to be cloned
73  */
74 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
75  const mbedtls_sha1_context *src );
76 
77 /**
78  * \brief SHA-1 context setup
79  *
80  * \param ctx context to be initialized
81  *
82  * \returns error code
83  */
84 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
85 
86 /**
87  * \brief SHA-1 process buffer
88  *
89  * \param ctx SHA-1 context
90  * \param input buffer holding the data
91  * \param ilen length of the input data
92  *
93  * \returns error code
94  */
95 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
96 
97 /**
98  * \brief SHA-1 final digest
99  *
100  * \param ctx SHA-1 context
101  * \param output SHA-1 checksum result
102  *
103  * \returns error code
104  */
105 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
106 
107 /* Internal use */
108 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
109 
110 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
111 #if defined(MBEDTLS_DEPRECATED_WARNING)
112 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
113 #else
114 #define MBEDTLS_DEPRECATED
115 #endif
116 /**
117  * \brief SHA-1 context setup
118  *
119  * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0
120  *
121  * \param ctx The SHA-1 context to be initialized.
122  *
123  * \warning SHA-1 is considered a weak message digest and its use
124  * constitutes a security risk. We recommend considering
125  * stronger message digests instead.
126  *
127  */
128 MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
129 
130 /**
131  * \brief SHA-1 process buffer
132  *
133  * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0
134  *
135  * \param ctx The SHA-1 context.
136  * \param input The buffer holding the input data.
137  * \param ilen The length of the input data.
138  *
139  * \warning SHA-1 is considered a weak message digest and its use
140  * constitutes a security risk. We recommend considering
141  * stronger message digests instead.
142  *
143  */
144 MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
145  const unsigned char *input,
146  size_t ilen );
147 
148 /**
149  * \brief SHA-1 final digest
150  *
151  * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0
152  *
153  * \param ctx The SHA-1 context.
154  * \param output The SHA-1 checksum result.
155  *
156  * \warning SHA-1 is considered a weak message digest and its use
157  * constitutes a security risk. We recommend considering
158  * stronger message digests instead.
159  *
160  */
161 MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
162  unsigned char output[20] );
163 
164 /**
165  * \brief SHA-1 process data block (internal use only)
166  *
167  * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0
168  *
169  * \param ctx The SHA-1 context.
170  * \param data The data block being processed.
171  *
172  * \warning SHA-1 is considered a weak message digest and its use
173  * constitutes a security risk. We recommend considering
174  * stronger message digests instead.
175  *
176  */
177 MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
178  const unsigned char data[64] );
179 
180 #undef MBEDTLS_DEPRECATED
181 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* #if defined(MBEDTLS_SHA1_ALT) */
188 
189 /** \} (end addtogroup sl_crypto_sha1) */
190 /** \} (end addtogroup sl_crypto) */
191 
192 #endif /* #ifndef MBEDTLS_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.