mbed TLS v2.16.6
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: GPL-2.0
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 2 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with this program; if not, write to the Free Software Foundation, Inc.,
29  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30  *
31  * This file is part of Mbed TLS (https://tls.mbed.org)
32  */
33 #ifndef MBEDTLS_SHA1_H
34 #define MBEDTLS_SHA1_H
35 
36 #if !defined(MBEDTLS_CONFIG_FILE)
37 #include "config.h"
38 #else
39 #include MBEDTLS_CONFIG_FILE
40 #endif
41 
42 #include <stddef.h>
43 #include <stdint.h>
44 
45 /* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */
46 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
47 #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #if !defined(MBEDTLS_SHA1_ALT)
54 // Regular implementation
55 //
56 
65 typedef struct mbedtls_sha1_context
66 {
67  uint32_t total[2];
68  uint32_t state[5];
69  unsigned char buffer[64];
70 }
72 
73 #else /* MBEDTLS_SHA1_ALT */
74 #include "sha1_alt.h"
75 #endif /* MBEDTLS_SHA1_ALT */
76 
89 
104 
117  const mbedtls_sha1_context *src );
118 
133 
152  const unsigned char *input,
153  size_t ilen );
154 
172  unsigned char output[20] );
173 
190  const unsigned char data[64] );
191 
192 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
193 #if defined(MBEDTLS_DEPRECATED_WARNING)
194 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
195 #else
196 #define MBEDTLS_DEPRECATED
197 #endif
198 
211 
230  const unsigned char *input,
231  size_t ilen );
232 
249  unsigned char output[20] );
250 
266  const unsigned char data[64] );
267 
268 #undef MBEDTLS_DEPRECATED
269 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
270 
294 int mbedtls_sha1_ret( const unsigned char *input,
295  size_t ilen,
296  unsigned char output[20] );
297 
298 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
299 #if defined(MBEDTLS_DEPRECATED_WARNING)
300 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
301 #else
302 #define MBEDTLS_DEPRECATED
303 #endif
304 
326 MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
327  size_t ilen,
328  unsigned char output[20] );
329 
330 #undef MBEDTLS_DEPRECATED
331 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
332 
333 #if defined(MBEDTLS_SELF_TEST)
334 
346 int mbedtls_sha1_self_test( int verbose );
347 
348 #endif /* MBEDTLS_SELF_TEST */
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #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:69
#define MBEDTLS_DEPRECATED
Definition: sha1.h:302
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:67
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:68
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:65
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.