51#if !defined(MBEDTLS_CONFIG_FILE)
54#include MBEDTLS_CONFIG_FILE
57#if defined(MBEDTLS_CIPHER_C)
66#if defined(MBEDTLS_CHACHAPOLY_C)
70#if defined(MBEDTLS_GCM_C)
74#if defined(MBEDTLS_CCM_C)
78#if defined(MBEDTLS_CHACHA20_C)
82#if defined(MBEDTLS_CMAC_C)
86#if defined(MBEDTLS_PLATFORM_C)
89#define mbedtls_calloc calloc
90#define mbedtls_free free
93#define CIPHER_VALIDATE_RET( cond ) \
94 MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA )
95#define CIPHER_VALIDATE( cond ) \
96 MBEDTLS_INTERNAL_VALIDATE( cond )
98#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
104static int mbedtls_constant_time_memcmp(
const void *
v1,
const void *
v2,
size_t len )
106 const unsigned char *p1 = (
const unsigned char*)
v1;
107 const unsigned char *p2 = (
const unsigned char*)
v2;
111 for( diff = 0,
i = 0;
i <
len;
i++ )
112 diff |= p1[
i] ^ p2[
i];
118static int supported_init = 0;
125 if( ! supported_init )
130 while( def->
type != 0 )
146 if( def->
type == cipher_type )
156 if(
NULL == cipher_name )
183 CIPHER_VALIDATE(
ctx !=
NULL );
192#if defined(MBEDTLS_CMAC_C)
201 if(
ctx->cipher_ctx )
202 ctx->cipher_info->base->ctx_free_func(
ctx->cipher_ctx );
209 CIPHER_VALIDATE_RET(
ctx !=
NULL );
210 if( cipher_info ==
NULL )
218 ctx->cipher_info = cipher_info;
220#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
224#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
235 const unsigned char *
key,
239 CIPHER_VALIDATE_RET(
ctx !=
NULL );
240 CIPHER_VALIDATE_RET(
key !=
NULL );
247 (
int)
ctx->cipher_info->key_bitlen != key_bitlen )
252 ctx->key_bitlen = key_bitlen;
263 return(
ctx->cipher_info->base->setkey_enc_func(
ctx->cipher_ctx,
key,
268 return(
ctx->cipher_info->base->setkey_dec_func(
ctx->cipher_ctx,
key,
275 const unsigned char *iv,
278 size_t actual_iv_size;
280 CIPHER_VALIDATE_RET(
ctx !=
NULL );
281 CIPHER_VALIDATE_RET( iv_len == 0 || iv !=
NULL );
290 actual_iv_size = iv_len;
293 actual_iv_size =
ctx->cipher_info->iv_size;
296 if( actual_iv_size > iv_len )
300#if defined(MBEDTLS_CHACHA20_C)
312 if ( actual_iv_size != 0 )
315 ctx->iv_size = actual_iv_size;
323 CIPHER_VALIDATE_RET(
ctx !=
NULL );
327 ctx->unprocessed_len = 0;
332#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
334 const unsigned char *ad,
size_t ad_len )
336 CIPHER_VALIDATE_RET(
ctx !=
NULL );
337 CIPHER_VALIDATE_RET( ad_len == 0 || ad !=
NULL );
341#if defined(MBEDTLS_GCM_C)
345 ctx->iv,
ctx->iv_size, ad, ad_len ) );
349#if defined(MBEDTLS_CHACHAPOLY_C)
375 size_t ilen,
unsigned char *output,
size_t *olen )
380 CIPHER_VALIDATE_RET(
ctx !=
NULL );
381 CIPHER_VALIDATE_RET( ilen == 0 ||
input !=
NULL );
382 CIPHER_VALIDATE_RET( output !=
NULL );
383 CIPHER_VALIDATE_RET( olen !=
NULL );
401 if( 0 != (
ret =
ctx->cipher_info->base->ecb_func(
ctx->cipher_ctx,
410#if defined(MBEDTLS_GCM_C)
419#if defined(MBEDTLS_CHACHAPOLY_C)
424 ilen,
input, output ) );
428 if(
input == output &&
434#if defined(MBEDTLS_CIPHER_MODE_CBC)
443 ilen <= block_size - ctx->unprocessed_len ) ||
445 ilen < block_size - ctx->unprocessed_len ) ||
447 ilen < block_size - ctx->unprocessed_len ) )
452 ctx->unprocessed_len += ilen;
459 if( 0 !=
ctx->unprocessed_len )
466 if( 0 != (
ret =
ctx->cipher_info->base->cbc_func(
ctx->cipher_ctx,
468 ctx->unprocessed_data, output ) ) )
475 ctx->unprocessed_len = 0;
501 ctx->unprocessed_len += copy_len;
510 if( 0 != (
ret =
ctx->cipher_info->base->cbc_func(
ctx->cipher_ctx,
523#if defined(MBEDTLS_CIPHER_MODE_CFB)
526 if( 0 != (
ret =
ctx->cipher_info->base->cfb_func(
ctx->cipher_ctx,
527 ctx->operation, ilen, &
ctx->unprocessed_len,
ctx->iv,
539#if defined(MBEDTLS_CIPHER_MODE_OFB)
542 if( 0 != (
ret =
ctx->cipher_info->base->ofb_func(
ctx->cipher_ctx,
543 ilen, &
ctx->unprocessed_len,
ctx->iv,
input, output ) ) )
554#if defined(MBEDTLS_CIPHER_MODE_CTR)
557 if( 0 != (
ret =
ctx->cipher_info->base->ctr_func(
ctx->cipher_ctx,
558 ilen, &
ctx->unprocessed_len,
ctx->iv,
559 ctx->unprocessed_data,
input, output ) ) )
570#if defined(MBEDTLS_CIPHER_MODE_XTS)
573 if(
ctx->unprocessed_len > 0 ) {
578 ret =
ctx->cipher_info->base->xts_func(
ctx->cipher_ctx,
591#if defined(MBEDTLS_CIPHER_MODE_STREAM)
594 if( 0 != (
ret =
ctx->cipher_info->base->stream_func(
ctx->cipher_ctx,
595 ilen,
input, output ) ) )
609#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
610#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
614static void add_pkcs_padding(
unsigned char *output,
size_t output_len,
617 size_t padding_len = output_len - data_len;
620 for(
i = 0;
i < padding_len;
i++ )
621 output[data_len +
i] = (
unsigned char) padding_len;
624static int get_pkcs_padding(
unsigned char *
input,
size_t input_len,
628 unsigned char padding_len, bad = 0;
633 padding_len =
input[input_len - 1];
634 *data_len = input_len - padding_len;
637 bad |= padding_len > input_len;
638 bad |= padding_len == 0;
642 pad_idx = input_len - padding_len;
643 for(
i = 0;
i < input_len;
i++ )
644 bad |= (
input[
i] ^ padding_len ) * (
i >= pad_idx );
650#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS)
654static void add_one_and_zeros_padding(
unsigned char *output,
655 size_t output_len,
size_t data_len )
657 size_t padding_len = output_len - data_len;
660 output[data_len] = 0x80;
661 for(
i = 1;
i < padding_len;
i++ )
662 output[data_len +
i] = 0x00;
665static int get_one_and_zeros_padding(
unsigned char *
input,
size_t input_len,
669 unsigned char done = 0, prev_done, bad;
676 for(
i = input_len;
i > 0;
i-- )
679 done |= (
input[
i - 1] != 0 );
680 *data_len |= (
i - 1 ) * ( done != prev_done );
681 bad ^=
input[
i - 1] * ( done != prev_done );
689#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN)
693static void add_zeros_and_len_padding(
unsigned char *output,
694 size_t output_len,
size_t data_len )
696 size_t padding_len = output_len - data_len;
699 for(
i = 1;
i < padding_len;
i++ )
700 output[data_len +
i - 1] = 0x00;
701 output[output_len - 1] = (
unsigned char) padding_len;
704static int get_zeros_and_len_padding(
unsigned char *
input,
size_t input_len,
708 unsigned char padding_len, bad = 0;
713 padding_len =
input[input_len - 1];
714 *data_len = input_len - padding_len;
717 bad |= padding_len > input_len;
718 bad |= padding_len == 0;
721 pad_idx = input_len - padding_len;
722 for(
i = 0;
i < input_len - 1;
i++ )
723 bad |=
input[
i] * (
i >= pad_idx );
729#if defined(MBEDTLS_CIPHER_PADDING_ZEROS)
733static void add_zeros_padding(
unsigned char *output,
734 size_t output_len,
size_t data_len )
738 for(
i = data_len;
i < output_len;
i++ )
742static int get_zeros_padding(
unsigned char *
input,
size_t input_len,
746 unsigned char done = 0, prev_done;
752 for(
i = input_len;
i > 0;
i-- )
755 done |= (
input[
i-1] != 0 );
756 *data_len |=
i * ( done != prev_done );
769static int get_no_padding(
unsigned char *
input,
size_t input_len,
775 *data_len = input_len;
782 unsigned char *output,
size_t *olen )
784 CIPHER_VALIDATE_RET(
ctx !=
NULL );
785 CIPHER_VALIDATE_RET( output !=
NULL );
786 CIPHER_VALIDATE_RET( olen !=
NULL );
810 if(
ctx->unprocessed_len != 0 )
816#if defined(MBEDTLS_CIPHER_MODE_CBC)
826 if( 0 !=
ctx->unprocessed_len )
833 ctx->unprocessed_len );
841 if(
NULL ==
ctx->add_padding && 0 ==
ctx->unprocessed_len )
848 if( 0 != (
ret =
ctx->cipher_info->base->cbc_func(
ctx->cipher_ctx,
850 ctx->unprocessed_data, output ) ) )
871#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
875 CIPHER_VALIDATE_RET(
ctx !=
NULL );
884#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
886 ctx->add_padding = add_pkcs_padding;
887 ctx->get_padding = get_pkcs_padding;
890#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS)
892 ctx->add_padding = add_one_and_zeros_padding;
893 ctx->get_padding = get_one_and_zeros_padding;
896#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN)
898 ctx->add_padding = add_zeros_and_len_padding;
899 ctx->get_padding = get_zeros_and_len_padding;
902#if defined(MBEDTLS_CIPHER_PADDING_ZEROS)
904 ctx->add_padding = add_zeros_padding;
905 ctx->get_padding = get_zeros_padding;
910 ctx->get_padding = get_no_padding;
921#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
923 unsigned char *
tag,
size_t tag_len )
925 CIPHER_VALIDATE_RET(
ctx !=
NULL );
926 CIPHER_VALIDATE_RET( tag_len == 0 ||
tag !=
NULL );
933#if defined(MBEDTLS_GCM_C)
939#if defined(MBEDTLS_CHACHAPOLY_C)
943 if ( tag_len != 16U )
955 const unsigned char *
tag,
size_t tag_len )
957 unsigned char check_tag[16];
960 CIPHER_VALIDATE_RET(
ctx !=
NULL );
961 CIPHER_VALIDATE_RET( tag_len == 0 ||
tag !=
NULL );
970#if defined(MBEDTLS_GCM_C)
973 if( tag_len >
sizeof( check_tag ) )
977 check_tag, tag_len ) ) )
983 if( mbedtls_constant_time_memcmp(
tag, check_tag, tag_len ) != 0 )
990#if defined(MBEDTLS_CHACHAPOLY_C)
994 if ( tag_len !=
sizeof( check_tag ) )
1005 if( mbedtls_constant_time_memcmp(
tag, check_tag, tag_len ) != 0 )
1020 const unsigned char *iv,
size_t iv_len,
1021 const unsigned char *
input,
size_t ilen,
1022 unsigned char *output,
size_t *olen )
1027 CIPHER_VALIDATE_RET(
ctx !=
NULL );
1028 CIPHER_VALIDATE_RET( iv_len == 0 || iv !=
NULL );
1029 CIPHER_VALIDATE_RET( ilen == 0 ||
input !=
NULL );
1030 CIPHER_VALIDATE_RET( output !=
NULL );
1031 CIPHER_VALIDATE_RET( olen !=
NULL );
1045 *olen += finish_olen;
1050#if defined(MBEDTLS_CIPHER_MODE_AEAD)
1055 const unsigned char *iv,
size_t iv_len,
1056 const unsigned char *ad,
size_t ad_len,
1057 const unsigned char *
input,
size_t ilen,
1058 unsigned char *output,
size_t *olen,
1059 unsigned char *
tag,
size_t tag_len )
1061 CIPHER_VALIDATE_RET(
ctx !=
NULL );
1062 CIPHER_VALIDATE_RET( iv !=
NULL );
1063 CIPHER_VALIDATE_RET( ad_len == 0 || ad !=
NULL );
1064 CIPHER_VALIDATE_RET( ilen == 0 ||
input !=
NULL );
1065 CIPHER_VALIDATE_RET( output !=
NULL );
1066 CIPHER_VALIDATE_RET( olen !=
NULL );
1067 CIPHER_VALIDATE_RET( tag_len == 0 ||
tag !=
NULL );
1069#if defined(MBEDTLS_GCM_C)
1074 iv, iv_len, ad, ad_len,
input, output,
1078#if defined(MBEDTLS_CCM_C)
1083 iv, iv_len, ad, ad_len,
input, output,
1087#if defined(MBEDTLS_CHACHAPOLY_C)
1091 if ( ( iv_len !=
ctx->cipher_info->iv_size ) ||
1092 ( tag_len != 16U ) )
1099 ilen, iv, ad, ad_len,
input, output,
tag ) );
1110 const unsigned char *iv,
size_t iv_len,
1111 const unsigned char *ad,
size_t ad_len,
1112 const unsigned char *
input,
size_t ilen,
1113 unsigned char *output,
size_t *olen,
1114 const unsigned char *
tag,
size_t tag_len )
1116 CIPHER_VALIDATE_RET(
ctx !=
NULL );
1117 CIPHER_VALIDATE_RET( iv !=
NULL );
1118 CIPHER_VALIDATE_RET( ad_len == 0 || ad !=
NULL );
1119 CIPHER_VALIDATE_RET( ilen == 0 ||
input !=
NULL );
1120 CIPHER_VALIDATE_RET( output !=
NULL );
1121 CIPHER_VALIDATE_RET( olen !=
NULL );
1122 CIPHER_VALIDATE_RET( tag_len == 0 ||
tag !=
NULL );
1124#if defined(MBEDTLS_GCM_C)
1131 iv, iv_len, ad, ad_len,
1140#if defined(MBEDTLS_CCM_C)
1147 iv, iv_len, ad, ad_len,
1156#if defined(MBEDTLS_CHACHAPOLY_C)
1162 if ( ( iv_len !=
ctx->cipher_info->iv_size ) ||
1163 ( tag_len != 16U ) )
1170 iv, ad, ad_len,
tag,
input, output );
int strcmp(const char *String1, const char *String2)
This file provides an API for the CCM authenticated encryption mode for block ciphers.
int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context *ctx, 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, unsigned char *tag, size_t tag_len)
This function encrypts a buffer using CCM.
int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context *ctx, 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, const unsigned char *tag, size_t tag_len)
This function performs a CCM authenticated decryption of a buffer.
#define MBEDTLS_ERR_CCM_AUTH_FAILED
This file contains ChaCha20 definitions and functions.
int mbedtls_chacha20_starts(mbedtls_chacha20_context *ctx, const unsigned char nonce[12], uint32_t counter)
This function sets the nonce and initial counter value.
This file contains the AEAD-ChaCha20-Poly1305 definitions and functions.
int mbedtls_chachapoly_finish(mbedtls_chachapoly_context *ctx, unsigned char mac[16])
This function finished the ChaCha20-Poly1305 operation and generates the MAC (authentication tag).
int mbedtls_chachapoly_starts(mbedtls_chachapoly_context *ctx, const unsigned char nonce[12], mbedtls_chachapoly_mode_t mode)
This function starts a ChaCha20-Poly1305 encryption or decryption operation.
int mbedtls_chachapoly_update(mbedtls_chachapoly_context *ctx, size_t len, const unsigned char *input, unsigned char *output)
Thus function feeds data to be encrypted or decrypted into an on-going ChaCha20-Poly1305 operation.
int mbedtls_chachapoly_encrypt_and_tag(mbedtls_chachapoly_context *ctx, size_t length, const unsigned char nonce[12], const unsigned char *aad, size_t aad_len, const unsigned char *input, unsigned char *output, unsigned char tag[16])
This function performs a complete ChaCha20-Poly1305 authenticated encryption with the previously-set ...
#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED
mbedtls_chachapoly_mode_t
@ MBEDTLS_CHACHAPOLY_ENCRYPT
@ MBEDTLS_CHACHAPOLY_DECRYPT
int mbedtls_chachapoly_auth_decrypt(mbedtls_chachapoly_context *ctx, size_t length, const unsigned char nonce[12], const unsigned char *aad, size_t aad_len, const unsigned char tag[16], const unsigned char *input, unsigned char *output)
This function performs a complete ChaCha20-Poly1305 authenticated decryption with the previously-set ...
int mbedtls_chachapoly_update_aad(mbedtls_chachapoly_context *ctx, const unsigned char *aad, size_t aad_len)
This function feeds additional data to be authenticated into an ongoing ChaCha20-Poly1305 operation.
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info)
This function initializes and fills the cipher-context structure with the appropriate values....
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
@ MBEDTLS_CIPHER_CHACHA20
@ MBEDTLS_CIPHER_CHACHA20_POLY1305
int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx, const unsigned char *key, int key_bitlen, const mbedtls_operation_t operation)
This function sets the key to use with the given context.
#define MBEDTLS_ERR_CIPHER_INVALID_PADDING
int mbedtls_cipher_crypt(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen)
The generic all-in-one encryption/decryption function, for all ciphers except AEAD constructs.
int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx)
This function resets the cipher state.
#define MBEDTLS_CIPHER_VARIABLE_IV_LEN
#define MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE
int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len)
This function sets the initialization vector (IV) or nonce.
@ MBEDTLS_PADDING_ONE_AND_ZEROS
@ MBEDTLS_PADDING_ZEROS_AND_LEN
int mbedtls_cipher_auth_encrypt(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, unsigned char *tag, size_t tag_len)
The generic autenticated encryption (AEAD) function.
int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen)
The generic cipher finalization function. If data still needs to be flushed from an incomplete block,...
#define MBEDTLS_ERR_CIPHER_AUTH_FAILED
#define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
int mbedtls_cipher_auth_decrypt(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, const unsigned char *tag, size_t tag_len)
The generic autenticated decryption (AEAD) function.
const mbedtls_cipher_info_t * mbedtls_cipher_info_from_values(const mbedtls_cipher_id_t cipher_id, int key_bitlen, const mbedtls_cipher_mode_t mode)
This function retrieves the cipher-information structure associated with the given cipher ID,...
void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx)
This function initializes a cipher_context as NONE.
int mbedtls_cipher_update_ad(mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len)
This function adds additional data for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly13...
#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN
int mbedtls_cipher_write_tag(mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len)
This function writes a tag for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly1305....
void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx)
This function frees and clears the cipher-specific context of ctx. Freeing ctx itself remains the res...
static int mbedtls_cipher_get_iv_size(const mbedtls_cipher_context_t *ctx)
This function returns the size of the IV or nonce of the cipher, in Bytes.
int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen)
The generic cipher update function. It encrypts or decrypts using the given cipher context....
static unsigned int mbedtls_cipher_get_block_size(const mbedtls_cipher_context_t *ctx)
This function returns the block size of the given cipher.
const mbedtls_cipher_info_t * mbedtls_cipher_info_from_string(const char *cipher_name)
This function retrieves the cipher-information structure associated with the given cipher name.
const int * mbedtls_cipher_list(void)
This function retrieves the list of ciphers supported by the generic cipher module.
#define MBEDTLS_ERR_CIPHER_ALLOC_FAILED
#define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED
int mbedtls_cipher_check_tag(mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len)
This function checks the tag for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly1305....
#define MBEDTLS_MAX_IV_LENGTH
#define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT
mbedtls_cipher_id_t
Supported cipher types.
int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode)
This function sets the padding mode, for cipher modes that use padding.
const mbedtls_cipher_definition_t mbedtls_cipher_definitions[]
int mbedtls_cipher_supported[]
This file contains CMAC definitions and functions.
This file contains GCM definitions and functions.
#define MBEDTLS_GCM_ENCRYPT
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)
This function starts a GCM encryption or decryption operation.
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)
This function performs GCM encryption or decryption of a buffer.
int mbedtls_gcm_finish(mbedtls_gcm_context *ctx, unsigned char *tag, size_t tag_len)
This function finishes the GCM operation and generates the authentication tag.
#define MBEDTLS_ERR_GCM_AUTH_FAILED
int mbedtls_gcm_update(mbedtls_gcm_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
This function feeds an input buffer into an ongoing GCM encryption or decryption operation.
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)
This function performs a GCM authenticated decryption of a buffer.
GLuint GLuint GLsizei GLenum type
GLenum GLenum GLenum input
GLfloat GLfloat GLfloat v2
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static DWORD block_size(DWORD block)
#define memcpy(s1, s2, n)
#define mbedtls_cipher_info_from_type
Configuration options (set of defines)
mbedtls_cipher_id_t cipher
void *(* ctx_alloc_func)(void)
mbedtls_cipher_type_t type
const mbedtls_cipher_info_t * info
mbedtls_cipher_mode_t mode
const mbedtls_cipher_base_t * base
The GCM context structure.