aes.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * this file comes from https://github.com/kokke/tiny-AES128-C
  3. */
  4. #ifndef _AES_H_
  5. #define _AES_H_
  6. #include <stdint.h>
  7. // #define the macros below to 1/0 to enable/disable the mode of operation.
  8. //
  9. // CBC enables AES encryption in CBC-mode of operation.
  10. // ECB enables the basic ECB 16-byte block algorithm. Both can be enabled simultaneously.
  11. // The #ifndef-guard allows it to be configured before #include'ing or at compile time.
  12. #ifndef CBC
  13. #define CBC 1
  14. #endif
  15. #ifndef ECB
  16. #define ECB 1
  17. #endif
  18. #define AES128 1
  19. //#define AES192 1
  20. //#define AES256 1
  21. #if defined(ECB) && (ECB == 1)
  22. void AES_ECB_encrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
  23. void AES_ECB_decrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
  24. #endif // #if defined(ECB) && (ECB == !)
  25. #if defined(CBC) && (CBC == 1)
  26. void AES_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  27. void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
  28. #endif // #if defined(CBC) && (CBC == 1)
  29. #endif //_AES_H_