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(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
00039 !defined(inline) && !defined(__cplusplus)
00040 #define inline __inline
00041 #endif
00042 #if !defined(MBEDTLS_SHA256_ALT)
00043
00044
00045
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049
00057 typedef struct
00058 {
00059 uint32_t total[2];
00060 uint32_t state[8];
00061 unsigned char buffer[64];
00062 int is224;
00065 }
00066 mbedtls_sha256_context;
00067
00073 void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
00074
00080 void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
00081
00088 void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
00089 const mbedtls_sha256_context *src );
00090
00102 int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
00103
00114 int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
00115 const unsigned char *input,
00116 size_t ilen );
00117
00127 int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
00128 unsigned char output[32] );
00129
00140 int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
00141 const unsigned char data[64] );
00142
00143 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00144 #if defined(MBEDTLS_DEPRECATED_WARNING)
00145 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00146 #else
00147 #define MBEDTLS_DEPRECATED
00148 #endif
00149
00159 MBEDTLS_DEPRECATED static inline void mbedtls_sha256_starts(
00160 mbedtls_sha256_context *ctx,
00161 int is224 )
00162 {
00163 mbedtls_sha256_starts_ret( ctx, is224 );
00164 }
00165
00176 MBEDTLS_DEPRECATED static inline void mbedtls_sha256_update(
00177 mbedtls_sha256_context *ctx,
00178 const unsigned char *input,
00179 size_t ilen )
00180 {
00181 mbedtls_sha256_update_ret( ctx, input, ilen );
00182 }
00183
00193 MBEDTLS_DEPRECATED static inline void mbedtls_sha256_finish(
00194 mbedtls_sha256_context *ctx,
00195 unsigned char output[32] )
00196 {
00197 mbedtls_sha256_finish_ret( ctx, output );
00198 }
00199
00210 MBEDTLS_DEPRECATED static inline void mbedtls_sha256_process(
00211 mbedtls_sha256_context *ctx,
00212 const unsigned char data[64] )
00213 {
00214 mbedtls_internal_sha256_process( ctx, data );
00215 }
00216
00217 #undef MBEDTLS_DEPRECATED
00218 #endif
00219 #ifdef __cplusplus
00220 }
00221 #endif
00222
00223 #else
00224 #include "sha256_alt.h"
00225 #endif
00226
00227 #ifdef __cplusplus
00228 extern "C" {
00229 #endif
00230
00248 int mbedtls_sha256_ret( const unsigned char *input,
00249 size_t ilen,
00250 unsigned char output[32],
00251 int is224 );
00252
00253 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00254 #if defined(MBEDTLS_DEPRECATED_WARNING)
00255 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00256 #else
00257 #define MBEDTLS_DEPRECATED
00258 #endif
00259
00279 MBEDTLS_DEPRECATED static inline void mbedtls_sha256(
00280 const unsigned char *input,
00281 size_t ilen,
00282 unsigned char output[32],
00283 int is224 )
00284 {
00285 mbedtls_sha256_ret( input, ilen, output, is224 );
00286 }
00287
00288 #undef MBEDTLS_DEPRECATED
00289 #endif
00290
00296 int mbedtls_sha256_self_test( int verbose );
00297
00298 #ifdef __cplusplus
00299 }
00300 #endif
00301
00302 #endif