00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MBEDTLS_SHA512_H
00025 #define MBEDTLS_SHA512_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_SHA512_HW_ACCEL_FAILED -0x0039
00038 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
00039 !defined(inline) && !defined(__cplusplus)
00040 #define inline __inline
00041 #endif
00042 #if !defined(MBEDTLS_SHA512_ALT)
00043
00044
00045
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049
00057 typedef struct
00058 {
00059 uint64_t total[2];
00060 uint64_t state[8];
00061 unsigned char buffer[128];
00062 int is384;
00065 }
00066 mbedtls_sha512_context;
00067
00073 void mbedtls_sha512_init( mbedtls_sha512_context *ctx );
00074
00080 void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
00081
00088 void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
00089 const mbedtls_sha512_context *src );
00090
00102 int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 );
00103
00114 int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
00115 const unsigned char *input,
00116 size_t ilen );
00117
00128 int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
00129 unsigned char output[64] );
00130
00140 int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
00141 const unsigned char data[128] );
00142 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00143 #if defined(MBEDTLS_DEPRECATED_WARNING)
00144 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00145 #else
00146 #define MBEDTLS_DEPRECATED
00147 #endif
00148
00159 MBEDTLS_DEPRECATED static inline void mbedtls_sha512_starts(
00160 mbedtls_sha512_context *ctx,
00161 int is384 )
00162 {
00163 mbedtls_sha512_starts_ret( ctx, is384 );
00164 }
00165
00176 MBEDTLS_DEPRECATED static inline void mbedtls_sha512_update(
00177 mbedtls_sha512_context *ctx,
00178 const unsigned char *input,
00179 size_t ilen )
00180 {
00181 mbedtls_sha512_update_ret( ctx, input, ilen );
00182 }
00183
00193 MBEDTLS_DEPRECATED static inline void mbedtls_sha512_finish(
00194 mbedtls_sha512_context *ctx,
00195 unsigned char output[64] )
00196 {
00197 mbedtls_sha512_finish_ret( ctx, output );
00198 }
00199
00210 MBEDTLS_DEPRECATED static inline void mbedtls_sha512_process(
00211 mbedtls_sha512_context *ctx,
00212 const unsigned char data[128] )
00213 {
00214 mbedtls_internal_sha512_process( ctx, data );
00215 }
00216
00217 #undef MBEDTLS_DEPRECATED
00218 #endif
00219
00220 #ifdef __cplusplus
00221 }
00222 #endif
00223
00224 #else
00225 #include "sha512_alt.h"
00226 #endif
00227
00228 #ifdef __cplusplus
00229 extern "C" {
00230 #endif
00231
00251 int mbedtls_sha512_ret( const unsigned char *input,
00252 size_t ilen,
00253 unsigned char output[64],
00254 int is384 );
00255
00256 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00257 #if defined(MBEDTLS_DEPRECATED_WARNING)
00258 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
00259 #else
00260 #define MBEDTLS_DEPRECATED
00261 #endif
00262
00281 MBEDTLS_DEPRECATED static inline void mbedtls_sha512(
00282 const unsigned char *input,
00283 size_t ilen,
00284 unsigned char output[64],
00285 int is384 )
00286 {
00287 mbedtls_sha512_ret( input, ilen, output, is384 );
00288 }
00289
00290 #undef MBEDTLS_DEPRECATED
00291 #endif
00292
00297 int mbedtls_sha512_self_test( int verbose );
00298
00299 #ifdef __cplusplus
00300 }
00301 #endif
00302
00303 #endif