00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MBEDTLS_SHA256_H
00025 #define MBEDTLS_SHA256_H
00026
00027 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032
00033 #include <stddef.h>
00034 #include <stdint.h>
00035
00036 #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037
00038 #if !defined(MBEDTLS_SHA256_ALT)
00039
00040
00041
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045
00053 typedef struct
00054 {
00055 uint32_t total[2];
00056 uint32_t state[8];
00057 unsigned char buffer[64];
00058 int is224;
00061 }
00062 mbedtls_sha256_context;
00063
00069 void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
00070
00076 void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
00077
00084 void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
00085 const mbedtls_sha256_context *src );
00086
00098 int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
00099
00110 int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
00111 const unsigned char *input,
00112 size_t ilen );
00113
00123 int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
00124 unsigned char output[32] );
00125
00136 int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
00137 const unsigned char data[64] );
00138
00139 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00140 #if defined(MBEDTLS_DEPRECATED_WARNING)
00141 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00142 #else
00143 #define MBEDTLS_DEPRECATED
00144 #endif
00145
00155 MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
00156 int is224 );
00157
00168 MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
00169 const unsigned char *input,
00170 size_t ilen );
00171
00181 MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
00182 unsigned char output[32] );
00183
00194 MBEDTLS_DEPRECATED void mbedtls_sha256_process( mbedtls_sha256_context *ctx,
00195 const unsigned char data[64] );
00196
00197 #undef MBEDTLS_DEPRECATED
00198 #endif
00199 #ifdef __cplusplus
00200 }
00201 #endif
00202
00203 #else
00204 #include "sha256_alt.h"
00205 #endif
00206
00207 #ifdef __cplusplus
00208 extern "C" {
00209 #endif
00210
00228 int mbedtls_sha256_ret( const unsigned char *input,
00229 size_t ilen,
00230 unsigned char output[32],
00231 int is224 );
00232
00233 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00234 #if defined(MBEDTLS_DEPRECATED_WARNING)
00235 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00236 #else
00237 #define MBEDTLS_DEPRECATED
00238 #endif
00239
00259 MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
00260 size_t ilen,
00261 unsigned char output[32],
00262 int is224 );
00263
00264 #undef MBEDTLS_DEPRECATED
00265 #endif
00266
00272 int mbedtls_sha256_self_test( int verbose );
00273
00274 #ifdef __cplusplus
00275 }
00276 #endif
00277
00278 #endif