123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #ifndef POLARSSL_AES_H
- #define POLARSSL_AES_H
- #include <string.h>
- #define AES_ENCRYPT 1
- #define AES_DECRYPT 0
- #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
- #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
- typedef struct
- {
- int nr;
- unsigned long *rk;
- unsigned long buf[68];
- #ifdef USE_STM32F4XX_HW_CRYPTO
- unsigned char aes_enc_key[32];
- unsigned char aes_dec_key[32];
- #endif
- }aes_context;
- #ifdef __cplusplus
- extern "C" {
- #endif
- int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize );
- int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize );
- int aes_crypt_ecb( aes_context *ctx,
- int mode,
- const unsigned char input[16],
- unsigned char output[16] );
- int aes_crypt_cbc( aes_context *ctx,
- int mode,
- size_t length,
- unsigned char iv[16],
- const unsigned char *input,
- unsigned char *output );
- int aes_crypt_cfb128( aes_context *ctx,
- int mode,
- size_t length,
- size_t *iv_off,
- unsigned char iv[16],
- const unsigned char *input,
- unsigned char *output );
- int aes_crypt_ctr( 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 );
- int aes_self_test( int verbose );
- #ifdef __cplusplus
- }
- #endif
- #endif
|