PolarSSL v1.3.9
gcm.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_GCM_H
28 #define POLARSSL_GCM_H
29 
30 #include "cipher.h"
31 
32 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
33 #include <basetsd.h>
34 typedef UINT32 uint32_t;
35 typedef UINT64 uint64_t;
36 #else
37 #include <stdint.h>
38 #endif
39 
40 #define GCM_ENCRYPT 1
41 #define GCM_DECRYPT 0
42 
43 #define POLARSSL_ERR_GCM_AUTH_FAILED -0x0012
44 #define POLARSSL_ERR_GCM_BAD_INPUT -0x0014
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 typedef struct {
55  uint64_t HL[16];
56  uint64_t HH[16];
57  uint64_t len;
58  uint64_t add_len;
59  unsigned char base_ectr[16];
60  unsigned char y[16];
61  unsigned char buf[16];
62  int mode;
63 }
65 
76 int gcm_init( gcm_context *ctx, cipher_id_t cipher, const unsigned char *key,
77  unsigned int keysize );
78 
102  int mode,
103  size_t length,
104  const unsigned char *iv,
105  size_t iv_len,
106  const unsigned char *add,
107  size_t add_len,
108  const unsigned char *input,
109  unsigned char *output,
110  size_t tag_len,
111  unsigned char *tag );
112 
134 int gcm_auth_decrypt( gcm_context *ctx,
135  size_t length,
136  const unsigned char *iv,
137  size_t iv_len,
138  const unsigned char *add,
139  size_t add_len,
140  const unsigned char *tag,
141  size_t tag_len,
142  const unsigned char *input,
143  unsigned char *output );
144 
157 int gcm_starts( gcm_context *ctx,
158  int mode,
159  const unsigned char *iv,
160  size_t iv_len,
161  const unsigned char *add,
162  size_t add_len );
163 
181 int gcm_update( gcm_context *ctx,
182  size_t length,
183  const unsigned char *input,
184  unsigned char *output );
185 
197 int gcm_finish( gcm_context *ctx,
198  unsigned char *tag,
199  size_t tag_len );
200 
206 void gcm_free( gcm_context *ctx );
207 
213 int gcm_self_test( int verbose );
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* gcm.h */