mbed TLS v3.1.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
27 #include "mbedtls/private_access.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
38 extern "C" {
39 #endif
40 
41 #if !defined(MBEDTLS_SHA256_ALT)
42 // Regular implementation
43 //
44 
52 typedef struct mbedtls_sha256_context
53 {
54  uint32_t MBEDTLS_PRIVATE(total)[2];
55  uint32_t MBEDTLS_PRIVATE(state)[8];
56  unsigned char MBEDTLS_PRIVATE(buffer)[64];
57  int MBEDTLS_PRIVATE(is224);
59 }
60 mbedtls_sha256_context;
61 
62 #else /* MBEDTLS_SHA256_ALT */
63 #include "sha256_alt.h"
64 #endif /* MBEDTLS_SHA256_ALT */
65 
71 void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
72 
80 void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
81 
88 void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
89  const mbedtls_sha256_context *src );
90 
102 int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );
103 
117 int mbedtls_sha256_update( mbedtls_sha256_context *ctx,
118  const unsigned char *input,
119  size_t ilen );
120 
134 int mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
135  unsigned char *output );
136 
149 int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
150  const unsigned char data[64] );
151 
174 int mbedtls_sha256( const unsigned char *input,
175  size_t ilen,
176  unsigned char *output,
177  int is224 );
178 
179 #if defined(MBEDTLS_SELF_TEST)
180 
187 int mbedtls_sha256_self_test( int verbose );
188 
189 #endif /* MBEDTLS_SELF_TEST */
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #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.
Macro wrapper for struct's memebrs.
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-224 and SHA-256 checkup routine.