mbed TLS v3.1.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 #include "mbedtls/private_access.h"
32 
33 #include "mbedtls/build_info.h"
34 
35 #include <stddef.h>
36 #include <stdint.h>
37 
39 #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #if !defined(MBEDTLS_SHA1_ALT)
46 // Regular implementation
47 //
48 
57 typedef struct mbedtls_sha1_context
58 {
59  uint32_t MBEDTLS_PRIVATE(total)[2];
60  uint32_t MBEDTLS_PRIVATE(state)[5];
61  unsigned char MBEDTLS_PRIVATE(buffer)[64];
62 }
63 mbedtls_sha1_context;
64 
65 #else /* MBEDTLS_SHA1_ALT */
66 #include "sha1_alt.h"
67 #endif /* MBEDTLS_SHA1_ALT */
68 
80 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
81 
95 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
96 
108 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
109  const mbedtls_sha1_context *src );
110 
124 int mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
125 
143 int mbedtls_sha1_update( mbedtls_sha1_context *ctx,
144  const unsigned char *input,
145  size_t ilen );
146 
163 int mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
164  unsigned char output[20] );
165 
181 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
182  const unsigned char data[64] );
183 
207 int mbedtls_sha1( const unsigned char *input,
208  size_t ilen,
209  unsigned char output[20] );
210 
211 #if defined(MBEDTLS_SELF_TEST)
212 
224 int mbedtls_sha1_self_test( int verbose );
225 
226 #endif /* MBEDTLS_SELF_TEST */
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 
232 #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(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.
int mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
#define MBEDTLS_PRIVATE(member)
int mbedtls_internal_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
Macro wrapper for struct's memebrs.
int mbedtls_sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
This function calculates the SHA-1 checksum of a buffer.
Build-time configuration info.
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
int mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-1 checksum calculation.