mbed TLS v2.14.1
sha256.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
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  * This file is part of Mbed TLS (https://tls.mbed.org)
26  */
27 #ifndef MBEDTLS_SHA256_H
28 #define MBEDTLS_SHA256_H
29 
30 #if !defined(MBEDTLS_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include MBEDTLS_CONFIG_FILE
34 #endif
35 
36 #include <stddef.h>
37 #include <stdint.h>
38 
39 /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */
40 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #if !defined(MBEDTLS_SHA256_ALT)
47 // Regular implementation
48 //
49 
57 typedef struct mbedtls_sha256_context
58 {
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 
84 
92  const mbedtls_sha256_context *src );
93 
105 
117  const unsigned char *input,
118  size_t ilen );
119 
130  unsigned char output[32] );
131 
143  const unsigned char data[64] );
144 
145 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
146 #if defined(MBEDTLS_DEPRECATED_WARNING)
147 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
148 #else
149 #define MBEDTLS_DEPRECATED
150 #endif
151 
163  int is224 );
164 
176  const unsigned char *input,
177  size_t ilen );
178 
189  unsigned char output[32] );
190 
202  const unsigned char data[64] );
203 
204 #undef MBEDTLS_DEPRECATED
205 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
206 
223 int mbedtls_sha256_ret( const unsigned char *input,
224  size_t ilen,
225  unsigned char output[32],
226  int is224 );
227 
228 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
229 #if defined(MBEDTLS_DEPRECATED_WARNING)
230 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
231 #else
232 #define MBEDTLS_DEPRECATED
233 #endif
234 
253 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
254  size_t ilen,
255  unsigned char output[32],
256  int is224 );
257 
258 #undef MBEDTLS_DEPRECATED
259 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
260 
267 int mbedtls_sha256_self_test( int verbose );
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #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:59
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:232
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:60
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
The SHA-256 context structure.
Definition: sha256.h:57
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:61
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.