mbed TLS v2.7.0
sha1.h
Go to the documentation of this file.
1 
10 /*
11  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
12  * SPDX-License-Identifier: Apache-2.0
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License"); you may
15  * not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * This file is part of Mbed TLS (https://tls.mbed.org)
27  */
28 #ifndef MBEDTLS_SHA1_H
29 #define MBEDTLS_SHA1_H
30 
31 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include "config.h"
33 #else
34 #include MBEDTLS_CONFIG_FILE
35 #endif
36 
37 #include <stddef.h>
38 #include <stdint.h>
39 
40 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
42 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
43  !defined(inline) && !defined(__cplusplus)
44 #define inline __inline
45 #endif
46 
47 #if !defined(MBEDTLS_SHA1_ALT)
48 // Regular implementation
49 //
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
63 typedef struct
64 {
65  uint32_t total[2];
66  uint32_t state[5];
67  unsigned char buffer[64];
68 }
70 
82 
94 
107  const mbedtls_sha1_context *src );
108 
122 
139  const unsigned char *input,
140  size_t ilen );
141 
157  unsigned char output[20] );
158 
173  const unsigned char data[64] );
174 
175 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
176 #if defined(MBEDTLS_DEPRECATED_WARNING)
177 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
178 #else
179 #define MBEDTLS_DEPRECATED
180 #endif
181 
194  mbedtls_sha1_context *ctx )
195 {
197 }
198 
215  const unsigned char *input,
216  size_t ilen )
217 {
218  mbedtls_sha1_update_ret( ctx, input, ilen );
219 }
220 
236  unsigned char output[20] )
237 {
238  mbedtls_sha1_finish_ret( ctx, output );
239 }
240 
256  const unsigned char data[64] )
257 {
258  mbedtls_internal_sha1_process( ctx, data );
259 }
260 
261 #undef MBEDTLS_DEPRECATED
262 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
263 
264 #ifdef __cplusplus
265 }
266 #endif
267 
268 #else /* MBEDTLS_SHA1_ALT */
269 #include "sha1_alt.h"
270 #endif /* MBEDTLS_SHA1_ALT */
271 
272 #ifdef __cplusplus
273 extern "C" {
274 #endif
275 
296 int mbedtls_sha1_ret( const unsigned char *input,
297  size_t ilen,
298  unsigned char output[20] );
299 
300 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
301 #if defined(MBEDTLS_DEPRECATED_WARNING)
302 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
303 #else
304 #define MBEDTLS_DEPRECATED
305 #endif
306 
320 MBEDTLS_DEPRECATED static inline void mbedtls_sha1( const unsigned char *input,
321  size_t ilen,
322  unsigned char output[20] )
323 {
324  mbedtls_sha1_ret( input, ilen, output );
325 }
326 
327 #undef MBEDTLS_DEPRECATED
328 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
329 
340 int mbedtls_sha1_self_test( int verbose );
341 
342 #ifdef __cplusplus
343 }
344 #endif
345 
346 #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.
static MBEDTLS_DEPRECATED void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only)
Definition: sha1.h:254
int mbedtls_sha1_self_test(int verbose)
The SHA-1 checkup routine.
static MBEDTLS_DEPRECATED void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
SHA-1 context setup.
Definition: sha1.h:193
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.
static MBEDTLS_DEPRECATED void mbedtls_sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = SHA-1( input buffer )
Definition: sha1.h:320
#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)
static MBEDTLS_DEPRECATED void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 process buffer.
Definition: sha1.h:213
static MBEDTLS_DEPRECATED void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
SHA-1 final digest.
Definition: sha1.h:234
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.
The SHA-1 context structure.
Definition: sha1.h:63
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.