43 #if !defined(MBEDTLS_CONFIG_FILE)
46 #include MBEDTLS_CONFIG_FILE
54 #define MBEDTLS_AES_ENCRYPT 1
55 #define MBEDTLS_AES_DECRYPT 0
59 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
61 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
65 #define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
69 #define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
73 #define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
75 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
76 !defined(inline) && !defined(__cplusplus)
77 #define inline __inline
84 #if !defined(MBEDTLS_AES_ALT)
106 #if defined(MBEDTLS_CIPHER_MODE_XTS)
142 #if defined(MBEDTLS_CIPHER_MODE_XTS)
180 unsigned int keybits );
199 unsigned int keybits );
201 #if defined(MBEDTLS_CIPHER_MODE_XTS)
220 const unsigned char *key,
221 unsigned int keybits );
241 const unsigned char *key,
242 unsigned int keybits );
271 const unsigned char input[16],
272 unsigned char output[16] );
274 #if defined(MBEDTLS_CIPHER_MODE_CBC)
320 unsigned char iv[16],
321 const unsigned char *input,
322 unsigned char *output );
325 #if defined(MBEDTLS_CIPHER_MODE_XTS)
365 const unsigned char data_unit[16],
366 const unsigned char *input,
367 unsigned char *output );
370 #if defined(MBEDTLS_CIPHER_MODE_CFB)
415 unsigned char iv[16],
416 const unsigned char *input,
417 unsigned char *output );
459 unsigned char iv[16],
460 const unsigned char *input,
461 unsigned char *output );
464 #if defined(MBEDTLS_CIPHER_MODE_OFB)
514 unsigned char iv[16],
515 const unsigned char *input,
516 unsigned char *output );
520 #if defined(MBEDTLS_CIPHER_MODE_CTR)
597 unsigned char nonce_counter[16],
598 unsigned char stream_block[16],
599 const unsigned char *input,
600 unsigned char *output );
616 const unsigned char input[16],
617 unsigned char output[16] );
632 const unsigned char input[16],
633 unsigned char output[16] );
635 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
636 #if defined(MBEDTLS_DEPRECATED_WARNING)
637 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
639 #define MBEDTLS_DEPRECATED
652 const unsigned char input[16],
653 unsigned char output[16] );
666 const unsigned char input[16],
667 unsigned char output[16] );
669 #undef MBEDTLS_DEPRECATED
673 #if defined(MBEDTLS_SELF_TEST)
MBEDTLS_CHECK_RETURN_CRITICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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...
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.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
#define MBEDTLS_DEPRECATED
MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
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.
MBEDTLS_CHECK_RETURN_TYPICAL 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_context mbedtls_aes_context
The AES context-type definition.
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
MBEDTLS_CHECK_RETURN_TYPICAL 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.
Configuration options (set of defines)
The AES context-type definition.
The AES XTS context-type definition.
mbedtls_aes_context crypt
mbedtls_aes_context tweak