mbed TLS v2.0.0
gcm.h
Go to the documentation of this file.
1 
24 #ifndef MBEDTLS_GCM_H
25 #define MBEDTLS_GCM_H
26 
27 #include "cipher.h"
28 
29 #include <stdint.h>
30 
31 #define MBEDTLS_GCM_ENCRYPT 1
32 #define MBEDTLS_GCM_DECRYPT 0
33 
34 #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
35 #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
44 typedef struct {
46  uint64_t HL[16];
47  uint64_t HH[16];
48  uint64_t len;
49  uint64_t add_len;
50  unsigned char base_ectr[16];
51  unsigned char y[16];
52  unsigned char buf[16];
53  int mode;
54 }
56 
65 
77  mbedtls_cipher_id_t cipher,
78  const unsigned char *key,
79  unsigned int keybits );
80 
104  int mode,
105  size_t length,
106  const unsigned char *iv,
107  size_t iv_len,
108  const unsigned char *add,
109  size_t add_len,
110  const unsigned char *input,
111  unsigned char *output,
112  size_t tag_len,
113  unsigned char *tag );
114 
137  size_t length,
138  const unsigned char *iv,
139  size_t iv_len,
140  const unsigned char *add,
141  size_t add_len,
142  const unsigned char *tag,
143  size_t tag_len,
144  const unsigned char *input,
145  unsigned char *output );
146 
160  int mode,
161  const unsigned char *iv,
162  size_t iv_len,
163  const unsigned char *add,
164  size_t add_len );
165 
184  size_t length,
185  const unsigned char *input,
186  unsigned char *output );
187 
200  unsigned char *tag,
201  size_t tag_len );
202 
209 
215 int mbedtls_gcm_self_test( int verbose );
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #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:44
mbedtls_cipher_context_t cipher_ctx
Definition: gcm.h:45
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:49
mbedtls_cipher_id_t
Definition: cipher.h:68
Generic cipher wrapper.
uint64_t len
Definition: gcm.h:48
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.