aes.h 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _AES_H_
  2. #define _AES_H_
  3. #include <stdint.h>
  4. // #define the macros below to 1/0 to enable/disable the mode of operation.
  5. //
  6. // CBC enables AES128 encryption in CBC-mode of operation and handles 0-padding.
  7. // ECB enables the basic ECB 16-byte block algorithm. Both can be enabled simultaneously.
  8. // The #ifndef-guard allows it to be configured before #include'ing or at compile time.
  9. #ifndef CBC
  10. #define CBC 1
  11. #endif
  12. #ifndef ECB
  13. #define ECB 1
  14. #endif
  15. #if defined(ECB) && ECB
  16. void AES128_ECB_encrypt(uint8_t* input, const uint8_t* key, uint8_t *output);
  17. void AES128_ECB_decrypt(uint8_t* input, const uint8_t* key, uint8_t *output);
  18. #endif // #if defined(ECB) && ECB
  19. #if defined(CBC) && CBC
  20. void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  21. void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  22. #endif // #if defined(CBC) && CBC
  23. #endif //_AES_H_