PolarSSL v1.3.1
sha512.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA512_H
28 #define POLARSSL_SHA512_H
29 
30 #include "config.h"
31 
32 #include <string.h>
33 
34 #if defined(_MSC_VER) || defined(__WATCOMC__)
35  #define UL64(x) x##ui64
36  typedef unsigned __int64 uint64_t;
37 #else
38  #include <inttypes.h>
39  #define UL64(x) x##ULL
40 #endif
41 
42 #define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A
44 #if !defined(POLARSSL_SHA512_ALT)
45 // Regular implementation
46 //
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 typedef struct
56 {
57  uint64_t total[2];
58  uint64_t state[8];
59  unsigned char buffer[128];
61  unsigned char ipad[128];
62  unsigned char opad[128];
63  int is384;
64 }
66 
73 void sha512_starts( sha512_context *ctx, int is384 );
74 
82 void sha512_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
83 
90 void sha512_finish( sha512_context *ctx, unsigned char output[64] );
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #else /* POLARSSL_SHA512_ALT */
97 #include "sha512_alt.h"
98 #endif /* POLARSSL_SHA512_ALT */
99 
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103 
112 void sha512( const unsigned char *input, size_t ilen,
113  unsigned char output[64], int is384 );
114 
124 int sha512_file( const char *path, unsigned char output[64], int is384 );
125 
134 void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key,
135  size_t keylen, int is384 );
136 
144 void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
145 
152 void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] );
153 
159 void sha512_hmac_reset( sha512_context *ctx );
160 
171 void sha512_hmac( const unsigned char *key, size_t keylen,
172  const unsigned char *input, size_t ilen,
173  unsigned char output[64], int is384 );
174 
180 int sha512_self_test( int verbose );
181 
182 /* Internal use */
183 void sha512_process( sha512_context *ctx, const unsigned char data[128] );
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* sha512.h */
void sha512_hmac_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 HMAC process buffer.
Configuration options (set of defines)
void sha512_process(sha512_context *ctx, const unsigned char data[128])
SHA-512 context structure.
Definition: sha512.h:55
void sha512_hmac_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 HMAC final digest.
void sha512_starts(sha512_context *ctx, int is384)
SHA-512 context setup.
int sha512_self_test(int verbose)
Checkup routine.
void sha512(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
int sha512_file(const char *path, unsigned char output[64], int is384)
Output = SHA-512( file contents )
void sha512_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = HMAC-SHA-512( hmac key, input buffer )
void sha512_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 final digest.
void sha512_hmac_starts(sha512_context *ctx, const unsigned char *key, size_t keylen, int is384)
SHA-512 HMAC context setup.
void sha512_hmac_reset(sha512_context *ctx)
SHA-512 HMAC context reset.
void sha512_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.