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