aes.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /******************************************************************************
  2. * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. * @file aes.h
  12. *
  13. * @brief Header file for AES functions
  14. *
  15. * @author MADS Team
  16. *
  17. ******************************************************************************/
  18. #ifndef __AES_H__
  19. #define __AES_H__
  20. /******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "ddl.h"
  24. /* C binding of definitions if building with C++ compiler */
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. /**
  30. ******************************************************************************
  31. ** \defgroup AESGroup AES
  32. **
  33. ******************************************************************************/
  34. //@{
  35. /******************************************************************************
  36. * Global type definitions
  37. ******************************************************************************/
  38. /**
  39. *******************************************************************************
  40. ** \brief AES密钥长度类型定义
  41. ** \note
  42. ******************************************************************************/
  43. typedef enum en_aes_key_type
  44. {
  45. AesKey128 = 0u, ///< 128 bits
  46. AesKey192 = 1u, ///< 192 bits
  47. AesKey256 = 2u, ///< 256 bits
  48. }en_aes_key_type_t;
  49. /**
  50. *******************************************************************************
  51. ** \brief AES配置结构体
  52. ** \note
  53. ******************************************************************************/
  54. typedef struct
  55. {
  56. uint32_t* pu32Cipher; ///< AES 密文指针
  57. uint32_t* pu32Plaintext; ///< AES 明文指针
  58. uint32_t* pu32Key; ///< AES 密钥指针
  59. en_aes_key_type_t enKeyLen; ///< AES 密钥长度类型
  60. }stc_aes_cfg_t;
  61. /******************************************************************************
  62. * Global definitions
  63. ******************************************************************************/
  64. /******************************************************************************
  65. * Local type definitions ('typedef')
  66. ******************************************************************************/
  67. /******************************************************************************
  68. * Global variable definitions ('extern')
  69. ******************************************************************************/
  70. /******************************************************************************
  71. * Global function prototypes (definition in C source)
  72. ******************************************************************************/
  73. //AES 加密
  74. en_result_t AES_Encrypt(stc_aes_cfg_t* pstcAesCfg);
  75. //AES 解密
  76. en_result_t AES_Decrypt(stc_aes_cfg_t* pstcAesCfg);
  77. //@} // AES Group
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif /* __AES_H__ */
  82. /******************************************************************************
  83. * EOF (not truncated)
  84. ******************************************************************************/