From ad0f9349ae74976f054fc0aba35c0ec82c2837c8 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 13 Jun 2018 08:17:40 +0000 Subject: Added more conditionals to CRY driver. Removed conditionals from high level functions, those functions are not meant to be excluded. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12092 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/src/hal_crypto.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 4 deletions(-) (limited to 'os/hal/src') diff --git a/os/hal/src/hal_crypto.c b/os/hal/src/hal_crypto.c index 25e3aa553..f49987878 100644 --- a/os/hal/src/hal_crypto.c +++ b/os/hal/src/hal_crypto.c @@ -193,6 +193,8 @@ cryerror_t cryLoadTransientKey(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @special */ @@ -237,6 +239,8 @@ cryerror_t cryEncryptAES(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @special */ @@ -284,6 +288,8 @@ cryerror_t cryDecryptAES(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -334,6 +340,8 @@ cryerror_t cryEncryptAES_ECB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -385,6 +393,8 @@ cryerror_t cryDecryptAES_ECB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -438,6 +448,8 @@ cryerror_t cryEncryptAES_CBC(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -491,6 +503,8 @@ cryerror_t cryDecryptAES_CBC(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -544,6 +558,8 @@ cryerror_t cryEncryptAES_CFB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -598,6 +614,8 @@ cryerror_t cryDecryptAES_CFB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -652,6 +670,8 @@ cryerror_t cryEncryptAES_CTR(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -711,6 +731,8 @@ cryerror_t cryDecryptAES_CTR(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -780,6 +802,8 @@ cryerror_t cryEncryptAES_GCM(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -839,6 +863,8 @@ cryerror_t cryDecryptAES_GCM(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @special */ @@ -884,6 +910,8 @@ cryerror_t cryEncryptDES(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @special */ @@ -931,6 +959,8 @@ cryerror_t cryDecryptDES(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -981,6 +1011,8 @@ cryerror_t cryEncryptDES_ECB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -1032,6 +1064,8 @@ cryerror_t cryDecryptDES_ECB(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -1085,6 +1119,8 @@ cryerror_t cryEncryptDES_CBC(CRYDriver *cryp, * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid * or refers to an empty key slot. + * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation + * dependent. * * @api */ @@ -1126,6 +1162,8 @@ cryerror_t cryDecryptDES_CBC(CRYDriver *cryp, * @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. * * @api */ @@ -1159,6 +1197,8 @@ cryerror_t crySHA1Init(CRYDriver *cryp, SHA1Context *sha1ctxp) { * @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. * * @api */ @@ -1194,6 +1234,8 @@ cryerror_t crySHA1Update(CRYDriver *cryp, SHA1Context *sha1ctxp, * @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. * * @api */ @@ -1226,6 +1268,8 @@ cryerror_t crySHA1Final(CRYDriver *cryp, SHA1Context *sha1ctxp, uint8_t *out) { * @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. * * @api */ @@ -1259,6 +1303,8 @@ cryerror_t crySHA256Init(CRYDriver *cryp, SHA256Context *sha256ctxp) { * @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. * * @api */ @@ -1294,6 +1340,8 @@ cryerror_t crySHA256Update(CRYDriver *cryp, SHA256Context *sha256ctxp, * @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. * * @api */ @@ -1327,6 +1375,8 @@ cryerror_t crySHA256Final(CRYDriver *cryp, SHA256Context *sha256ctxp, * @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. * * @api */ @@ -1360,6 +1410,8 @@ cryerror_t crySHA512Init(CRYDriver *cryp, SHA512Context *sha512ctxp) { * @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. * * @api */ @@ -1395,6 +1447,8 @@ cryerror_t crySHA512Update(CRYDriver *cryp, SHA512Context *sha512ctxp, * @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. * * @api */ @@ -1418,7 +1472,6 @@ cryerror_t crySHA512Final(CRYDriver *cryp, SHA512Context *sha512ctxp, #endif } -#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. @@ -1430,6 +1483,8 @@ cryerror_t crySHA512Final(CRYDriver *cryp, SHA512Context *sha512ctxp, * @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. * * @api */ @@ -1464,6 +1519,8 @@ cryerror_t cryHMACSHA256Init(CRYDriver *cryp, * @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. * * @api */ @@ -1501,6 +1558,8 @@ cryerror_t cryHMACSHA256Update(CRYDriver *cryp, * @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. * * @api */ @@ -1524,9 +1583,7 @@ cryerror_t cryHMACSHA256Final(CRYDriver *cryp, return CRY_ERR_INV_ALGO; #endif } -#endif /* CRY_LLD_SUPPORTS_HMAC_SHA256 */ -#if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__) /** * @brief Hash initialization using HMAC_SHA512. * @note Use of this algorithm is not recommended because proven weak. @@ -1538,6 +1595,8 @@ cryerror_t cryHMACSHA256Final(CRYDriver *cryp, * @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. * * @api */ @@ -1572,6 +1631,8 @@ cryerror_t cryHMACSHA512Init(CRYDriver *cryp, * @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. * * @api */ @@ -1609,6 +1670,8 @@ cryerror_t cryHMACSHA512Update(CRYDriver *cryp, * @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. * * @api */ @@ -1632,7 +1695,6 @@ cryerror_t cryHMACSHA512Final(CRYDriver *cryp, return CRY_ERR_INV_ALGO; #endif } -#endif /* CRY_LLD_SUPPORTS_HMAC_SHA256 */ /** * @brief True random numbers generator. @@ -1643,6 +1705,8 @@ cryerror_t cryHMACSHA512Final(CRYDriver *cryp, * @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. * * @api */ -- cgit v1.2.3