stm8l15x_aes.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. ********************************************************************************
  3. * @file stm8l15x_aes.h
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief This file contains all the functions prototypes for the AES firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM8L15x_AES_H
  30. #define __STM8L15x_AES_H
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm8l15x.h"
  33. /** @addtogroup STM8L15x_StdPeriph_Driver
  34. * @{
  35. */
  36. /** @addtogroup AES
  37. * @{
  38. */
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @defgroup AES_Exported_Types
  41. * @{
  42. */
  43. /** @defgroup AES_Operation_Mode
  44. * @{
  45. */
  46. typedef enum
  47. {
  48. AES_Operation_Encryp = (uint8_t)0x00, /*!< AES in Encryption mode */
  49. AES_Operation_KeyDeriv = (uint8_t)0x02, /*!< AES in Key Derivation mode */
  50. AES_Operation_Decryp = (uint8_t)0x04, /*!< AES in Decryption mode */
  51. AES_Operation_KeyDerivAndDecryp = (uint8_t)0x06 /*!< AES in Key Derivation and Decryption mode */
  52. } AES_Operation_TypeDef;
  53. #define IS_AES_MODE(Operation) (((Operation) == AES_Operation_Encryp) || \
  54. ((Operation) == AES_Operation_KeyDeriv) || \
  55. ((Operation) == AES_Operation_Decryp) || \
  56. ((Operation) == AES_Operation_KeyDerivAndDecryp))
  57. /**
  58. * @}
  59. */
  60. /** @defgroup AES_Flags
  61. * @{
  62. */
  63. typedef enum
  64. {
  65. AES_FLAG_CCF = (uint8_t)0x01, /*!< Computation Complete Flag */
  66. AES_FLAG_RDERR = (uint8_t)0x02, /*!< Read Error Flag */
  67. AES_FLAG_WRERR = (uint8_t)0x04 /*!< Write Error Flag */
  68. }AES_FLAG_TypeDef;
  69. #define IS_AES_FLAG(Flag) (((Flag) == AES_FLAG_CCF) || \
  70. ((Flag) == AES_FLAG_RDERR) || \
  71. ((Flag) == AES_FLAG_WRERR))
  72. /**
  73. * @}
  74. */
  75. /** @defgroup AES_Interrupts
  76. * @{
  77. */
  78. typedef enum
  79. {
  80. AES_IT_CCIE = (uint16_t)0x20, /*!< Computation Complete interrupt enable */
  81. AES_IT_ERRIE = (uint16_t)0x40 /*!< Error interrupt enable */
  82. }AES_IT_TypeDef;
  83. #define IS_AES_IT(IT) (((IT) == AES_IT_CCIE) || \
  84. ((IT) == AES_IT_ERRIE))
  85. /**
  86. * @}
  87. */
  88. /** @defgroup AES_DMA_Transfer_Direction
  89. * @{
  90. */
  91. typedef enum
  92. {
  93. AES_DMATransfer_InOut = (uint8_t) 0x80 /*!< DMA requests enabled for input transfer phase
  94. as well as for the output transfer phase */
  95. }
  96. AES_DMATransfer_TypeDef;
  97. #define IS_AES_DMATRANSFER(Transfer) ((Transfer) == AES_DMATransfer_InOut)
  98. /**
  99. * @}
  100. */
  101. /**
  102. * @}
  103. */
  104. /* Exported constants --------------------------------------------------------*/
  105. /* Exported macros -----------------------------------------------------------*/
  106. /* Exported functions ------------------------------------------------------- */
  107. /* Function used to set the AES configuration to the default reset state *****/
  108. void AES_DeInit(void);
  109. /* AES Configuration **********************************************************/
  110. void AES_OperationModeConfig(AES_Operation_TypeDef AES_Operation);
  111. void AES_Cmd(FunctionalState NewState);
  112. /* AES Read and Write operations **********************************************/
  113. void AES_WriteSubData(uint8_t Data);
  114. void AES_WriteSubKey(uint8_t Key);
  115. uint8_t AES_ReadSubData(void);
  116. uint8_t AES_ReadSubKey(void);
  117. /* DMA transfers management function ******************************************/
  118. void AES_DMAConfig(AES_DMATransfer_TypeDef AES_DMATransfer, FunctionalState NewState);
  119. /* Interrupts and flags management functions **********************************/
  120. void AES_ITConfig(AES_IT_TypeDef AES_IT, FunctionalState NewState);
  121. FlagStatus AES_GetFlagStatus(AES_FLAG_TypeDef AES_FLAG);
  122. void AES_ClearFlag(AES_FLAG_TypeDef AES_FLAG);
  123. ITStatus AES_GetITStatus(AES_IT_TypeDef AES_IT);
  124. void AES_ClearITPendingBit(AES_IT_TypeDef AES_IT);
  125. #endif /* __STM8L15x_AES_H */
  126. /**
  127. * @}
  128. */
  129. /**
  130. * @}
  131. */
  132. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/