43#if !defined(MBEDTLS_CONFIG_FILE)
46#include MBEDTLS_CONFIG_FILE
53#define MBEDTLS_AES_ENCRYPT 1
54#define MBEDTLS_AES_DECRYPT 0
57#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
58#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
61#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
64#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
67#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
69#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
70 !defined(inline) && !defined(__cplusplus)
71#define inline __inline
78#if !defined(MBEDTLS_AES_ALT)
100#if defined(MBEDTLS_CIPHER_MODE_XTS)
136#if defined(MBEDTLS_CIPHER_MODE_XTS)
173 unsigned int keybits );
191 unsigned int keybits );
193#if defined(MBEDTLS_CIPHER_MODE_XTS)
211 const unsigned char *key,
212 unsigned int keybits );
231 const unsigned char *key,
232 unsigned int keybits );
260 const unsigned char input[16],
261 unsigned char output[16] );
263#if defined(MBEDTLS_CIPHER_MODE_CBC)
308 unsigned char iv[16],
309 const unsigned char *input,
310 unsigned char *output );
313#if defined(MBEDTLS_CIPHER_MODE_XTS)
352 const unsigned char data_unit[16],
353 const unsigned char *input,
354 unsigned char *output );
357#if defined(MBEDTLS_CIPHER_MODE_CFB)
401 unsigned char iv[16],
402 const unsigned char *input,
403 unsigned char *output );
444 unsigned char iv[16],
445 const unsigned char *input,
446 unsigned char *output );
449#if defined(MBEDTLS_CIPHER_MODE_OFB)
498 unsigned char iv[16],
499 const unsigned char *input,
500 unsigned char *output );
504#if defined(MBEDTLS_CIPHER_MODE_CTR)
584 unsigned char nonce_counter[16],
585 unsigned char stream_block[16],
586 const unsigned char *input,
587 unsigned char *output );
602 const unsigned char input[16],
603 unsigned char output[16] );
617 const unsigned char input[16],
618 unsigned char output[16] );
620#if !defined(MBEDTLS_DEPRECATED_REMOVED)
621#if defined(MBEDTLS_DEPRECATED_WARNING)
622#define MBEDTLS_DEPRECATED __attribute__((deprecated))
624#define MBEDTLS_DEPRECATED
637 const unsigned char input[16],
638 unsigned char output[16] );
651 const unsigned char input[16],
652 unsigned char output[16] );
654#undef MBEDTLS_DEPRECATED
658#if defined(MBEDTLS_SELF_TEST)
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
This function performs an AES single-block encryption or decryption operation.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
int mbedtls_aes_self_test(int verbose)
Checkup routine.
void mbedtls_aes_xts_init(mbedtls_aes_xts_context *ctx)
This function initializes the specified AES XTS context.
int mbedtls_aes_crypt_ofb(mbedtls_aes_context *ctx, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-OFB (Output Feedback Mode) encryption or decryption operation.
int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CBC encryption or decryption operation on full blocks.
int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CTR encryption or decryption operation.
int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for decryption and sets the decryption key.
int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output)
This function performs an AES-XTS encryption or decryption operation for an entire XTS data unit.
int mbedtls_internal_aes_encrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Internal AES block encryption function. This is only exposed to allow overriding it using MBEDTLS_AES...
struct mbedtls_aes_xts_context mbedtls_aes_xts_context
The AES XTS context-type definition.
void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx)
This function releases and clears the specified AES XTS context.
int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB128 encryption or decryption operation.
int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB8 encryption or decryption operation.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
#define MBEDTLS_DEPRECATED
MBEDTLS_DEPRECATED void mbedtls_aes_decrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Deprecated internal AES block decryption function without return value.
struct mbedtls_aes_context mbedtls_aes_context
The AES context-type definition.
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
MBEDTLS_DEPRECATED void mbedtls_aes_encrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Deprecated internal AES block encryption function without return value.
int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Internal AES block decryption function. This is only exposed to allow overriding it using see MBEDTLS...
int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for encryption and sets the encryption key.
Configuration options (set of defines)
The AES context-type definition.
The AES XTS context-type definition.
mbedtls_aes_context crypt
mbedtls_aes_context tweak