51 #define MBEDTLS_AES_ENCRYPT 1
52 #define MBEDTLS_AES_DECRYPT 0
56 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
58 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
62 #define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
64 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
65 !defined(inline) && !defined(__cplusplus)
66 #define inline __inline
73 #if !defined(MBEDTLS_AES_ALT)
80 typedef struct mbedtls_aes_context
95 #if defined(MBEDTLS_CIPHER_MODE_XTS)
99 typedef struct mbedtls_aes_xts_context
105 } mbedtls_aes_xts_context;
131 #if defined(MBEDTLS_CIPHER_MODE_XTS)
169 unsigned int keybits );
188 unsigned int keybits );
190 #if defined(MBEDTLS_CIPHER_MODE_XTS)
209 const unsigned char *key,
210 unsigned int keybits );
230 const unsigned char *key,
231 unsigned int keybits );
260 const unsigned char input[16],
261 unsigned char output[16] );
263 #if defined(MBEDTLS_CIPHER_MODE_CBC)
309 unsigned char iv[16],
310 const unsigned char *input,
311 unsigned char *output );
314 #if defined(MBEDTLS_CIPHER_MODE_XTS)
354 const unsigned char data_unit[16],
355 const unsigned char *input,
356 unsigned char *output );
359 #if defined(MBEDTLS_CIPHER_MODE_CFB)
404 unsigned char iv[16],
405 const unsigned char *input,
406 unsigned char *output );
448 unsigned char iv[16],
449 const unsigned char *input,
450 unsigned char *output );
453 #if defined(MBEDTLS_CIPHER_MODE_OFB)
503 unsigned char iv[16],
504 const unsigned char *input,
505 unsigned char *output );
509 #if defined(MBEDTLS_CIPHER_MODE_CTR)
586 unsigned char nonce_counter[16],
587 unsigned char stream_block[16],
588 const unsigned char *input,
589 unsigned char *output );
605 const unsigned char input[16],
606 unsigned char output[16] );
621 const unsigned char input[16],
622 unsigned char output[16] );
624 #if defined(MBEDTLS_SELF_TEST)
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_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_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.
#define MBEDTLS_PRIVATE(member)
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
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...
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_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
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. ...
MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_aes_self_test(int verbose)
Checkup routine.
Macro wrapper for struct's memebrs.
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.
void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx)
This function releases and clears the specified AES XTS context.
Build-time configuration info.
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_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_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...
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. ...
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
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...