aes.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 AES encryption in CBC-mode of operation.
  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. #define AES128 1
  16. //#define AES192 1
  17. //#define AES256 1
  18. #if defined(ECB) && (ECB == 1)
  19. void AES_ECB_encrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
  20. void AES_ECB_decrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
  21. #endif // #if defined(ECB) && (ECB == !)
  22. #if defined(CBC) && (CBC == 1)
  23. void AES_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  24. void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  25. #endif // #if defined(CBC) && (CBC == 1)
  26. #endif //_AES_H_