PolarSSL v1.3.8
sha1.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA1_H
28 #define POLARSSL_SHA1_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(EFIX64) && !defined(EFI32)
39 #include <basetsd.h>
40 typedef UINT32 uint32_t;
41 #else
42 #include <inttypes.h>
43 #endif
44 
45 #define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076
47 #if !defined(POLARSSL_SHA1_ALT)
48 // Regular implementation
49 //
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef struct
59 {
60  uint32_t total[2];
61  uint32_t state[5];
62  unsigned char buffer[64];
64  unsigned char ipad[64];
65  unsigned char opad[64];
66 }
68 
74 void sha1_init( sha1_context *ctx );
75 
81 void sha1_free( sha1_context *ctx );
82 
88 void sha1_starts( sha1_context *ctx );
89 
97 void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen );
98 
105 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
106 
107 /* Internal use */
108 void sha1_process( sha1_context *ctx, const unsigned char data[64] );
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #else /* POLARSSL_SHA1_ALT */
115 #include "sha1_alt.h"
116 #endif /* POLARSSL_SHA1_ALT */
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
129 void sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
130 
139 int sha1_file( const char *path, unsigned char output[20] );
140 
148 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key,
149  size_t keylen );
150 
158 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input,
159  size_t ilen );
160 
167 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
168 
174 void sha1_hmac_reset( sha1_context *ctx );
175 
185 void sha1_hmac( const unsigned char *key, size_t keylen,
186  const unsigned char *input, size_t ilen,
187  unsigned char output[20] );
188 
194 int sha1_self_test( int verbose );
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* sha1.h */