mbed TLS v2.26.0
sha256.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright The Mbed TLS Contributors
11  * SPDX-License-Identifier: Apache-2.0
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License"); you may
14  * not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  */
25 #ifndef MBEDTLS_SHA256_H
26 #define MBEDTLS_SHA256_H
27 
28 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include "mbedtls/config.h"
30 #else
31 #include MBEDTLS_CONFIG_FILE
32 #endif
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 
37 /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */
38 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
39 #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #if !defined(MBEDTLS_SHA256_ALT)
46 // Regular implementation
47 //
48 
56 typedef struct mbedtls_sha256_context
57 {
58  uint32_t total[2];
59  uint32_t state[8];
60  unsigned char buffer[64];
61  int is224;
63 }
65 
66 #else /* MBEDTLS_SHA256_ALT */
67 #include "sha256_alt.h"
68 #endif /* MBEDTLS_SHA256_ALT */
69 
76 
85 
93  const mbedtls_sha256_context *src );
94 
107 
122  const unsigned char *input,
123  size_t ilen );
124 
138  unsigned char output[32] );
139 
153  const unsigned char data[64] );
154 
155 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
156 #if defined(MBEDTLS_DEPRECATED_WARNING)
157 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
158 #else
159 #define MBEDTLS_DEPRECATED
160 #endif
161 
172  int is224 );
173 
187  const unsigned char *input,
188  size_t ilen );
189 
202  unsigned char output[32] );
203 
216  const unsigned char data[64] );
217 
218 #undef MBEDTLS_DEPRECATED
219 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
220 
239 int mbedtls_sha256_ret( const unsigned char *input,
240  size_t ilen,
241  unsigned char output[32],
242  int is224 );
243 
244 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
245 #if defined(MBEDTLS_DEPRECATED_WARNING)
246 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
247 #else
248 #define MBEDTLS_DEPRECATED
249 #endif
250 
271 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
272  size_t ilen,
273  unsigned char output[32],
274  int is224 );
275 
276 #undef MBEDTLS_DEPRECATED
277 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
278 
279 #if defined(MBEDTLS_SELF_TEST)
280 
287 int mbedtls_sha256_self_test( int verbose );
288 
289 #endif /* MBEDTLS_SELF_TEST */
290 
291 #ifdef __cplusplus
292 }
293 #endif
294 
295 #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:58
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:248
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:59
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
The SHA-256 context structure.
Definition: sha256.h:56
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:60
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.