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.*/
#if STM32_CRY_USE_CRYP1 || defined(__DOXYGEN__)
#if (STM32_CRY_ENABLED1 == TRUE) || defined(__DOXYGEN__)
CRYDriver CRYD1;
#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.
* @note The default is @p FALSE.
*/
#if !defined(STM32_CRY_USE_CRYP1) || defined(__DOXYGEN__)
#define STM32_CRY_USE_CRYP1 FALSE
#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. */
/*===========================================================================*/
/* Handling cleanly incomplete registry files.*/
#if !defined (STM32_HAS_CRYP)
#define STM32_HAS_CRYP FALSE
#if (STM32_CRY_USE_CRYP1 == TRUE) || (STM32_CRY_USE_HASH1 == TRUE) || \
(STM32_CRY_USE_RNG1 == TRUE) || defined (__DOXYGEN__)
#define STM32_CRY_ENABLED1 TRUE
#else
#define STM32_CRY_ENABLED1 FALSE
#endif
#if !defined (STM32_HAS_HASH)
#define STM32_HAS_HASH FALSE
#if !defined (STM32_HAS_CRYP1)
#define STM32_HAS_CRYP1 FALSE
#endif
#if !defined (STM32_HAS_RNG)
#define STM32_HAS_RNG FALSE
#if !defined (STM32_HAS_HASH1)
#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
/**
* @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_ECB TRUE
#define CRY_LLD_SUPPORTS_AES_CBC TRUE
@ -91,7 +131,7 @@
#define CRY_LLD_SUPPORTS_DES_ECB FALSE
#define CRY_LLD_SUPPORTS_DES_CBC FALSE
#endif
#if STM32_HAS_HASH || defined (__DOXYGEN__)
#if STM32_CRY_USE_HASH1 || defined (__DOXYGEN__)
#define CRY_LLD_SUPPORTS_SHA1 TRUE
#define CRY_LLD_SUPPORTS_SHA256 TRUE
#define CRY_LLD_SUPPORTS_SHA512 TRUE
@ -104,7 +144,7 @@
#define CRY_LLD_SUPPORTS_HMAC_SHA256 FALSE
#define CRY_LLD_SUPPORTS_HMAC_SHA512 FALSE
#endif
#if STM32_HAS_RNG || defined (__DOXYGEN__)
#if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__)
#define CRY_LLD_SUPPORTS_TRNG TRUE
#else
#define CRY_LLD_SUPPORTS_TRNG FALSE
@ -163,19 +203,19 @@ struct CRYDriver {
CRY_DRIVER_EXT_FIELDS
#endif
/* 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.
*/
CRYP_TypeDef *cryp;
#endif
#if STM32_HAS_HASH || defined (__DOXYGEN__)
#if STM32_CRY_USE_HASH1 || defined (__DOXYGEN__)
/**
* @brief Pointer to the HASH registers block.
*/
HASH_TypeDef *hash;
#endif
#if STM32_HAS_RNG || defined (__DOXYGEN__)
#if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__)
/**
* @brief Pointer to the RNG registers block.
*/
@ -236,7 +276,7 @@ typedef struct {
/* External declarations. */
/*===========================================================================*/
#if (STM32_CRY_USE_CRYP1 == TRUE) && !defined(__DOXYGEN__)
#if (STM32_CRY_ENABLED1 == TRUE) && !defined(__DOXYGEN__)
extern CRYDriver CRYD1;
#endif