mbed TLS v2.24.0
sha1.h
Go to the documentation of this file.
1 
13 /*
14  * Copyright The Mbed TLS Contributors
15  * SPDX-License-Identifier: Apache-2.0
16  *
17  * Licensed under the Apache License, Version 2.0 (the "License"); you may
18  * not use this file except in compliance with the License.
19  * You may obtain a copy of the License at
20  *
21  * http://www.apache.org/licenses/LICENSE-2.0
22  *
23  * Unless required by applicable law or agreed to in writing, software
24  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26  * See the License for the specific language governing permissions and
27  * limitations under the License.
28  */
29 #ifndef MBEDTLS_SHA1_H
30 #define MBEDTLS_SHA1_H
31 
32 #if !defined(MBEDTLS_CONFIG_FILE)
33 #include "mbedtls/config.h"
34 #else
35 #include MBEDTLS_CONFIG_FILE
36 #endif
37 
38 #include <stddef.h>
39 #include <stdint.h>
40 
41 /* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */
42 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
43 #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(MBEDTLS_SHA1_ALT)
50 // Regular implementation
51 //
52 
61 typedef struct mbedtls_sha1_context
62 {
63  uint32_t total[2];
64  uint32_t state[5];
65  unsigned char buffer[64];
66 }
67 mbedtls_sha1_context;
68 
69 #else /* MBEDTLS_SHA1_ALT */
70 #include "sha1_alt.h"
71 #endif /* MBEDTLS_SHA1_ALT */
72 
84 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
85 
99 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
100 
112 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
113  const mbedtls_sha1_context *src );
114 
128 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
129 
147 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
148  const unsigned char *input,
149  size_t ilen );
150 
167 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
168  unsigned char output[20] );
169 
185 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
186  const unsigned char data[64] );
187 
188 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
189 #if defined(MBEDTLS_DEPRECATED_WARNING)
190 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
191 #else
192 #define MBEDTLS_DEPRECATED
193 #endif
194 
206 MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
207 
225 MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
226  const unsigned char *input,
227  size_t ilen );
228 
244 MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
245  unsigned char output[20] );
246 
261 MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
262  const unsigned char data[64] );
263 
264 #undef MBEDTLS_DEPRECATED
265 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
266 
290 int mbedtls_sha1_ret( const unsigned char *input,
291  size_t ilen,
292  unsigned char output[20] );
293 
294 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
295 #if defined(MBEDTLS_DEPRECATED_WARNING)
296 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
297 #else
298 #define MBEDTLS_DEPRECATED
299 #endif
300 
322 MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
323  size_t ilen,
324  unsigned char output[20] );
325 
326 #undef MBEDTLS_DEPRECATED
327 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
328 
329 #if defined(MBEDTLS_SELF_TEST)
330 
342 int mbedtls_sha1_self_test( int verbose );
343 
344 #endif /* MBEDTLS_SELF_TEST */
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* mbedtls_sha1.h */
void mbedtls_sha1_clone(mbedtls_sha1_context *dst, const mbedtls_sha1_context *src)
This function clones the state of a SHA-1 context.
int mbedtls_sha1_self_test(int verbose)
The SHA-1 checkup routine.
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
This function finishes the SHA-1 operation, and writes the result to the output buffer.
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
This function initializes a SHA-1 context.
Configuration options (set of defines)
#define MBEDTLS_DEPRECATED
Definition: pkcs11.h:60
int mbedtls_internal_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-1 checksum calculation.
int mbedtls_sha1_ret(const unsigned char *input, size_t ilen, unsigned char output[20])
This function calculates the SHA-1 checksum of a buffer.
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.