From 282f50256531ffee5f9f5baf8d275fb64464769d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 19 Dec 2018 11:26:37 +0000 Subject: Crypto driver changes, removed TRNG. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12477 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c | 64 -------------------------- os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h | 52 ++++++++++----------- 2 files changed, 26 insertions(+), 90 deletions(-) (limited to 'os/hal/ports/STM32/LLD/CRYPv1') 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 5c02434e3..60a1f88f2 100644 --- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c +++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c @@ -70,9 +70,6 @@ void cry_lld_init(void) { #if STM32_CRY_USE_HASH1 CRYD1.hash = HASH; #endif -#if STM32_CRY_USE_RNG1 - CRYD1.rng = RNG; -#endif #endif } @@ -93,9 +90,6 @@ void cry_lld_start(CRYDriver *cryp) { #endif #if STM32_CRY_USE_HASH1 rccEnableHASH(true); -#endif -#if STM32_CRY_USE_RNG1 - rccEnableRNG(true); #endif } #endif @@ -107,9 +101,6 @@ void cry_lld_start(CRYDriver *cryp) { #if STM32_CRY_USE_HASH1 /* HASH setup and enable.*/ #endif -#if STM32_CRY_USE_RNG1 - /* RNG setup and enable.*/ -#endif } /** @@ -123,29 +114,6 @@ void cry_lld_stop(CRYDriver *cryp) { if (cryp->state == CRY_READY) { -#if STM32_CRY_USE_CRYP1 - /* CRYP disable.*/ -#endif -#if STM32_CRY_USE_HASH1 - /* HASH disable.*/ -#endif -#if STM32_CRY_USE_RNG1 - /* RNG disable.*/ -#endif - -#if STM32_CRY_ENABLED1 - if (&CRYD1 == cryp) { -#if STM32_CRY_USE_CRYP1 - rccDisableCRYP(); -#endif -#if STM32_CRY_USE_HASH1 - rccDisableHASH(); -#endif -#if STM32_CRY_USE_RNG1 - rccDisableRNG(); -#endif - } -#endif } } @@ -1201,7 +1169,6 @@ cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp, #if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__) /** * @brief Hash initialization using HMAC_SHA256. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[out] hmacsha256ctxp pointer to a HMAC_SHA256 context to be @@ -1226,7 +1193,6 @@ cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp, /** * @brief Hash update using HMAC. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context @@ -1256,7 +1222,6 @@ cryerror_t cry_lld_HMACSHA256_update(CRYDriver *cryp, /** * @brief Hash finalization using HMAC. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context @@ -1285,7 +1250,6 @@ cryerror_t cry_lld_HMACSHA256_final(CRYDriver *cryp, #if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__) /** * @brief Hash initialization using HMAC_SHA512. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[out] hmacsha512ctxp pointer to a HMAC_SHA512 context to be @@ -1310,7 +1274,6 @@ cryerror_t cry_lld_HMACSHA512_init(CRYDriver *cryp, /** * @brief Hash update using HMAC. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context @@ -1340,7 +1303,6 @@ cryerror_t cry_lld_HMACSHA512_update(CRYDriver *cryp, /** * @brief Hash finalization using HMAC. - * @note Use of this algorithm is not recommended because proven weak. * * @param[in] cryp pointer to the @p CRYDriver object * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context @@ -1366,32 +1328,6 @@ cryerror_t cry_lld_HMACSHA512_final(CRYDriver *cryp, } #endif -#if (CRY_LLD_SUPPORTS_TRNG == TRUE) || defined(__DOXYGEN__) -/** - * @brief True random numbers generator. - * - * @param[in] cryp pointer to the @p CRYDriver object - * @param[in] size size of output buffer - * @param[out] out output buffer - * @return The operation status. - * @retval CRY_NOERROR if the operation succeeded. - * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this - * device instance. - * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation - * dependent. - * - * @notapi - */ -cryerror_t cry_lld_TRNG(CRYDriver *cryp, size_t size, uint8_t *out) { - - (void)cryp; - (void)size; - (void)out; - - return CRY_ERR_INV_ALGO; -} -#endif - #endif /* HAL_USE_CRY == TRUE */ /** @} */ 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 60c50e03c..94eae3fd7 100644 --- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h +++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h @@ -56,15 +56,6 @@ #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 /** @} */ /*===========================================================================*/ @@ -144,10 +135,6 @@ #define CRY_LLD_SUPPORTS_HMAC_SHA256 FALSE #define CRY_LLD_SUPPORTS_HMAC_SHA512 FALSE #endif -#if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__) -#define CRY_LLD_SUPPORTS_TRNG TRUE -#else -#define CRY_LLD_SUPPORTS_TRNG FALSE #endif /** @} */ @@ -201,12 +188,6 @@ struct CRYDriver { */ HASH_TypeDef *hash; #endif -#if STM32_CRY_USE_RNG1 || defined (__DOXYGEN__) - /** - * @brief Pointer to the RNG registers block. - */ - RNG_TypeDef *rng; -#endif }; #if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__) @@ -272,10 +253,17 @@ extern "C" { void cry_lld_init(void); void cry_lld_start(CRYDriver *cryp); void cry_lld_stop(CRYDriver *cryp); - cryerror_t cry_lld_loadkey(CRYDriver *cryp, - cryalgorithm_t algorithm, - size_t size, - const uint8_t *keyp); +#if (CRY_LLD_SUPPORTS_AES == TRUE) || \ + (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || \ + (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || \ + (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || \ + (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || \ + (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || \ + defined(__DOXYGEN__) + cryerror_t cry_lld_aes_loadkey(CRYDriver *cryp, + size_t size, + const uint8_t *keyp); +#endif #if (CRY_LLD_SUPPORTS_AES == TRUE) || defined(__DOXYGEN__) cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp, crykey_t key_id, @@ -360,6 +348,14 @@ extern "C" { const uint8_t *aad, uint8_t *authtag); #endif +#if (CRY_LLD_SUPPORTS_DES == TRUE) || \ + (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || \ + (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || \ + defined(__DOXYGEN__) + cryerror_t cry_lld_des_loadkey(CRYDriver *cryp, + size_t size, + const uint8_t *keyp); +#endif #if (CRY_LLD_SUPPORTS_DES == TRUE) || defined(__DOXYGEN__) cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp, crykey_t key_id, @@ -417,6 +413,13 @@ extern "C" { cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp, uint8_t *out); #endif +#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || \ + (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || \ + defined(__DOXYGEN__) + cryerror_t cry_lld_hmac_loadkey(CRYDriver *cryp, + size_t size, + const uint8_t *keyp); +#endif #if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__) cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp, HMACSHA256Context *hmacsha256ctxp); @@ -437,9 +440,6 @@ extern "C" { HMACSHA512Context *hmacsha512ctxp, uint8_t *out); #endif -#if (CRY_LLD_SUPPORTS_TRNG == TRUE) || defined(__DOXYGEN__) - cryerror_t cry_lld_TRNG(CRYDriver *cryp, size_t size, uint8_t *out); -#endif #ifdef __cplusplus } #endif -- cgit v1.2.3