gcm.h
Go to the documentation of this file.
#ifndef MBEDTLS_GCM_H
#define MBEDTLS_GCM_H
#include "cipher.h"
#include <stdint.h>
#define MBEDTLS_GCM_ENCRYPT 1
#define MBEDTLS_GCM_DECRYPT 0
#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
mbedtls_cipher_context_t cipher_ctx;
uint64_t HL[16];
uint64_t HH[16];
uint64_t len;
uint64_t add_len;
unsigned char base_ectr[16];
unsigned char y[16];
unsigned char buf[16];
int mode;
}
mbedtls_gcm_context;
void mbedtls_gcm_init( mbedtls_gcm_context *ctx );
int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
mbedtls_cipher_id_t cipher,
const unsigned char *key,
unsigned int keybits );
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 );
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 );
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 );
int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
size_t length,
const unsigned char *input,
unsigned char *output );
int mbedtls_gcm_finish( mbedtls_gcm_context *ctx,
unsigned char *tag,
size_t tag_len );
void mbedtls_gcm_free( mbedtls_gcm_context *ctx );
int mbedtls_gcm_self_test( int verbose );
#ifdef __cplusplus
}
#endif
#endif /* gcm.h */
mbedtls_gcm_init
void mbedtls_gcm_init(mbedtls_gcm_context *ctx)
Initialize GCM context (just makes references valid) Makes the context ready for mbedtls_gcm_setkey()...
mbedtls_gcm_starts
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.
mbedtls_gcm_self_test
int mbedtls_gcm_self_test(int verbose)
Checkup routine.
mbedtls_gcm_free
void mbedtls_gcm_free(mbedtls_gcm_context *ctx)
Free a GCM context and underlying cipher sub-context.
mbedtls_cipher_context_t
Generic cipher context.
Definition: cipher.h:213
mbedtls_gcm_context
GCM context structure.
Definition: gcm.h:43
mbedtls_gcm_context::cipher_ctx
mbedtls_cipher_context_t cipher_ctx
Definition: gcm.h:44
mbedtls_gcm_update
int mbedtls_gcm_update(mbedtls_gcm_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
Generic GCM update function.
mbedtls_gcm_context::add_len
uint64_t add_len
Definition: gcm.h:48
mbedtls_cipher_id_t
mbedtls_cipher_id_t
Definition: cipher.h:68
cipher.h
Generic cipher wrapper.
mbedtls_gcm_context::len
uint64_t len
Definition: gcm.h:47
mbedtls_gcm_setkey
int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
GCM initialization (encryption)
mbedtls_gcm_finish
int mbedtls_gcm_finish(mbedtls_gcm_context *ctx, unsigned char *tag, size_t tag_len)
Generic GCM finalisation function.
mbedtls_gcm_context::mode
int mode
Definition: gcm.h:52
mbedtls_gcm_auth_decrypt
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.
mbedtls_gcm_crypt_and_tag
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.