More work on crypto.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12251 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
Giovanni Di Sirio 2018-09-08 10:05:13 +00:00
parent bbcb55cfc5
commit 2dbd855684
2 changed files with 56 additions and 16 deletions

View File

@ -35,7 +35,7 @@
/*===========================================================================*/ /*===========================================================================*/
/** @brief CRY1 driver identifier.*/ /** @brief CRY1 driver identifier.*/
#if STM32_CRY_USE_CRYP1 || defined(__DOXYGEN__) #if (STM32_CRY_ENABLED1 == TRUE) || defined(__DOXYGEN__)
CRYDriver CRYD1; CRYDriver CRYD1;
#endif #endif

View File

@ -40,37 +40,77 @@
* @{ * @{
*/ */
/** /**
* @brief CRY1 driver enable switch. * @brief CRYP1 driver enable switch.
* @details If set to @p TRUE the support for CRYP1 is included. * @details If set to @p TRUE the support for CRYP1 is included.
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(STM32_CRY_USE_CRYP1) || defined(__DOXYGEN__) #if !defined(STM32_CRY_USE_CRYP1) || defined(__DOXYGEN__)
#define STM32_CRY_USE_CRYP1 FALSE #define STM32_CRY_USE_CRYP1 FALSE
#endif #endif
/**
* @brief HASH1 driver enable switch.
* @details If set to @p TRUE the support for CRYP1 is included.
* @note The default is @p FALSE.
*/
#if !defined(STM32_CRY_USE_HASH1) || defined(__DOXYGEN__)
#define STM32_CRY_USE_HASH1 FALSE
#endif
/**
* @brief RNG1 driver enable switch.
* @details If set to @p TRUE the support for CRYP1 is included.
* @note The default is @p FALSE.
*/
#if !defined(STM32_CRY_USE_RNG1) || defined(__DOXYGEN__)
#define STM32_CRY_USE_RNG1 FALSE
#endif
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*===========================================================================*/
/* Handling cleanly incomplete registry files.*/ #if (STM32_CRY_USE_CRYP1 == TRUE) || (STM32_CRY_USE_HASH1 == TRUE) || \
#if !defined (STM32_HAS_CRYP) (STM32_CRY_USE_RNG1 == TRUE) || defined (__DOXYGEN__)
#define STM32_HAS_CRYP FALSE #define STM32_CRY_ENABLED1 TRUE
#else
#define STM32_CRY_ENABLED1 FALSE
#endif #endif
#if !defined (STM32_HAS_HASH) #if !defined (STM32_HAS_CRYP1)
#define STM32_HAS_HASH FALSE #define STM32_HAS_CRYP1 FALSE
#endif #endif
#if !defined (STM32_HAS_RNG) #if !defined (STM32_HAS_HASH1)
#define STM32_HAS_RNG FALSE #define STM32_HAS_HASH1 FALSE
#endif
#if !defined (STM32_HAS_RNG1)
#define STM32_HAS_RNG1 FALSE
#endif
#if STM32_CRY_USE_CRYP1 && !STM32_HAS_CRYP1
#error "CRYP1 not present in the selected device"
#endif
#if STM32_CRY_USE_HASH1 && !STM32_HAS_HASH1
#error "HASH1 not present in the selected device"
#endif
#if STM32_CRY_USE_RNG1 && !STM32_HAS_RNG1
#error "RNG1 not present in the selected device"
#endif
#if !STM32_CRY_ENABLED1
#error "CRY driver activated but no CRYP or HASH or RNG peripheral assigned"
#endif #endif
/** /**
* @name Driver capability switches * @name Driver capability switches
* @{ * @{
*/ */
#if STM32_HAS_CRYP || defined (__DOXYGEN__) #if STM32_CRY_USE_CRYP1 || defined (__DOXYGEN__)
#define CRY_LLD_SUPPORTS_AES TRUE #define CRY_LLD_SUPPORTS_AES TRUE
#define CRY_LLD_SUPPORTS_AES_ECB TRUE #define CRY_LLD_SUPPORTS_AES_ECB TRUE
#define CRY_LLD_SUPPORTS_AES_CBC TRUE #define CRY_LLD_SUPPORTS_AES_CBC TRUE
@ -91,7 +131,7 @@
#define CRY_LLD_SUPPORTS_DES_ECB FALSE #define CRY_LLD_SUPPORTS_DES_ECB FALSE
#define CRY_LLD_SUPPORTS_DES_CBC FALSE #define CRY_LLD_SUPPORTS_DES_CBC FALSE
#endif #endif
#if STM32_HAS_HASH || defined (__DOXYGEN__) #if STM32_CRY_USE_HASH1 || defined (__DOXYGEN__)
#define CRY_LLD_SUPPORTS_SHA1 TRUE #define CRY_LLD_SUPPORTS_SHA1 TRUE
#define CRY_LLD_SUPPORTS_SHA256 TRUE #define CRY_LLD_SUPPORTS_SHA256 TRUE
#define CRY_LLD_SUPPORTS_SHA512 TRUE #define CRY_LLD_SUPPORTS_SHA512 TRUE
@ -104,7 +144,7 @@
#define CRY_LLD_SUPPORTS_HMAC_SHA256 FALSE #define CRY_LLD_SUPPORTS_HMAC_SHA256 FALSE
#define CRY_LLD_SUPPORTS_HMAC_SHA512 FALSE #define CRY_LLD_SUPPORTS_HMAC_SHA512 FALSE
#endif #endif
#if STM32_HAS_RNG || defined (__DOXYGEN__) #if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__)
#define CRY_LLD_SUPPORTS_TRNG TRUE #define CRY_LLD_SUPPORTS_TRNG TRUE
#else #else
#define CRY_LLD_SUPPORTS_TRNG FALSE #define CRY_LLD_SUPPORTS_TRNG FALSE
@ -163,19 +203,19 @@ struct CRYDriver {
CRY_DRIVER_EXT_FIELDS CRY_DRIVER_EXT_FIELDS
#endif #endif
/* End of the mandatory fields.*/ /* End of the mandatory fields.*/
#if STM32_HAS_CRYP || defined (__DOXYGEN__) #if STM32_CRY_USE_CRYP1 || defined (__DOXYGEN__)
/** /**
* @brief Pointer to the CRYP registers block. * @brief Pointer to the CRYP registers block.
*/ */
CRYP_TypeDef *cryp; CRYP_TypeDef *cryp;
#endif #endif
#if STM32_HAS_HASH || defined (__DOXYGEN__) #if STM32_CRY_USE_HASH1 || defined (__DOXYGEN__)
/** /**
* @brief Pointer to the HASH registers block. * @brief Pointer to the HASH registers block.
*/ */
HASH_TypeDef *hash; HASH_TypeDef *hash;
#endif #endif
#if STM32_HAS_RNG || defined (__DOXYGEN__) #if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__)
/** /**
* @brief Pointer to the RNG registers block. * @brief Pointer to the RNG registers block.
*/ */
@ -236,7 +276,7 @@ typedef struct {
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
#if (STM32_CRY_USE_CRYP1 == TRUE) && !defined(__DOXYGEN__) #if (STM32_CRY_ENABLED1 == TRUE) && !defined(__DOXYGEN__)
extern CRYDriver CRYD1; extern CRYDriver CRYD1;
#endif #endif