se.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2020 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file security engine for Actions SoC
  8. */
  9. #ifndef SE_H_
  10. #define SE_H_
  11. #include <kernel.h>
  12. #define CPY_MEM_TO_FIFO 0
  13. #define CPY_FIFO_TO_MEM 1
  14. #define CPY_MEM_TO_MEM 2
  15. #define CPY_MEMU8_TO_FIFO 3
  16. /* AES Macro */
  17. #define AES_MODE_ECB 0
  18. #define AES_MODE_CTR 1
  19. #define AES_MODE_CBC 2
  20. #define AES_MODE_CBC_CTS 3
  21. #define CYPHER_ENCRYPT 1
  22. #define CYPHER_DECRYPT 0
  23. extern struct k_mutex se_lock;
  24. extern void se_memcpy(void *out, const void *in,
  25. size_t size, uint8_t direct);
  26. extern int aes_cypher(void *out, const void *in, size_t size,
  27. const void *iv, const void *key, size_t keysize,
  28. int mode, int encrypt);
  29. extern uint32_t utils_crc32(uint32_t crc, const uint8_t *ptr, int buf_len);
  30. extern uint32_t crc32_mpeg2(uint32_t inital_val, const unsigned char* ptr, unsigned int len);
  31. extern uint32_t crc32(uint32_t inital_val, const unsigned char* ptr, unsigned int len);
  32. extern uint16_t crc16_xmodem(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  33. extern uint16_t crc16_x5(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  34. extern uint16_t crc16_ccitt_false(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  35. extern uint16_t crc16_ccitt(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  36. extern uint16_t crc16_modbus(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  37. extern uint16_t crc16_usb(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  38. extern uint16_t crc16_maxim(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  39. extern uint16_t crc16_ibm(uint16_t inital_val, const unsigned char* ptr, unsigned int len);
  40. #endif /* SE_H_ */