Mbed TLS v3.6.3
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 #ifndef MBEDTLS_SHA256_H
14 #define MBEDTLS_SHA256_H
15 #include "mbedtls/private_access.h"
16 
17 #include "mbedtls/build_info.h"
18 
19 #include <stddef.h>
20 #include <stdint.h>
21 
23 #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #if !defined(MBEDTLS_SHA256_ALT)
30 // Regular implementation
31 //
32 
40 typedef struct mbedtls_sha256_context {
41  unsigned char MBEDTLS_PRIVATE(buffer)[64];
42  uint32_t MBEDTLS_PRIVATE(total)[2];
43  uint32_t MBEDTLS_PRIVATE(state)[8];
44 #if defined(MBEDTLS_SHA224_C)
45  int MBEDTLS_PRIVATE(is224);
47 #endif
48 }
50 
51 #else /* MBEDTLS_SHA256_ALT */
52 #include "sha256_alt.h"
53 #endif /* MBEDTLS_SHA256_ALT */
54 
61 
70 
78  const mbedtls_sha256_context *src);
79 
96 
111  const unsigned char *input,
112  size_t ilen);
113 
128  unsigned char *output);
129 
143  const unsigned char data[64]);
144 
167 int mbedtls_sha256(const unsigned char *input,
168  size_t ilen,
169  unsigned char *output,
170  int is224);
171 
172 #if defined(MBEDTLS_SELF_TEST)
173 
174 #if defined(MBEDTLS_SHA224_C)
175 
181 int mbedtls_sha224_self_test(int verbose);
182 #endif /* MBEDTLS_SHA224_C */
183 
184 #if defined(MBEDTLS_SHA256_C)
185 
191 int mbedtls_sha256_self_test(int verbose);
192 #endif /* MBEDTLS_SHA256_C */
193 
194 #endif /* MBEDTLS_SELF_TEST */
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* mbedtls_sha256.h */
int mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char *output)
This function finishes the SHA-256 operation, and writes the result to the output buffer...
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.
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
#define MBEDTLS_PRIVATE(member)
int 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. ...
int mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
int mbedtls_sha224_self_test(int verbose)
The SHA-224 checkup routine.
Macro wrapper for struct's members.
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
The SHA-256 context structure.
Definition: sha256.h:40
Build-time configuration info.
void mbedtls_sha256_clone(mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
This function clones the state of a SHA-256 context.
int mbedtls_sha256(const unsigned char *input, size_t ilen, unsigned char *output, int is224)
This function calculates the SHA-224 or SHA-256 checksum of a buffer.
int mbedtls_sha256_self_test(int verbose)
The SHA-256 checkup routine.