00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef MBEDTLS_SHA1_H
00029 #define MBEDTLS_SHA1_H
00030
00031 #if !defined(MBEDTLS_CONFIG_FILE)
00032 #include "config.h"
00033 #else
00034 #include MBEDTLS_CONFIG_FILE
00035 #endif
00036
00037 #include <stddef.h>
00038 #include <stdint.h>
00039
00040 #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035
00042 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
00043 !defined(inline) && !defined(__cplusplus)
00044 #define inline __inline
00045 #endif
00046
00047 #if !defined(MBEDTLS_SHA1_ALT)
00048
00049
00050
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054
00063 typedef struct
00064 {
00065 uint32_t total[2];
00066 uint32_t state[5];
00067 unsigned char buffer[64];
00068 }
00069 mbedtls_sha1_context;
00070
00081 void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
00082
00093 void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
00094
00106 void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
00107 const mbedtls_sha1_context *src );
00108
00121 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
00122
00138 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
00139 const unsigned char *input,
00140 size_t ilen );
00141
00156 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
00157 unsigned char output[20] );
00158
00172 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
00173 const unsigned char data[64] );
00174
00175 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00176 #if defined(MBEDTLS_DEPRECATED_WARNING)
00177 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00178 #else
00179 #define MBEDTLS_DEPRECATED
00180 #endif
00181
00193 MBEDTLS_DEPRECATED static inline void mbedtls_sha1_starts(
00194 mbedtls_sha1_context *ctx )
00195 {
00196 mbedtls_sha1_starts_ret( ctx );
00197 }
00198
00213 MBEDTLS_DEPRECATED static inline void mbedtls_sha1_update(
00214 mbedtls_sha1_context *ctx,
00215 const unsigned char *input,
00216 size_t ilen )
00217 {
00218 mbedtls_sha1_update_ret( ctx, input, ilen );
00219 }
00220
00234 MBEDTLS_DEPRECATED static inline void mbedtls_sha1_finish(
00235 mbedtls_sha1_context *ctx,
00236 unsigned char output[20] )
00237 {
00238 mbedtls_sha1_finish_ret( ctx, output );
00239 }
00240
00254 MBEDTLS_DEPRECATED static inline void mbedtls_sha1_process(
00255 mbedtls_sha1_context *ctx,
00256 const unsigned char data[64] )
00257 {
00258 mbedtls_internal_sha1_process( ctx, data );
00259 }
00260
00261 #undef MBEDTLS_DEPRECATED
00262 #endif
00263
00264 #ifdef __cplusplus
00265 }
00266 #endif
00267
00268 #else
00269 #include "sha1_alt.h"
00270 #endif
00271
00272 #ifdef __cplusplus
00273 extern "C" {
00274 #endif
00275
00296 int mbedtls_sha1_ret( const unsigned char *input,
00297 size_t ilen,
00298 unsigned char output[20] );
00299
00300 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00301 #if defined(MBEDTLS_DEPRECATED_WARNING)
00302 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00303 #else
00304 #define MBEDTLS_DEPRECATED
00305 #endif
00306
00320 MBEDTLS_DEPRECATED static inline void mbedtls_sha1( const unsigned char *input,
00321 size_t ilen,
00322 unsigned char output[20] )
00323 {
00324 mbedtls_sha1_ret( input, ilen, output );
00325 }
00326
00327 #undef MBEDTLS_DEPRECATED
00328 #endif
00329
00340 int mbedtls_sha1_self_test( int verbose );
00341
00342 #ifdef __cplusplus
00343 }
00344 #endif
00345
00346 #endif