mbed TLS v2.16.3: sha1.h Source File

mbed TLS v2.16.3

sha1.h
Go to the documentation of this file.
1
13 /*
14 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
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 * This file is part of Mbed TLS (https://tls.mbed.org)
30 */
31 #ifndef MBEDTLS_SHA1_H
32 #define MBEDTLS_SHA1_H
33
34 #if !defined(MBEDTLS_CONFIG_FILE)
35 #include "config.h"
36 #else
37 #include MBEDTLS_CONFIG_FILE
38 #endif
39
40 #include <stddef.h>
41 #include <stdint.h>
42
43 /* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */
44 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
45 #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 #if !defined(MBEDTLS_SHA1_ALT)
52 // Regular implementation
53 //
54
63 typedef struct mbedtls_sha1_context
64 {
65 uint32_t total[2];
66 uint32_t state[5];
67 unsigned char buffer[64];
68 }
69 mbedtls_sha1_context;
70
71 #else /* MBEDTLS_SHA1_ALT */
72 #include "sha1_alt.h"
73 #endif /* MBEDTLS_SHA1_ALT */
74
86 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
87
101 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
102
114 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
115 const mbedtls_sha1_context *src );
116
130 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
131
149 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
150 const unsigned char *input,
151 size_t ilen );
152
169 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
170 unsigned char output[20] );
171
187 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
188 const unsigned char data[64] );
189
190 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
191 #if defined(MBEDTLS_DEPRECATED_WARNING)
192 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
193 #else
194 #define MBEDTLS_DEPRECATED
195 #endif
196
208 MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
209
227 MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
228 const unsigned char *input,
229 size_t ilen );
230
246 MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
247 unsigned char output[20] );
248
263 MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
264 const unsigned char data[64] );
265
266 #undef MBEDTLS_DEPRECATED
267 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
268
292 int mbedtls_sha1_ret( const unsigned char *input,
293 size_t ilen,
294 unsigned char output[20] );
295
296 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
297 #if defined(MBEDTLS_DEPRECATED_WARNING)
298 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
299 #else
300 #define MBEDTLS_DEPRECATED
301 #endif
302
324 MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
325 size_t ilen,
326 unsigned char output[20] );
327
328 #undef MBEDTLS_DEPRECATED
329 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
330
331 #if defined(MBEDTLS_SELF_TEST)
332
344 int mbedtls_sha1_self_test( int verbose );
345
346 #endif /* MBEDTLS_SELF_TEST */
347
348 #ifdef __cplusplus
349 }
350 #endif
351
352 #endif /* mbedtls_sha1.h */
mbedtls_sha1_context
The SHA-1 context structure.
Definition: sha1.h:63
mbedtls_sha1_starts
MBEDTLS_DEPRECATED void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
mbedtls_sha1_free
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
mbedtls_sha1_context::buffer
unsigned char buffer[64]
Definition: sha1.h:67
mbedtls_sha1_update_ret
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.
mbedtls_sha1_process
MBEDTLS_DEPRECATED void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
mbedtls_sha1_context
struct mbedtls_sha1_context mbedtls_sha1_context
The SHA-1 context structure.
mbedtls_sha1_ret
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.
mbedtls_sha1_finish_ret
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.
mbedtls_sha1_self_test
int mbedtls_sha1_self_test(int verbose)
The SHA-1 checkup routine.
mbedtls_sha1_context::total
uint32_t total[2]
Definition: sha1.h:65
mbedtls_sha1_context::state
uint32_t state[5]
Definition: sha1.h:66
mbedtls_sha1
MBEDTLS_DEPRECATED void mbedtls_sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
This function calculates the SHA-1 checksum of a buffer.
mbedtls_sha1_init
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
This function initializes a SHA-1 context.
mbedtls_sha1_starts_ret
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
mbedtls_internal_sha1_process
int mbedtls_internal_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
mbedtls_sha1_clone
void mbedtls_sha1_clone(mbedtls_sha1_context *dst, const mbedtls_sha1_context *src)
This function clones the state of a SHA-1 context.
mbedtls_sha1_update
MBEDTLS_DEPRECATED void 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.
config.h
Configuration options (set of defines)
mbedtls_sha1_finish
MBEDTLS_DEPRECATED void 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.
MBEDTLS_DEPRECATED
#define MBEDTLS_DEPRECATED
Definition: sha1.h:300