From 2dbd855684b925c7a57982d883abcc9e0ecec10c Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 8 Sep 2018 10:05:13 +0000 Subject: More work on crypto. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12251 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c | 2 +- os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h | 70 ++++++++++++++++++++------ 2 files changed, 56 insertions(+), 16 deletions(-) (limited to 'os/hal') diff --git a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c index 743608ed2..c9ca9858b 100644 --- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c +++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c @@ -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 diff --git a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h index 607ac8cb3..b66be5e29 100644 --- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h +++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h @@ -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_CRYP1) +#define STM32_HAS_CRYP1 FALSE +#endif + +#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 !defined (STM32_HAS_HASH) -#define STM32_HAS_HASH FALSE +#if STM32_CRY_USE_RNG1 && !STM32_HAS_RNG1 +#error "RNG1 not present in the selected device" #endif -#if !defined (STM32_HAS_RNG) -#define STM32_HAS_RNG FALSE +#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 -- cgit v1.2.3