mbed TLS v2.2.0
gcm.h
Go to the documentation of this file.
1 
23 #ifndef MBEDTLS_GCM_H
24 #define MBEDTLS_GCM_H
25 
26 #include "cipher.h"
27 
28 #include <stdint.h>
29 
30 #define MBEDTLS_GCM_ENCRYPT 1
31 #define MBEDTLS_GCM_DECRYPT 0
32 
33 #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
34 #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 typedef struct {
45  uint64_t HL[16];
46  uint64_t HH[16];
47  uint64_t len;
48  uint64_t add_len;
49  unsigned char base_ectr[16];
50  unsigned char y[16];
51  unsigned char buf[16];
52  int mode;
53 }
55 
64 
76  mbedtls_cipher_id_t cipher,
77  const unsigned char *key,
78  unsigned int keybits );
79 
103  int mode,
104  size_t length,
105  const unsigned char *iv,
106  size_t iv_len,
107  const unsigned char *add,
108  size_t add_len,
109  const unsigned char *input,
110  unsigned char *output,
111  size_t tag_len,
112  unsigned char *tag );
113 
136  size_t length,
137  const unsigned char *iv,
138  size_t iv_len,
139  const unsigned char *add,
140  size_t add_len,
141  const unsigned char *tag,
142  size_t tag_len,
143  const unsigned char *input,
144  unsigned char *output );
145 
159  int mode,
160  const unsigned char *iv,
161  size_t iv_len,
162  const unsigned char *add,
163  size_t add_len );
164 
183  size_t length,
184  const unsigned char *input,
185  unsigned char *output );
186 
199  unsigned char *tag,
200  size_t tag_len );
201 
208 
214 int mbedtls_gcm_self_test( int verbose );
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif /* gcm.h */
void mbedtls_gcm_init(mbedtls_gcm_context *ctx)
Initialize GCM context (just makes references valid) Makes the context ready for mbedtls_gcm_setkey()...
int mbedtls_gcm_starts(mbedtls_gcm_context *ctx, int mode, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len)
Generic GCM stream start function.
int mbedtls_gcm_self_test(int verbose)
Checkup routine.
void mbedtls_gcm_free(mbedtls_gcm_context *ctx)
Free a GCM context and underlying cipher sub-context.
Generic cipher context.
Definition: cipher.h:213
GCM context structure.
Definition: gcm.h:43
mbedtls_cipher_context_t cipher_ctx
Definition: gcm.h:44
int mbedtls_gcm_update(mbedtls_gcm_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
Generic GCM update function.
uint64_t add_len
Definition: gcm.h:48
mbedtls_cipher_id_t
Definition: cipher.h:68
Generic cipher wrapper.
uint64_t len
Definition: gcm.h:47
int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
GCM initialization (encryption)
int mbedtls_gcm_finish(mbedtls_gcm_context *ctx, unsigned char *tag, size_t tag_len)
Generic GCM finalisation function.
int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *tag, size_t tag_len, const unsigned char *input, unsigned char *output)
GCM buffer authenticated decryption using a block cipher.
int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context *ctx, int mode, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, size_t tag_len, unsigned char *tag)
GCM buffer encryption/decryption using a block cipher.