PolarSSL v1.3.9
sha512.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA512_H
28 #define POLARSSL_SHA512_H
29 
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
35 
36 #include <string.h>
37 
38 #if defined(_MSC_VER) || defined(__WATCOMC__)
39  #define UL64(x) x##ui64
40  typedef unsigned __int64 uint64_t;
41 #else
42  #include <inttypes.h>
43  #define UL64(x) x##ULL
44 #endif
45 
46 #define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A
48 #if !defined(POLARSSL_SHA512_ALT)
49 // Regular implementation
50 //
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
59 typedef struct
60 {
61  uint64_t total[2];
62  uint64_t state[8];
63  unsigned char buffer[128];
65  unsigned char ipad[128];
66  unsigned char opad[128];
67  int is384;
68 }
70 
76 void sha512_init( sha512_context *ctx );
77 
83 void sha512_free( sha512_context *ctx );
84 
91 void sha512_starts( sha512_context *ctx, int is384 );
92 
100 void sha512_update( sha512_context *ctx, const unsigned char *input,
101  size_t ilen );
102 
109 void sha512_finish( sha512_context *ctx, unsigned char output[64] );
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #else /* POLARSSL_SHA512_ALT */
116 #include "sha512_alt.h"
117 #endif /* POLARSSL_SHA512_ALT */
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
131 void sha512( const unsigned char *input, size_t ilen,
132  unsigned char output[64], int is384 );
133 
143 int sha512_file( const char *path, unsigned char output[64], int is384 );
144 
153 void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key,
154  size_t keylen, int is384 );
155 
163 void sha512_hmac_update( sha512_context *ctx, const unsigned char *input,
164  size_t ilen );
165 
172 void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] );
173 
179 void sha512_hmac_reset( sha512_context *ctx );
180 
191 void sha512_hmac( const unsigned char *key, size_t keylen,
192  const unsigned char *input, size_t ilen,
193  unsigned char output[64], int is384 );
194 
200 int sha512_self_test( int verbose );
201 
202 /* Internal use */
203 void sha512_process( sha512_context *ctx, const unsigned char data[128] );
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* sha512.h */