mbed TLS v1.3.11
sha1.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_SHA1_H
25 #define POLARSSL_SHA1_H
26 
27 #if !defined(POLARSSL_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include POLARSSL_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 
35 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
36 #include <basetsd.h>
37 typedef UINT32 uint32_t;
38 #else
39 #include <inttypes.h>
40 #endif
41 
42 #define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076
44 #if !defined(POLARSSL_SHA1_ALT)
45 // Regular implementation
46 //
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 typedef struct
56 {
57  uint32_t total[2];
58  uint32_t state[5];
59  unsigned char buffer[64];
61  unsigned char ipad[64];
62  unsigned char opad[64];
63 }
65 
71 void sha1_init( sha1_context *ctx );
72 
78 void sha1_free( sha1_context *ctx );
79 
85 void sha1_starts( sha1_context *ctx );
86 
94 void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen );
95 
102 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
103 
104 /* Internal use */
105 void sha1_process( sha1_context *ctx, const unsigned char data[64] );
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #else /* POLARSSL_SHA1_ALT */
112 #include "sha1_alt.h"
113 #endif /* POLARSSL_SHA1_ALT */
114 
115 #ifdef __cplusplus
116 extern "C" {
117 #endif
118 
126 void sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
127 
136 int sha1_file( const char *path, unsigned char output[20] );
137 
145 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key,
146  size_t keylen );
147 
155 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input,
156  size_t ilen );
157 
164 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
165 
171 void sha1_hmac_reset( sha1_context *ctx );
172 
182 void sha1_hmac( const unsigned char *key, size_t keylen,
183  const unsigned char *input, size_t ilen,
184  unsigned char output[20] );
185 
191 int sha1_self_test( int verbose );
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* sha1.h */
void sha1_hmac_finish(sha1_context *ctx, unsigned char output[20])
SHA-1 HMAC final digest.
int sha1_self_test(int verbose)
Checkup routine.
SHA-1 context structure.
Definition: sha1.h:55
void sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = SHA-1( input buffer )
void sha1_finish(sha1_context *ctx, unsigned char output[20])
SHA-1 final digest.
void sha1_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[20])
Output = HMAC-SHA-1( hmac key, input buffer )
Configuration options (set of defines)
void sha1_hmac_reset(sha1_context *ctx)
SHA-1 HMAC context reset.
int sha1_file(const char *path, unsigned char output[20])
Output = SHA-1( file contents )
void sha1_free(sha1_context *ctx)
Clear SHA-1 context.
void sha1_hmac_starts(sha1_context *ctx, const unsigned char *key, size_t keylen)
SHA-1 HMAC context setup.
void sha1_starts(sha1_context *ctx)
SHA-1 context setup.
void sha1_init(sha1_context *ctx)
Initialize SHA-1 context.
void sha1_update(sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 process buffer.
void sha1_process(sha1_context *ctx, const unsigned char data[64])
void sha1_hmac_update(sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 HMAC process buffer.