123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- #ifndef MBEDTLS_AES_H
- #define MBEDTLS_AES_H
- #if !defined(MBEDTLS_CONFIG_FILE)
- #include "config.h"
- #else
- #include MBEDTLS_CONFIG_FILE
- #endif
- #include <stddef.h>
- #include <stdint.h>
- #define MBEDTLS_AES_ENCRYPT 1
- #define MBEDTLS_AES_DECRYPT 0
- #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
- #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
- #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
- !defined(inline) && !defined(__cplusplus)
- #define inline __inline
- #endif
- #if !defined(MBEDTLS_AES_ALT)
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct
- {
- int nr;
- uint32_t *rk;
- uint32_t buf[68];
- }
- mbedtls_aes_context;
- void mbedtls_aes_init( mbedtls_aes_context *ctx );
- void mbedtls_aes_free( mbedtls_aes_context *ctx );
- int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
- unsigned int keybits );
- int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
- unsigned int keybits );
- int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
- int mode,
- const unsigned char input[16],
- unsigned char output[16] );
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- 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 );
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- 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 );
- 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 );
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- 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 );
- #endif
- int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
- int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
- #if !defined(MBEDTLS_DEPRECATED_REMOVED)
- #if defined(MBEDTLS_DEPRECATED_WARNING)
- #define MBEDTLS_DEPRECATED __attribute__((deprecated))
- #else
- #define MBEDTLS_DEPRECATED
- #endif
- MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
- MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
- #undef MBEDTLS_DEPRECATED
- #endif
- #ifdef __cplusplus
- }
- #endif
- #else
- #include "aes_alt.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- int mbedtls_aes_self_test( int verbose );
- #ifdef __cplusplus
- }
- #endif
- #endif
|