mbed TLS v1.3.17
sha512.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_SHA512_H
25 #define POLARSSL_SHA512_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(__WATCOMC__)
36  typedef unsigned __int64 uint64_t;
37 #else
38  #include <inttypes.h>
39 #endif
40 
41 #define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A
43 #if !defined(POLARSSL_SHA512_ALT)
44 // Regular implementation
45 //
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
54 typedef struct
55 {
56  uint64_t total[2];
57  uint64_t state[8];
58  unsigned char buffer[128];
60  unsigned char ipad[128];
61  unsigned char opad[128];
62  int is384;
63 }
65 
71 void sha512_init( sha512_context *ctx );
72 
78 void sha512_free( sha512_context *ctx );
79 
86 void sha512_starts( sha512_context *ctx, int is384 );
87 
95 void sha512_update( sha512_context *ctx, const unsigned char *input,
96  size_t ilen );
97 
104 void sha512_finish( sha512_context *ctx, unsigned char output[64] );
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #else /* POLARSSL_SHA512_ALT */
111 #include "sha512_alt.h"
112 #endif /* POLARSSL_SHA512_ALT */
113 
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117 
126 void sha512( const unsigned char *input, size_t ilen,
127  unsigned char output[64], int is384 );
128 
138 int sha512_file( const char *path, unsigned char output[64], int is384 );
139 
148 void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key,
149  size_t keylen, int is384 );
150 
158 void sha512_hmac_update( sha512_context *ctx, const unsigned char *input,
159  size_t ilen );
160 
167 void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] );
168 
174 void sha512_hmac_reset( sha512_context *ctx );
175 
186 void sha512_hmac( const unsigned char *key, size_t keylen,
187  const unsigned char *input, size_t ilen,
188  unsigned char output[64], int is384 );
189 
195 int sha512_self_test( int verbose );
196 
197 /* Internal use */
198 void sha512_process( sha512_context *ctx, const unsigned char data[128] );
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #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:54
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_free(sha512_context *ctx)
Clear SHA-512 context.
void sha512_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.
void sha512_init(sha512_context *ctx)
Initialize SHA-512 context.