Add optional parameter validation to the AES module
This adds additional and optional parameter validation to the AES module that can be used by enabling the MBEDTLS_CHECK_PARAMS config.h option.
This commit is contained in:
parent
b4868034dd
commit
5201e414aa
2 changed files with 38 additions and 8 deletions
|
@ -67,6 +67,26 @@
|
|||
/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
|
||||
#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
|
||||
|
||||
#if defined( MBEDTLS_CHECK_PARAMS )
|
||||
#define MBEDTLS_AES_VALIDATE_RET( cond ) do{ if( !(cond) ) { \
|
||||
MBEDTLS_PARAM_FAILED( #cond, \
|
||||
__FILE__, \
|
||||
__LINE__ ); \
|
||||
return MBEDTLS_ERR_AES_BAD_INPUT_DATA;} \
|
||||
} while(0);
|
||||
|
||||
#define MBEDTLS_AES_VALIDATE( cond ) do{ if( !(cond) ) { \
|
||||
MBEDTLS_PARAM_FAILED( #cond, \
|
||||
__FILE__, \
|
||||
__LINE__ ); \
|
||||
return; } \
|
||||
} while(0);
|
||||
#else
|
||||
/* No validation of parameters will be performed */
|
||||
#define MBEDTLS_AES_VALIDATE_RET( cond )
|
||||
#define MBEDTLS_AES_VALIDATE( cond)
|
||||
#endif
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue