HAL_AES.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /***********************************************************************
  2. * Copyright (c) 2008 - 2016, Shanghai AisinoChip Co.,Ltd .
  3. * All rights reserved.
  4. * Filename : aes.h
  5. * Description : aes driver header file
  6. * Author(s) : Eric
  7. * version : V1.0
  8. * Modify date : 2016-03-24
  9. ***********************************************************************/
  10. #ifndef __AES_H__
  11. #define __AES_H__
  12. #include "ACM32Fxx_HAL.h"
  13. #define AES_ENCRYPTION 1
  14. #define AES_DECRYPTION 0
  15. #define AES_ECB_MODE 0
  16. #define AES_CBC_MODE 1
  17. #define AES_SWAP_ENABLE 1
  18. #define AES_SWAP_DISABLE 0
  19. #define AES_NORMAL_MODE 0x12345678
  20. #define AES_SECURITY_MODE 0
  21. #define AES_KEY_128 0
  22. #define AES_KEY_192 1
  23. #define AES_KEY_256 2
  24. #define AES_FAIL 0x00
  25. #define AES_PASS 0xa59ada68
  26. /******************************************************************************
  27. Name: HAL_AES_Set_Key
  28. Function: set aes key for encryption and decryption
  29. Input:
  30. keyin -- pointer to buffer of key
  31. swap_en -- AES_SWAP_ENABLE, AES_SWAP_DISABLE
  32. Return: None
  33. *******************************************************************************/
  34. void HAL_AES_Set_Key(UINT32 *keyin, UINT8 key_len, UINT8 swap_en);
  35. void HAL_AES_Set_Key_U8(UINT8 *keyin, UINT8 key_len, UINT8 swap_en);
  36. /******************************************************************************
  37. Name: HAL_Aes_Crypt
  38. Function: Function for des encryption and decryption
  39. Input:
  40. indata -- pointer to buffer of input
  41. outdata -- pointer to buffer of result
  42. block_len -- block(128bit) length for des cryption
  43. operation -- AES_ENCRYPTION,AES_DECRYPTION
  44. mode -- AES_ECB_MODE, AES_CBC_MODE,
  45. iv -- initial vector for CBC mode
  46. security_mode -- AES_NORMAL_MODE, AES_SECURITY_MDOE,
  47. Return: None
  48. *******************************************************************************/
  49. UINT32 HAL_AES_Crypt(
  50. UINT32 *indata,
  51. UINT32 *outdata,
  52. UINT32 block_len,
  53. UINT8 operation,
  54. UINT8 mode,
  55. UINT32 *iv,
  56. UINT32 security_mode
  57. );
  58. UINT32 HAL_AES_Crypt_U8(
  59. UINT8 *indata,
  60. UINT8 *outdata,
  61. UINT32 block_len,
  62. UINT8 operation,
  63. UINT8 mode,
  64. UINT8 *iv,
  65. UINT32 security_mode
  66. );
  67. #endif
  68. /******************************************************************************
  69. * end of file
  70. *******************************************************************************/