aes.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. ROM functions for hardware AES support.
  3. It is not recommended to use these functions directly,
  4. use the wrapper functions in hwcrypto/aes.h instead.
  5. */
  6. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  7. //
  8. // Licensed under the Apache License, Version 2.0 (the "License");
  9. // you may not use this file except in compliance with the License.
  10. // You may obtain a copy of the License at
  11. // http://www.apache.org/licenses/LICENSE-2.0
  12. //
  13. // Unless required by applicable law or agreed to in writing, software
  14. // distributed under the License is distributed on an "AS IS" BASIS,
  15. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. // See the License for the specific language governing permissions and
  17. // limitations under the License.
  18. #pragma once
  19. #include <stdint.h>
  20. #include <stdbool.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #define AES_BLOCK_SIZE 16
  25. enum AES_TYPE {
  26. AES_ENC,
  27. AES_DEC,
  28. };
  29. enum AES_BITS {
  30. AES128,
  31. AES192,
  32. AES256
  33. };
  34. void ets_aes_enable(void);
  35. void ets_aes_disable(void);
  36. void ets_aes_set_endian(bool key_word_swap, bool key_byte_swap,
  37. bool in_word_swap, bool in_byte_swap,
  38. bool out_word_swap, bool out_byte_swap);
  39. int ets_aes_setkey(enum AES_TYPE type, const void *key, enum AES_BITS bits);
  40. int ets_aes_setkey_enc(const void *key, enum AES_BITS bits);
  41. int ets_aes_setkey_dec(const void *key, enum AES_BITS bits);
  42. void ets_aes_block(const void *input, void *output);
  43. #ifdef __cplusplus
  44. }
  45. #endif