mbed TLS v2.16.12
sha256.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright The Mbed TLS Contributors
11  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
12  *
13  * This file is provided under the Apache License 2.0, or the
14  * GNU General Public License v2.0 or later.
15  *
16  * **********
17  * Apache License 2.0:
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may
20  * not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  *
23  * http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  *
31  * **********
32  *
33  * **********
34  * GNU General Public License v2.0 or later:
35  *
36  * This program is free software; you can redistribute it and/or modify
37  * it under the terms of the GNU General Public License as published by
38  * the Free Software Foundation; either version 2 of the License, or
39  * (at your option) any later version.
40  *
41  * This program is distributed in the hope that it will be useful,
42  * but WITHOUT ANY WARRANTY; without even the implied warranty of
43  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44  * GNU General Public License for more details.
45  *
46  * You should have received a copy of the GNU General Public License along
47  * with this program; if not, write to the Free Software Foundation, Inc.,
48  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
49  *
50  * **********
51  */
52 #ifndef MBEDTLS_SHA256_H
53 #define MBEDTLS_SHA256_H
54 
55 #if !defined(MBEDTLS_CONFIG_FILE)
56 #include "config.h"
57 #else
58 #include MBEDTLS_CONFIG_FILE
59 #endif
60 
61 #include <stddef.h>
62 #include <stdint.h>
63 
64 /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */
66 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
67 
68 #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 #if !defined(MBEDTLS_SHA256_ALT)
75 // Regular implementation
76 //
77 
85 typedef struct mbedtls_sha256_context
86 {
87  uint32_t total[2];
88  uint32_t state[8];
89  unsigned char buffer[64];
90  int is224;
92 }
94 
95 #else /* MBEDTLS_SHA256_ALT */
96 #include "sha256_alt.h"
97 #endif /* MBEDTLS_SHA256_ALT */
98 
105 
114 
122  const mbedtls_sha256_context *src );
123 
136 
151  const unsigned char *input,
152  size_t ilen );
153 
167  unsigned char output[32] );
168 
182  const unsigned char data[64] );
183 
184 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
185 #if defined(MBEDTLS_DEPRECATED_WARNING)
186 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
187 #else
188 #define MBEDTLS_DEPRECATED
189 #endif
190 
201  int is224 );
202 
216  const unsigned char *input,
217  size_t ilen );
218 
231  unsigned char output[32] );
232 
245  const unsigned char data[64] );
246 
247 #undef MBEDTLS_DEPRECATED
248 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
249 
271 int mbedtls_sha256_ret( const unsigned char *input,
272  size_t ilen,
273  unsigned char output[32],
274  int is224 );
275 
276 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
277 #if defined(MBEDTLS_DEPRECATED_WARNING)
278 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
279 #else
280 #define MBEDTLS_DEPRECATED
281 #endif
282 
303 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
304  size_t ilen,
305  unsigned char output[32],
306  int is224 );
307 
308 #undef MBEDTLS_DEPRECATED
309 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
310 
311 #if defined(MBEDTLS_SELF_TEST)
312 
319 int mbedtls_sha256_self_test( int verbose );
320 
321 #endif /* MBEDTLS_SELF_TEST */
322 
323 #ifdef __cplusplus
324 }
325 #endif
326 
327 #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:87
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:280
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:88
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
The SHA-256 context structure.
Definition: sha256.h:85
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:89
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.