Mbed TLS v3.5.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
28
29#include "mbedtls/build_info.h"
30
31#include <stddef.h>
32#include <stdint.h>
33
35#define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#if !defined(MBEDTLS_SHA256_ALT)
42// Regular implementation
43//
44
52typedef struct mbedtls_sha256_context {
53 unsigned char MBEDTLS_PRIVATE(buffer)[64];
54 uint32_t MBEDTLS_PRIVATE(total)[2];
55 uint32_t MBEDTLS_PRIVATE(state)[8];
56 int MBEDTLS_PRIVATE(is224);
58}
60
61#else /* MBEDTLS_SHA256_ALT */
62#include "sha256_alt.h"
63#endif /* MBEDTLS_SHA256_ALT */
64
71
80
88 const mbedtls_sha256_context *src);
89
106
121 const unsigned char *input,
122 size_t ilen);
123
138 unsigned char *output);
139
153 const unsigned char data[64]);
154
177int mbedtls_sha256(const unsigned char *input,
178 size_t ilen,
179 unsigned char *output,
180 int is224);
181
182#if defined(MBEDTLS_SELF_TEST)
183
184#if defined(MBEDTLS_SHA224_C)
192#endif /* MBEDTLS_SHA224_C */
193
194#if defined(MBEDTLS_SHA256_C)
202#endif /* MBEDTLS_SHA256_C */
203
204#endif /* MBEDTLS_SELF_TEST */
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif /* mbedtls_sha256.h */
Build-time configuration info.
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
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.
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.
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.
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_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_self_test(int verbose)
The SHA-256 checkup routine.
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.
The SHA-256 context structure.
Definition: sha256.h:52