mbed TLS v2.16.7
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 OR GPL-2.0-or-later
16  *
17  * This file is provided under the Apache License 2.0, or the
18  * GNU General Public License v2.0 or later.
19  *
20  * **********
21  * Apache License 2.0:
22  *
23  * Licensed under the Apache License, Version 2.0 (the "License"); you may
24  * not use this file except in compliance with the License.
25  * You may obtain a copy of the License at
26  *
27  * http://www.apache.org/licenses/LICENSE-2.0
28  *
29  * Unless required by applicable law or agreed to in writing, software
30  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
31  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32  * See the License for the specific language governing permissions and
33  * limitations under the License.
34  *
35  * **********
36  *
37  * **********
38  * GNU General Public License v2.0 or later:
39  *
40  * This program is free software; you can redistribute it and/or modify
41  * it under the terms of the GNU General Public License as published by
42  * the Free Software Foundation; either version 2 of the License, or
43  * (at your option) any later version.
44  *
45  * This program is distributed in the hope that it will be useful,
46  * but WITHOUT ANY WARRANTY; without even the implied warranty of
47  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48  * GNU General Public License for more details.
49  *
50  * You should have received a copy of the GNU General Public License along
51  * with this program; if not, write to the Free Software Foundation, Inc.,
52  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
53  *
54  * **********
55  *
56  * This file is part of Mbed TLS (https://tls.mbed.org)
57  */
58 #ifndef MBEDTLS_SHA1_H
59 #define MBEDTLS_SHA1_H
60 
61 #if !defined(MBEDTLS_CONFIG_FILE)
62 #include "config.h"
63 #else
64 #include MBEDTLS_CONFIG_FILE
65 #endif
66 
67 #include <stddef.h>
68 #include <stdint.h>
69 
70 /* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */
71 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
72 #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 #if !defined(MBEDTLS_SHA1_ALT)
79 // Regular implementation
80 //
81 
90 typedef struct mbedtls_sha1_context
91 {
92  uint32_t total[2];
93  uint32_t state[5];
94  unsigned char buffer[64];
95 }
97 
98 #else /* MBEDTLS_SHA1_ALT */
99 #include "sha1_alt.h"
100 #endif /* MBEDTLS_SHA1_ALT */
101 
114 
129 
142  const mbedtls_sha1_context *src );
143 
158 
177  const unsigned char *input,
178  size_t ilen );
179 
197  unsigned char output[20] );
198 
215  const unsigned char data[64] );
216 
217 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
218 #if defined(MBEDTLS_DEPRECATED_WARNING)
219 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
220 #else
221 #define MBEDTLS_DEPRECATED
222 #endif
223 
236 
255  const unsigned char *input,
256  size_t ilen );
257 
274  unsigned char output[20] );
275 
291  const unsigned char data[64] );
292 
293 #undef MBEDTLS_DEPRECATED
294 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
295 
319 int mbedtls_sha1_ret( const unsigned char *input,
320  size_t ilen,
321  unsigned char output[20] );
322 
323 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
324 #if defined(MBEDTLS_DEPRECATED_WARNING)
325 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
326 #else
327 #define MBEDTLS_DEPRECATED
328 #endif
329 
351 MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
352  size_t ilen,
353  unsigned char output[20] );
354 
355 #undef MBEDTLS_DEPRECATED
356 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
357 
358 #if defined(MBEDTLS_SELF_TEST)
359 
371 int mbedtls_sha1_self_test( int verbose );
372 
373 #endif /* MBEDTLS_SELF_TEST */
374 
375 #ifdef __cplusplus
376 }
377 #endif
378 
379 #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.
MBEDTLS_DEPRECATED void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
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.
unsigned char buffer[64]
Definition: sha1.h:94
#define MBEDTLS_DEPRECATED
Definition: sha1.h:327
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
This function initializes a SHA-1 context.
Configuration options (set of defines)
uint32_t total[2]
Definition: sha1.h:92
MBEDTLS_DEPRECATED void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
int mbedtls_internal_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
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.
uint32_t state[5]
Definition: sha1.h:93
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.
struct mbedtls_sha1_context mbedtls_sha1_context
The SHA-1 context structure.
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
The SHA-1 context structure.
Definition: sha1.h:90
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.
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.