mbed TLS v2.28.1
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. */
39 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
41 #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #if !defined(MBEDTLS_SHA256_ALT)
48 // Regular implementation
49 //
50 
58 typedef struct mbedtls_sha256_context
59 {
60  uint32_t total[2];
61  uint32_t state[8];
62  unsigned char buffer[64];
63  int is224;
65 }
67 
68 #else /* MBEDTLS_SHA256_ALT */
69 #include "sha256_alt.h"
70 #endif /* MBEDTLS_SHA256_ALT */
71 
78 
87 
95  const mbedtls_sha256_context *src );
96 
109 
124  const unsigned char *input,
125  size_t ilen );
126 
140  unsigned char output[32] );
141 
155  const unsigned char data[64] );
156 
157 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
158 #if defined(MBEDTLS_DEPRECATED_WARNING)
159 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
160 #else
161 #define MBEDTLS_DEPRECATED
162 #endif
174  int is224 );
175 
189  const unsigned char *input,
190  size_t ilen );
191 
204  unsigned char output[32] );
205 
218  const unsigned char data[64] );
219 
220 #undef MBEDTLS_DEPRECATED
221 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
222 
244 int mbedtls_sha256_ret( const unsigned char *input,
245  size_t ilen,
246  unsigned char output[32],
247  int is224 );
248 
249 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
250 #if defined(MBEDTLS_DEPRECATED_WARNING)
251 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
252 #else
253 #define MBEDTLS_DEPRECATED
254 #endif
255 
276 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
277  size_t ilen,
278  unsigned char output[32],
279  int is224 );
280 
281 #undef MBEDTLS_DEPRECATED
282 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
283 
284 #if defined(MBEDTLS_SELF_TEST)
285 
292 int mbedtls_sha256_self_test( int verbose );
293 
294 #endif /* MBEDTLS_SELF_TEST */
295 
296 #ifdef __cplusplus
297 }
298 #endif
299 
300 #endif /* mbedtls_sha256.h */
Configuration options (set of defines)
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....
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.
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
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.
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.
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
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....
void mbedtls_sha256_clone(mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
This function clones the state of a SHA-256 context.
#define MBEDTLS_DEPRECATED
Definition: sha256.h:251
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_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.
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.
int mbedtls_sha256_self_test(int verbose)
The SHA-224 and SHA-256 checkup routine.
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
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.
The SHA-256 context structure.
Definition: sha256.h:59
uint32_t state[8]
Definition: sha256.h:61
uint32_t total[2]
Definition: sha256.h:60
unsigned char buffer[64]
Definition: sha256.h:62