123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #ifndef AES_DRIVER_H
- #define AES_DRIVER_H
- #include "avr_compiler.h"
- #define AES_BLOCK_LENGTH 16
- typedef struct AES_interrupt_driver
- {
-
- uint8_t * input_ptr;
-
- uint8_t * key_ptr;
-
- uint8_t * init_ptr;
-
- uint8_t * output_ptr;
-
- uint8_t block_count;
-
- uint8_t blocks_left;
-
- bool decrypt;
- } AES_interrupt_driver_t;
- #define AES_encryption_mode_set() ( AES.CTRL = AES.CTRL & (~AES_DECRYPT_bm) )
- #define AES_decryption_mode_set() ( AES.CTRL |= AES_DECRYPT_bm )
- #define AES_auto_enable() ( AES.CTRL |= AES_AUTO_bm )
- #define AES_auto_disable() ( AES.CTRL = AES.CTRL & (~AES_AUTO_bm) )
- #define AES_xor_enable() ( AES.CTRL |= AES_XOR_bm )
- #define AES_xor_disable() ( AES.CTRL = AES.CTRL & (~AES_XOR_bm) )
- #define AES_software_reset() ( AES.CTRL = AES_RESET_bm )
- #define AES_start() ( AES.CTRL |= AES_START_bm )
- #define AES_state_ready_flag_check() ((AES.STATUS & AES_SRIF_bm) != 0)
- #define AES_error_flag_check() ((AES.STATUS & AES_ERROR_bm) != 0)
- void AES_interrupt_driver_init(AES_interrupt_driver_t * interrupt_driver,
- uint8_t * input_ptr, uint8_t * output_ptr,
- uint8_t * AES_key, uint8_t * AES_init,
- uint8_t block_count, bool decrypt);
- bool AES_interrupt_driver_start(AES_interrupt_driver_t * interrupt_driver,
- AES_INTLVL_t int_lvl);
- void AES_interrupt_handler(AES_interrupt_driver_t * interrupt_driver);
- bool AES_interrupt_driver_finished(AES_interrupt_driver_t * interrupt_driver);
- void AES_interruptlevel_set(AES_INTLVL_t int_lvl);
- bool AES_encrypt(uint8_t * plaintext, uint8_t * ciphertext, uint8_t * key);
- bool AES_decrypt(uint8_t * ciphertext, uint8_t * plaintext, uint8_t * key);
- bool AES_encrypt_backtoback(uint8_t * plaintext, uint8_t * ciphertext);
- bool AES_decrypt_backtoback(uint8_t * ciphertext, uint8_t * plaintext);
- bool AES_lastsubkey_generate(uint8_t * key, uint8_t * decrypt_key);
- bool AES_CBC_encrypt(uint8_t * plaintext, uint8_t * ciphertext, uint8_t * keys,
- uint8_t * init, uint16_t block_count);
- bool AES_CBC_decrypt(uint8_t * ciphertext, uint8_t * plaintext, uint8_t * keys,
- uint8_t * init, uint16_t block_count);
- #endif
|