mbed TLS v2.7.6
sha256.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * This file is part of Mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_SHA256_H
25 #define MBEDTLS_SHA256_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 #include <stdint.h>
35 
36 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
38 #if !defined(MBEDTLS_SHA256_ALT)
39 // Regular implementation
40 //
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
53 typedef struct
54 {
55  uint32_t total[2];
56  uint32_t state[8];
57  unsigned char buffer[64];
58  int is224;
61 }
63 
70 
77 
85  const mbedtls_sha256_context *src );
86 
99 
111  const unsigned char *input,
112  size_t ilen );
113 
124  unsigned char output[32] );
125 
137  const unsigned char data[64] );
138 
139 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
140 #if defined(MBEDTLS_DEPRECATED_WARNING)
141 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
142 #else
143 #define MBEDTLS_DEPRECATED
144 #endif
145 
156  int is224 );
157 
169  const unsigned char *input,
170  size_t ilen );
171 
182  unsigned char output[32] );
183 
195  const unsigned char data[64] );
196 
197 #undef MBEDTLS_DEPRECATED
198 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #else /* MBEDTLS_SHA256_ALT */
204 #include "sha256_alt.h"
205 #endif /* MBEDTLS_SHA256_ALT */
206 
207 #ifdef __cplusplus
208 extern "C" {
209 #endif
210 
228 int mbedtls_sha256_ret( const unsigned char *input,
229  size_t ilen,
230  unsigned char output[32],
231  int is224 );
232 
233 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
234 #if defined(MBEDTLS_DEPRECATED_WARNING)
235 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
236 #else
237 #define MBEDTLS_DEPRECATED
238 #endif
239 
259 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
260  size_t ilen,
261  unsigned char output[32],
262  int is224 );
263 
264 #undef MBEDTLS_DEPRECATED
265 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
266 
272 int mbedtls_sha256_self_test( int verbose );
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #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.
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:237
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. ...
The SHA-256 context structure.
Definition: sha256.h:53
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.
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-256 checksum calculation.
int mbedtls_sha256_self_test(int verbose)
The SHA-224 and SHA-256 checkup routine.