00001 00023 #ifndef MBEDTLS_SHA256_H 00024 #define MBEDTLS_SHA256_H 00025 00026 #if !defined(MBEDTLS_CONFIG_FILE) 00027 #include "config.h" 00028 #else 00029 #include MBEDTLS_CONFIG_FILE 00030 #endif 00031 00032 #include <stddef.h> 00033 #include <stdint.h> 00034 00035 #if !defined(MBEDTLS_SHA256_ALT) 00036 // Regular implementation 00037 // 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00046 typedef struct 00047 { 00048 uint32_t total[2]; 00049 uint32_t state[8]; 00050 unsigned char buffer[64]; 00051 int is224; 00052 } 00053 mbedtls_sha256_context; 00054 00060 void mbedtls_sha256_init( mbedtls_sha256_context *ctx ); 00061 00067 void mbedtls_sha256_free( mbedtls_sha256_context *ctx ); 00068 00075 void mbedtls_sha256_clone( mbedtls_sha256_context *dst, 00076 const mbedtls_sha256_context *src ); 00077 00084 void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ); 00085 00093 void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, 00094 size_t ilen ); 00095 00102 void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ); 00103 00104 /* Internal use */ 00105 void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); 00106 00107 #ifdef __cplusplus 00108 } 00109 #endif 00110 00111 #else /* MBEDTLS_SHA256_ALT */ 00112 #include "sha256_alt.h" 00113 #endif /* MBEDTLS_SHA256_ALT */ 00114 00115 #ifdef __cplusplus 00116 extern "C" { 00117 #endif 00118 00127 void mbedtls_sha256( const unsigned char *input, size_t ilen, 00128 unsigned char output[32], int is224 ); 00129 00135 int mbedtls_sha256_self_test( int verbose ); 00136 00137 #ifdef __cplusplus 00138 } 00139 #endif 00140 00141 #endif /* mbedtls_sha256.h */