1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Document AES functions and fix free() functions

This commit is contained in:
Manuel Pégourié-Gonnard
2018-12-10 16:56:14 +01:00
parent 0e9cddbf1a
commit 44c5d58d05
4 changed files with 50 additions and 12 deletions

View File

@ -173,6 +173,33 @@ typedef enum
memcpy(param_fail_jmp, jmp_tmp, sizeof(jmp_buf)); \
} while( 0 )
/**
* \brief This macro tests the statement passed to it as a test step or
* individual test in a test case. The macro assumes the test will not fail.
*
* It assumes the library function under test cannot return a value and
* assumes errors can only be indicated by calls to
* MBEDTLS_PARAM_FAILED().
*
* When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
* callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the
* expected failure. If MBEDTLS_CHECK_PARAMS is not enabled, no test
* can be made.
*
* This macro is intended to test that function that return void
* accept all of the parameter values they're supposed to accept - eg
* that they don't call MBEDTLS_PARAM_FAILED() when a parameter
* that's allowed to be NULL happends to be NULL.
*
* Note: for functions that return something other that void,
* checking that they accept all the parameters they're supposed to
* accept is best done by using TEST_ASSERT() and checking the return
* value as well.
*
* \param TEST The test expression to be tested.
*/
#define TEST_VALID_PARAM( TEST ) \
TEST_ASSERT( ( TEST, 1 ) );
#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED_ALT */
#define assert(a) if( !( a ) ) \

View File

@ -379,6 +379,8 @@ void aes_invalid_param( )
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
/* mbedtls_aes_setkey_enc() */
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
mbedtls_aes_setkey_enc( NULL, key, 128 ) );
@ -393,6 +395,10 @@ void aes_invalid_param( )
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
mbedtls_aes_setkey_dec( &dummy_ctx, NULL, 128 ) );
/* These calls accept NULL */
TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
TEST_VALID_PARAM( mbedtls_aes_xts_free( NULL ) );
exit:
return;
}