Mbed TLS v2.28.5
Loading...
Searching...
No Matches
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
44extern "C" {
45#endif
46
47#if !defined(MBEDTLS_SHA256_ALT)
48// Regular implementation
49//
50
58typedef struct mbedtls_sha256_context {
59 uint32_t total[2];
60 uint32_t state[8];
61 unsigned char buffer[64];
62 int is224;
64}
66
67#else /* MBEDTLS_SHA256_ALT */
68#include "sha256_alt.h"
69#endif /* MBEDTLS_SHA256_ALT */
70
77
86
94 const mbedtls_sha256_context *src);
95
108
123 const unsigned char *input,
124 size_t ilen);
125
139 unsigned char output[32]);
140
154 const unsigned char data[64]);
155
156#if !defined(MBEDTLS_DEPRECATED_REMOVED)
157#if defined(MBEDTLS_DEPRECATED_WARNING)
158#define MBEDTLS_DEPRECATED __attribute__((deprecated))
159#else
160#define MBEDTLS_DEPRECATED
161#endif
173 int is224);
174
188 const unsigned char *input,
189 size_t ilen);
190
203 unsigned char output[32]);
204
217 const unsigned char data[64]);
218
219#undef MBEDTLS_DEPRECATED
220#endif /* !MBEDTLS_DEPRECATED_REMOVED */
221
243int mbedtls_sha256_ret(const unsigned char *input,
244 size_t ilen,
245 unsigned char output[32],
246 int is224);
247
248#if !defined(MBEDTLS_DEPRECATED_REMOVED)
249#if defined(MBEDTLS_DEPRECATED_WARNING)
250#define MBEDTLS_DEPRECATED __attribute__((deprecated))
251#else
252#define MBEDTLS_DEPRECATED
253#endif
254
275MBEDTLS_DEPRECATED void mbedtls_sha256(const unsigned char *input,
276 size_t ilen,
277 unsigned char output[32],
278 int is224);
279
280#undef MBEDTLS_DEPRECATED
281#endif /* !MBEDTLS_DEPRECATED_REMOVED */
282
283#if defined(MBEDTLS_SELF_TEST)
284
292
293#endif /* MBEDTLS_SELF_TEST */
294
295#ifdef __cplusplus
296}
297#endif
298
299#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.
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:252
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:58
uint32_t state[8]
Definition: sha256.h:60
uint32_t total[2]
Definition: sha256.h:59
unsigned char buffer[64]
Definition: sha256.h:61