mbed TLS v2.16.6
sha256.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
11  * SPDX-License-Identifier: GPL-2.0
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26  *
27  * This file is part of Mbed TLS (https://tls.mbed.org)
28  */
29 #ifndef MBEDTLS_SHA256_H
30 #define MBEDTLS_SHA256_H
31 
32 #if !defined(MBEDTLS_CONFIG_FILE)
33 #include "config.h"
34 #else
35 #include MBEDTLS_CONFIG_FILE
36 #endif
37 
38 #include <stddef.h>
39 #include <stdint.h>
40 
41 /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */
42 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
43 #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(MBEDTLS_SHA256_ALT)
50 // Regular implementation
51 //
52 
60 typedef struct mbedtls_sha256_context
61 {
62  uint32_t total[2];
63  uint32_t state[8];
64  unsigned char buffer[64];
65  int is224;
67 }
69 
70 #else /* MBEDTLS_SHA256_ALT */
71 #include "sha256_alt.h"
72 #endif /* MBEDTLS_SHA256_ALT */
73 
80 
89 
97  const mbedtls_sha256_context *src );
98 
111 
126  const unsigned char *input,
127  size_t ilen );
128 
142  unsigned char output[32] );
143 
157  const unsigned char data[64] );
158 
159 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
160 #if defined(MBEDTLS_DEPRECATED_WARNING)
161 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
162 #else
163 #define MBEDTLS_DEPRECATED
164 #endif
165 
176  int is224 );
177 
191  const unsigned char *input,
192  size_t ilen );
193 
206  unsigned char output[32] );
207 
220  const unsigned char data[64] );
221 
222 #undef MBEDTLS_DEPRECATED
223 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
224 
243 int mbedtls_sha256_ret( const unsigned char *input,
244  size_t ilen,
245  unsigned char output[32],
246  int is224 );
247 
248 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
249 #if defined(MBEDTLS_DEPRECATED_WARNING)
250 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
251 #else
252 #define MBEDTLS_DEPRECATED
253 #endif
254 
275 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
276  size_t ilen,
277  unsigned char output[32],
278  int is224 );
279 
280 #undef MBEDTLS_DEPRECATED
281 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
282 
283 #if defined(MBEDTLS_SELF_TEST)
284 
291 int mbedtls_sha256_self_test( int verbose );
292 
293 #endif /* MBEDTLS_SELF_TEST */
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif /* mbedtls_sha256.h */
int mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])
This function processes a single data block within the ongoing SHA-256 computation. This function is for internal use only.
MBEDTLS_DEPRECATED void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
This function finishes the SHA-256 operation, and writes the result to the output buffer...
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
uint32_t total[2]
Definition: sha256.h:62
int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation. ...
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
Configuration options (set of defines)
int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[32])
This function finishes the SHA-256 operation, and writes the result to the output buffer...
#define MBEDTLS_DEPRECATED
Definition: sha256.h:252
MBEDTLS_DEPRECATED void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation. ...
uint32_t state[8]
Definition: sha256.h:63
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
The SHA-256 context structure.
Definition: sha256.h:60
MBEDTLS_DEPRECATED void mbedtls_sha256(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
This function calculates the SHA-224 or SHA-256 checksum of a buffer.
int mbedtls_sha256_ret(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
This function calculates the SHA-224 or SHA-256 checksum of a buffer.
unsigned char buffer[64]
Definition: sha256.h:64
MBEDTLS_DEPRECATED void mbedtls_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])
This function processes a single data block within the ongoing SHA-256 computation. This function is for internal use only.
void mbedtls_sha256_clone(mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
This function clones the state of a SHA-256 context.
MBEDTLS_DEPRECATED void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
int mbedtls_sha256_self_test(int verbose)
The SHA-224 and SHA-256 checkup routine.