mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Merge pull request #4516 from TRodziewicz/Remove__CHECK_PARAMS_option
Remove MBEDTLS_CHECK_PARAMS option
This commit is contained in:
commit
dacd044938
4
ChangeLog.d/issue4313.txt
Normal file
4
ChangeLog.d/issue4313.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Removals
|
||||
* Remove the following macros: MBEDTLS_CHECK_PARAMS,
|
||||
MBEDTLS_CHECK_PARAMS_ASSERT, MBEDTLS_PARAM_FAILED,
|
||||
MBEDTLS_PARAM_FAILED_ALT. Fixes #4313.
|
@ -0,0 +1,33 @@
|
||||
Remove MBEDTLS_CHECK_PARAMS option
|
||||
----------------------------------
|
||||
|
||||
This change does not affect users who use the default configuration; it only
|
||||
affects users who enabled that option.
|
||||
|
||||
The option `MBEDTLS_CHECK_PARAMS` (disabled by default) enabled certain kinds
|
||||
of “parameter validation”. It covered two kinds of validations:
|
||||
|
||||
- In some functions that require a valid pointer, “parameter validation” checks
|
||||
that the pointer is non-null. With the feature disabled, a null pointer is not
|
||||
treated differently from any other invalid pointer, and typically leads to a
|
||||
runtime crash. 90% of the uses of the feature are of this kind.
|
||||
- In some functions that take an enum-like argument, “parameter validation”
|
||||
checks that the value is a valid one. With the feature disabled, an invalid
|
||||
value causes a silent default to one of the valid values.
|
||||
|
||||
The default reaction to a failed check was to call a function
|
||||
`mbedtls_param_failed()` which the application had to provide. If this function
|
||||
returned, its caller returned an error `MBEDTLS_ERR_xxx_BAD_INPUT_DATA`.
|
||||
|
||||
This feature was only used in some classic (non-PSA) cryptography modules. It was
|
||||
not used in X.509, TLS or in PSA crypto, and it was not implemented in all
|
||||
classic crypto modules.
|
||||
|
||||
This feature has been removed. The library no longer checks for NULL pointers;
|
||||
checks for enum-like arguments will be kept or re-introduced on a case-by-case
|
||||
basis, but their presence will no longer be dependent on a compile-time option.
|
||||
|
||||
Validation of enum-like values is somewhat useful, but not extremely important,
|
||||
because the parameters concerned are usually constants in applications.
|
||||
|
||||
For more information see issue #4313.
|
@ -826,6 +826,10 @@
|
||||
#error "MBEDTLS_SSL_PROTO_TLS1_1 (TLS v1.1 support) was removed in Mbed TLS 3.0. See https://github.com/ARMmbed/mbedtls/issues/4286"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS) //no-check-names
|
||||
#error "MBEDTLS_CHECK_PARAMS was removed in Mbed TLS 3.0. See https://github.com/ARMmbed/mbedtls/issues/4313"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY) //no-check-names
|
||||
#error "MBEDTLS_SSL_CID_PADDING_GRANULARITY was removed in Mbed TLS 3.0. See https://github.com/ARMmbed/mbedtls/issues/4335"
|
||||
#endif
|
||||
|
@ -255,72 +255,6 @@
|
||||
*/
|
||||
//#define MBEDTLS_DEPRECATED_REMOVED
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CHECK_PARAMS
|
||||
*
|
||||
* This configuration option controls whether the library validates more of
|
||||
* the parameters passed to it.
|
||||
*
|
||||
* When this flag is not defined, the library only attempts to validate an
|
||||
* input parameter if: (1) they may come from the outside world (such as the
|
||||
* network, the filesystem, etc.) or (2) not validating them could result in
|
||||
* internal memory errors such as overflowing a buffer controlled by the
|
||||
* library. On the other hand, it doesn't attempt to validate parameters whose
|
||||
* values are fully controlled by the application (such as pointers).
|
||||
*
|
||||
* When this flag is defined, the library additionally attempts to validate
|
||||
* parameters that are fully controlled by the application, and should always
|
||||
* be valid if the application code is fully correct and trusted.
|
||||
*
|
||||
* For example, when a function accepts as input a pointer to a buffer that may
|
||||
* contain untrusted data, and its documentation mentions that this pointer
|
||||
* must not be NULL:
|
||||
* - The pointer is checked to be non-NULL only if this option is enabled.
|
||||
* - The content of the buffer is always validated.
|
||||
*
|
||||
* When this flag is defined, if a library function receives a parameter that
|
||||
* is invalid:
|
||||
* 1. The function will invoke the macro MBEDTLS_PARAM_FAILED().
|
||||
* 2. If MBEDTLS_PARAM_FAILED() did not terminate the program, the function
|
||||
* will immediately return. If the function returns an Mbed TLS error code,
|
||||
* the error code in this case is MBEDTLS_ERR_xxx_BAD_INPUT_DATA.
|
||||
*
|
||||
* When defining this flag, you also need to arrange a definition for
|
||||
* MBEDTLS_PARAM_FAILED(). You can do this by any of the following methods:
|
||||
* - By default, the library defines MBEDTLS_PARAM_FAILED() to call a
|
||||
* function mbedtls_param_failed(), but the library does not define this
|
||||
* function. If you do not make any other arrangements, you must provide
|
||||
* the function mbedtls_param_failed() in your application.
|
||||
* See `platform_util.h` for its prototype.
|
||||
* - If you enable the macro #MBEDTLS_CHECK_PARAMS_ASSERT, then the
|
||||
* library defines MBEDTLS_PARAM_FAILED(\c cond) to be `assert(cond)`.
|
||||
* You can still supply an alternative definition of
|
||||
* MBEDTLS_PARAM_FAILED(), which may call `assert`.
|
||||
* - If you define a macro MBEDTLS_PARAM_FAILED() before including `config.h`
|
||||
* or you uncomment the definition of MBEDTLS_PARAM_FAILED() in `config.h`,
|
||||
* the library will call the macro that you defined and will not supply
|
||||
* its own version. Note that if MBEDTLS_PARAM_FAILED() calls `assert`,
|
||||
* you need to enable #MBEDTLS_CHECK_PARAMS_ASSERT so that library source
|
||||
* files include `<assert.h>`.
|
||||
*
|
||||
* Uncomment to enable validation of application-controlled parameters.
|
||||
*/
|
||||
//#define MBEDTLS_CHECK_PARAMS
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CHECK_PARAMS_ASSERT
|
||||
*
|
||||
* Allow MBEDTLS_PARAM_FAILED() to call `assert`, and make it default to
|
||||
* `assert`. This macro is only used if #MBEDTLS_CHECK_PARAMS is defined.
|
||||
*
|
||||
* If this macro is not defined, then MBEDTLS_PARAM_FAILED() defaults to
|
||||
* calling a function mbedtls_param_failed(). See the documentation of
|
||||
* #MBEDTLS_CHECK_PARAMS for details.
|
||||
*
|
||||
* Uncomment to allow MBEDTLS_PARAM_FAILED() to call `assert`.
|
||||
*/
|
||||
//#define MBEDTLS_CHECK_PARAMS_ASSERT
|
||||
|
||||
/* \} name SECTION: System support */
|
||||
|
||||
/**
|
||||
@ -3303,42 +3237,6 @@
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */
|
||||
|
||||
/**
|
||||
* \brief This macro is invoked by the library when an invalid parameter
|
||||
* is detected that is only checked with #MBEDTLS_CHECK_PARAMS
|
||||
* (see the documentation of that option for context).
|
||||
*
|
||||
* When you leave this undefined here, the library provides
|
||||
* a default definition. If the macro #MBEDTLS_CHECK_PARAMS_ASSERT
|
||||
* is defined, the default definition is `assert(cond)`,
|
||||
* otherwise the default definition calls a function
|
||||
* mbedtls_param_failed(). This function is declared in
|
||||
* `platform_util.h` for the benefit of the library, but
|
||||
* you need to define in your application.
|
||||
*
|
||||
* When you define this here, this replaces the default
|
||||
* definition in platform_util.h (which no longer declares the
|
||||
* function mbedtls_param_failed()) and it is your responsibility
|
||||
* to make sure this macro expands to something suitable (in
|
||||
* particular, that all the necessary declarations are visible
|
||||
* from within the library - you can ensure that by providing
|
||||
* them in this file next to the macro definition).
|
||||
* If you define this macro to call `assert`, also define
|
||||
* #MBEDTLS_CHECK_PARAMS_ASSERT so that library source files
|
||||
* include `<assert.h>`.
|
||||
*
|
||||
* Note that you may define this macro to expand to nothing, in
|
||||
* which case you don't have to worry about declarations or
|
||||
* definitions. However, you will then be notified about invalid
|
||||
* parameters only in non-void functions, and void function will
|
||||
* just silently return early on invalid parameters, which
|
||||
* partially negates the benefits of enabling
|
||||
* #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged.
|
||||
*
|
||||
* \param cond The expression that should evaluate to true, but doesn't.
|
||||
*/
|
||||
//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond )
|
||||
|
||||
/* PSA options */
|
||||
/**
|
||||
* Use HMAC_DRBG with the specified hash algorithm for HMAC_DRBG for the
|
||||
|
@ -39,78 +39,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
|
||||
/* Allow the user to define MBEDTLS_PARAM_FAILED to something like assert
|
||||
* (which is what our config.h suggests). */
|
||||
#include <assert.h>
|
||||
#endif /* MBEDTLS_CHECK_PARAMS_ASSERT */
|
||||
|
||||
#if defined(MBEDTLS_PARAM_FAILED)
|
||||
/** An alternative definition of MBEDTLS_PARAM_FAILED has been set in config.h.
|
||||
*
|
||||
* This flag can be used to check whether it is safe to assume that
|
||||
* MBEDTLS_PARAM_FAILED() will expand to a call to mbedtls_param_failed().
|
||||
*/
|
||||
#define MBEDTLS_PARAM_FAILED_ALT
|
||||
|
||||
#elif defined(MBEDTLS_CHECK_PARAMS_ASSERT)
|
||||
#define MBEDTLS_PARAM_FAILED( cond ) assert( cond )
|
||||
#define MBEDTLS_PARAM_FAILED_ALT
|
||||
|
||||
#else /* MBEDTLS_PARAM_FAILED */
|
||||
#define MBEDTLS_PARAM_FAILED( cond ) \
|
||||
mbedtls_param_failed( #cond, __FILE__, __LINE__ )
|
||||
|
||||
/**
|
||||
* \brief User supplied callback function for parameter validation failure.
|
||||
* See #MBEDTLS_CHECK_PARAMS for context.
|
||||
*
|
||||
* This function will be called unless an alternative treatement
|
||||
* is defined through the #MBEDTLS_PARAM_FAILED macro.
|
||||
*
|
||||
* This function can return, and the operation will be aborted, or
|
||||
* alternatively, through use of setjmp()/longjmp() can resume
|
||||
* execution in the application code.
|
||||
*
|
||||
* \param failure_condition The assertion that didn't hold.
|
||||
* \param file The file where the assertion failed.
|
||||
* \param line The line in the file where the assertion failed.
|
||||
*/
|
||||
void mbedtls_param_failed( const char *failure_condition,
|
||||
const char *file,
|
||||
int line );
|
||||
#endif /* MBEDTLS_PARAM_FAILED */
|
||||
|
||||
/* Internal macro meant to be called only from within the library. */
|
||||
#define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \
|
||||
do { \
|
||||
if( !(cond) ) \
|
||||
{ \
|
||||
MBEDTLS_PARAM_FAILED( cond ); \
|
||||
return( ret ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/* Internal macro meant to be called only from within the library. */
|
||||
#define MBEDTLS_INTERNAL_VALIDATE( cond ) \
|
||||
do { \
|
||||
if( !(cond) ) \
|
||||
{ \
|
||||
MBEDTLS_PARAM_FAILED( cond ); \
|
||||
return; \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
#else /* MBEDTLS_CHECK_PARAMS */
|
||||
|
||||
/* Internal macros meant to be called only from within the library. */
|
||||
#define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 )
|
||||
#define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 )
|
||||
|
||||
#endif /* MBEDTLS_CHECK_PARAMS */
|
||||
|
||||
/* Internal helper macros for deprecating API constants. */
|
||||
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
||||
|
@ -1019,18 +1019,8 @@ psa_status_t psa_wipe_key_slot( psa_key_slot_t *slot )
|
||||
{
|
||||
psa_status_t status = psa_remove_key_data_from_memory( slot );
|
||||
|
||||
/*
|
||||
* As the return error code may not be handled in case of multiple errors,
|
||||
* do our best to report an unexpected lock counter: if available
|
||||
* call MBEDTLS_PARAM_FAILED that may terminate execution (if called as
|
||||
* part of the execution of a test suite this will stop the test suite
|
||||
* execution).
|
||||
*/
|
||||
if( slot->lock_count != 1 )
|
||||
{
|
||||
#ifdef MBEDTLS_CHECK_PARAMS
|
||||
MBEDTLS_PARAM_FAILED( slot->lock_count == 1 );
|
||||
#endif
|
||||
status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
}
|
||||
|
||||
|
@ -409,17 +409,6 @@ psa_status_t psa_unlock_key_slot( psa_key_slot_t *slot )
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
/*
|
||||
* As the return error code may not be handled in case of multiple errors,
|
||||
* do our best to report if the lock counter is equal to zero: if
|
||||
* available call MBEDTLS_PARAM_FAILED that may terminate execution (if
|
||||
* called as part of the execution of a unit test suite this will stop the
|
||||
* test suite execution).
|
||||
*/
|
||||
#ifdef MBEDTLS_CHECK_PARAMS
|
||||
MBEDTLS_PARAM_FAILED( slot->lock_count > 0 );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_CORRUPTION_DETECTED );
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ unless( -f $config_file && -f $query_config_format_file ) {
|
||||
# throw errors.
|
||||
my @excluded = qw(
|
||||
MBEDTLS_SSL_CIPHERSUITES
|
||||
MBEDTLS_PARAM_FAILED
|
||||
);
|
||||
my $excluded_re = join '|', @excluded;
|
||||
|
||||
|
@ -175,95 +175,6 @@ unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen );
|
||||
int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
|
||||
uint32_t a_len, uint32_t b_len );
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *failure_condition;
|
||||
const char *file;
|
||||
int line;
|
||||
}
|
||||
mbedtls_test_param_failed_location_record_t;
|
||||
|
||||
/**
|
||||
* \brief Get the location record of the last call to
|
||||
* mbedtls_test_param_failed().
|
||||
*
|
||||
* \note The call expectation is set up and active until the next call to
|
||||
* mbedtls_test_param_failed_check_expected_call() or
|
||||
* mbedtls_param_failed() that cancels it.
|
||||
*/
|
||||
void mbedtls_test_param_failed_get_location_record(
|
||||
mbedtls_test_param_failed_location_record_t *location_record );
|
||||
|
||||
/**
|
||||
* \brief State that a call to mbedtls_param_failed() is expected.
|
||||
*
|
||||
* \note The call expectation is set up and active until the next call to
|
||||
* mbedtls_test_param_failed_check_expected_call() or
|
||||
* mbedtls_param_failed that cancel it.
|
||||
*/
|
||||
void mbedtls_test_param_failed_expect_call( void );
|
||||
|
||||
/**
|
||||
* \brief Check whether mbedtls_param_failed() has been called as expected.
|
||||
*
|
||||
* \note Check whether mbedtls_param_failed() has been called between the
|
||||
* last call to mbedtls_test_param_failed_expect_call() and the call
|
||||
* to this function.
|
||||
*
|
||||
* \return \c 0 Since the last call to mbedtls_param_failed_expect_call(),
|
||||
* mbedtls_param_failed() has been called.
|
||||
* \c -1 Otherwise.
|
||||
*/
|
||||
int mbedtls_test_param_failed_check_expected_call( void );
|
||||
|
||||
/**
|
||||
* \brief Get the address of the object of type jmp_buf holding the execution
|
||||
* state information used by mbedtls_param_failed() to do a long jump.
|
||||
*
|
||||
* \note If a call to mbedtls_param_failed() is not expected in the sense
|
||||
* that there is no call to mbedtls_test_param_failed_expect_call()
|
||||
* preceding it, then mbedtls_param_failed() will try to restore the
|
||||
* execution to the state stored in the jmp_buf object whose address
|
||||
* is returned by the present function.
|
||||
*
|
||||
* \note This function is intended to provide the parameter of the
|
||||
* setjmp() function to set-up where mbedtls_param_failed() should
|
||||
* long-jump if it has to. It is foreseen to be used as:
|
||||
*
|
||||
* setjmp( mbedtls_test_param_failed_get_state_buf() ).
|
||||
*
|
||||
* \note The type of the returned value is not jmp_buf as jmp_buf is an
|
||||
* an array type (C specification) and a function cannot return an
|
||||
* array type.
|
||||
*
|
||||
* \note The type of the returned value is not jmp_buf* as then the return
|
||||
* value couldn't be used by setjmp(), as its parameter's type is
|
||||
* jmp_buf.
|
||||
*
|
||||
* \return Address of the object of type jmp_buf holding the execution state
|
||||
* information used by mbedtls_param_failed() to do a long jump.
|
||||
*/
|
||||
void* mbedtls_test_param_failed_get_state_buf( void );
|
||||
|
||||
/**
|
||||
* \brief Reset the execution state used by mbedtls_param_failed() to do a
|
||||
* long jump.
|
||||
*
|
||||
* \note If a call to mbedtls_param_failed() is not expected in the sense
|
||||
* that there is no call to mbedtls_test_param_failed_expect_call()
|
||||
* preceding it, then mbedtls_param_failed() will try to restore the
|
||||
* execution state that this function reset.
|
||||
*
|
||||
* \note It is recommended to reset the execution state when the state
|
||||
* is not relevant anymore. That way an unexpected call to
|
||||
* mbedtls_param_failed() will not trigger a long jump with
|
||||
* undefined behavior but rather a long jump that will rather fault.
|
||||
*/
|
||||
void mbedtls_test_param_failed_reset_state( void );
|
||||
#endif /* MBEDTLS_CHECK_PARAMS */
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
#include "test/fake_external_rng_for_test.h"
|
||||
#endif
|
||||
|
@ -58,13 +58,6 @@
|
||||
* It allows a library function to return a value and return an error
|
||||
* code that can be tested.
|
||||
*
|
||||
* When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
|
||||
* callback, MBEDTLS_PARAM_FAILED(), will be assumed to be a test
|
||||
* failure.
|
||||
*
|
||||
* This macro is not suitable for negative parameter validation tests,
|
||||
* as it assumes the test step will not create an error.
|
||||
*
|
||||
* Failing the test means:
|
||||
* - Mark this test case as failed.
|
||||
* - Print a message identifying the failure.
|
||||
@ -181,107 +174,6 @@
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT)
|
||||
/**
|
||||
* \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 fail
|
||||
* and will generate an error.
|
||||
*
|
||||
* It allows a library function to return a value and tests the return
|
||||
* code on return to confirm the given error code was returned.
|
||||
*
|
||||
* When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
|
||||
* callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the
|
||||
* expected failure, and the test will pass.
|
||||
*
|
||||
* This macro is intended for negative parameter validation tests,
|
||||
* where the failing function may return an error value or call
|
||||
* MBEDTLS_PARAM_FAILED() to indicate the error.
|
||||
*
|
||||
* \param PARAM_ERROR_VALUE The expected error code.
|
||||
*
|
||||
* \param TEST The test expression to be tested.
|
||||
*/
|
||||
#define TEST_INVALID_PARAM_RET( PARAM_ERR_VALUE, TEST ) \
|
||||
do { \
|
||||
mbedtls_test_param_failed_expect_call( ); \
|
||||
if( ( ( TEST ) != ( PARAM_ERR_VALUE ) ) || \
|
||||
( mbedtls_test_param_failed_check_expected_call( ) != 0 ) ) \
|
||||
{ \
|
||||
mbedtls_test_fail( #TEST, __LINE__, __FILE__ ); \
|
||||
goto exit; \
|
||||
} \
|
||||
mbedtls_test_param_failed_check_expected_call( ); \
|
||||
} 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 fail
|
||||
* and will generate an error.
|
||||
*
|
||||
* It assumes the library function under test cannot return a value and
|
||||
* assumes errors can only be indicated byt 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 for negative parameter validation tests,
|
||||
* where the failing function can only return an error by calling
|
||||
* MBEDTLS_PARAM_FAILED() to indicate the error.
|
||||
*
|
||||
* \param TEST The test expression to be tested.
|
||||
*/
|
||||
#define TEST_INVALID_PARAM( TEST ) \
|
||||
do { \
|
||||
memcpy( jmp_tmp, mbedtls_test_param_failed_get_state_buf( ), \
|
||||
sizeof( jmp_tmp ) ); \
|
||||
if( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 ) \
|
||||
{ \
|
||||
TEST; \
|
||||
mbedtls_test_fail( #TEST, __LINE__, __FILE__ ); \
|
||||
goto exit; \
|
||||
} \
|
||||
mbedtls_test_param_failed_reset_state( ); \
|
||||
} while( 0 )
|
||||
#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED_ALT */
|
||||
|
||||
/**
|
||||
* \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 functions returning 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 happens 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.
|
||||
*
|
||||
* Note: this macro is available even when #MBEDTLS_CHECK_PARAMS is
|
||||
* disabled, as it makes sense to check that the functions accept all
|
||||
* legal values even if this option is disabled - only in that case,
|
||||
* the test is more about whether the function segfaults than about
|
||||
* whether it invokes MBEDTLS_PARAM_FAILED().
|
||||
*
|
||||
* \param TEST The test expression to be tested.
|
||||
*/
|
||||
#define TEST_VALID_PARAM( TEST ) \
|
||||
TEST_ASSERT( ( TEST, 1 ) );
|
||||
|
||||
#define TEST_HELPER_ASSERT(a) if( !( a ) ) \
|
||||
{ \
|
||||
mbedtls_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \
|
||||
|
@ -1834,38 +1834,6 @@ component_build_psa_accel_key_type_rsa_public_key() {
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
|
||||
}
|
||||
|
||||
component_test_check_params_functionality () {
|
||||
msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
|
||||
scripts/config.py full # includes CHECK_PARAMS
|
||||
# Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
|
||||
scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
|
||||
make CC=gcc CFLAGS='-Werror -O1' all test
|
||||
}
|
||||
|
||||
component_test_check_params_without_platform () {
|
||||
msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
|
||||
scripts/config.py full # includes CHECK_PARAMS
|
||||
# Keep MBEDTLS_PARAM_FAILED as assert.
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
|
||||
scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_C
|
||||
make CC=gcc CFLAGS='-Werror -O1' all test
|
||||
}
|
||||
|
||||
component_test_check_params_silent () {
|
||||
msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
|
||||
scripts/config.py full # includes CHECK_PARAMS
|
||||
# Set MBEDTLS_PARAM_FAILED to nothing.
|
||||
sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
|
||||
make CC=gcc CFLAGS='-Werror -O1' all test
|
||||
}
|
||||
|
||||
component_test_no_platform () {
|
||||
# Full configuration build, without platform support, file IO and net sockets.
|
||||
# This should catch missing mbedtls_printf definitions, and by disabling file
|
||||
|
@ -19,27 +19,9 @@
|
||||
#include <test/macros.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Static global variables */
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t expected_call;
|
||||
uint8_t expected_call_happened;
|
||||
|
||||
jmp_buf state;
|
||||
|
||||
mbedtls_test_param_failed_location_record_t location_record;
|
||||
}
|
||||
param_failed_ctx_t;
|
||||
static param_failed_ctx_t param_failed_ctx;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
static mbedtls_platform_context platform_ctx;
|
||||
#endif
|
||||
@ -222,67 +204,6 @@ int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
void mbedtls_test_param_failed_get_location_record(
|
||||
mbedtls_test_param_failed_location_record_t *location_record )
|
||||
{
|
||||
*location_record = param_failed_ctx.location_record;
|
||||
}
|
||||
|
||||
void mbedtls_test_param_failed_expect_call( void )
|
||||
{
|
||||
param_failed_ctx.expected_call_happened = 0;
|
||||
param_failed_ctx.expected_call = 1;
|
||||
}
|
||||
|
||||
int mbedtls_test_param_failed_check_expected_call( void )
|
||||
{
|
||||
param_failed_ctx.expected_call = 0;
|
||||
|
||||
if( param_failed_ctx.expected_call_happened != 0 )
|
||||
return( 0 );
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
void* mbedtls_test_param_failed_get_state_buf( void )
|
||||
{
|
||||
return ¶m_failed_ctx.state;
|
||||
}
|
||||
|
||||
void mbedtls_test_param_failed_reset_state( void )
|
||||
{
|
||||
memset( param_failed_ctx.state, 0, sizeof( param_failed_ctx.state ) );
|
||||
}
|
||||
|
||||
void mbedtls_param_failed( const char *failure_condition,
|
||||
const char *file,
|
||||
int line )
|
||||
{
|
||||
/* Record the location of the failure */
|
||||
param_failed_ctx.location_record.failure_condition = failure_condition;
|
||||
param_failed_ctx.location_record.file = file;
|
||||
param_failed_ctx.location_record.line = line;
|
||||
|
||||
/* If we are testing the callback function... */
|
||||
if( param_failed_ctx.expected_call != 0 )
|
||||
{
|
||||
param_failed_ctx.expected_call = 0;
|
||||
param_failed_ctx.expected_call_happened = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ...else try a long jump. If the execution state has not been set-up
|
||||
* or reset then the long jump buffer is all zero's and the call will
|
||||
* with high probability fault, emphasizing there is something to look
|
||||
* at.
|
||||
*/
|
||||
|
||||
longjmp( param_failed_ctx.state, 1 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_CHECK_PARAMS */
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
void mbedtls_test_err_add_check( int high, int low,
|
||||
const char *file, int line )
|
||||
|
@ -28,11 +28,6 @@
|
||||
#include "mbedtls/memory_buffer_alloc.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
#include "mbedtls/platform_util.h"
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <basetsd.h>
|
||||
typedef UINT8 uint8_t;
|
||||
@ -78,10 +73,6 @@ typedef struct data_tag
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Global variables */
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
jmp_buf jmp_tmp;
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Helper flags for complex dependencies */
|
||||
|
||||
|
@ -158,50 +158,6 @@ $dispatch_code
|
||||
#line $line_no "suites/main_test.function"
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Execute the test function.
|
||||
*
|
||||
* This is a wrapper function around the test function execution
|
||||
* to allow the setjmp() call used to catch any calls to the
|
||||
* parameter failure callback, to be used. Calls to setjmp()
|
||||
* can invalidate the state of any local auto variables.
|
||||
*
|
||||
* \param fp Function pointer to the test function.
|
||||
* \param params Parameters to pass to the #TestWrapper_t wrapper function.
|
||||
*
|
||||
*/
|
||||
void execute_function_ptr(TestWrapper_t fp, void **params)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
mbedtls_test_param_failed_location_record_t location_record;
|
||||
|
||||
if ( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 )
|
||||
{
|
||||
fp( params );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unexpected parameter validation error */
|
||||
mbedtls_test_param_failed_get_location_record( &location_record );
|
||||
mbedtls_test_fail( location_record.failure_condition,
|
||||
location_record.line,
|
||||
location_record.file );
|
||||
}
|
||||
|
||||
mbedtls_test_param_failed_reset_state( );
|
||||
#else
|
||||
fp( params );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
mbedtls_test_mutex_usage_check( );
|
||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Dispatches test functions based on function index.
|
||||
*
|
||||
@ -222,7 +178,17 @@ int dispatch_test( size_t func_idx, void ** params )
|
||||
{
|
||||
fp = test_funcs[func_idx];
|
||||
if ( fp )
|
||||
execute_function_ptr(fp, params);
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif
|
||||
|
||||
fp( params );
|
||||
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
mbedtls_test_mutex_usage_check( );
|
||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||
}
|
||||
else
|
||||
ret = DISPATCH_UNSUPPORTED_SUITE;
|
||||
}
|
||||
|
@ -206,9 +206,6 @@ void aes_crypt_xts_size( int size, int retval )
|
||||
mbedtls_aes_xts_init( &ctx );
|
||||
memset( data_unit, 0x00, sizeof( data_unit ) );
|
||||
|
||||
|
||||
/* Valid pointers are passed for builds with MBEDTLS_CHECK_PARAMS, as
|
||||
* otherwise we wouldn't get to the size check we're interested in. */
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, length, data_unit, src, output ) == retval );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -359,194 +356,41 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void aes_check_params( )
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void aes_invalid_mode( )
|
||||
{
|
||||
mbedtls_aes_context aes_ctx;
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
mbedtls_aes_xts_context xts_ctx;
|
||||
#endif
|
||||
const unsigned char key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const unsigned char in[16] = { 0 };
|
||||
unsigned char out[16];
|
||||
size_t size;
|
||||
const int valid_mode = MBEDTLS_AES_ENCRYPT;
|
||||
const int invalid_mode = 42;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
|
||||
#endif
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_setkey_enc( NULL, key, 128 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_setkey_enc( &aes_ctx, NULL, 128 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_setkey_dec( NULL, key, 128 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_setkey_dec( &aes_ctx, NULL, 128 ) );
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_xts_setkey_enc( NULL, key, 128 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_xts_setkey_enc( &xts_ctx, NULL, 128 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_xts_setkey_dec( NULL, key, 128 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_xts_setkey_dec( &xts_ctx, NULL, 128 ) );
|
||||
#endif
|
||||
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ecb( NULL,
|
||||
valid_mode, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ecb( &aes_ctx,
|
||||
invalid_mode, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ecb( &aes_ctx,
|
||||
valid_mode, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ecb( &aes_ctx,
|
||||
valid_mode, in, NULL ) );
|
||||
TEST_EQUAL( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ecb( &aes_ctx, invalid_mode, in, out ) );
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( NULL,
|
||||
valid_mode, 16,
|
||||
TEST_EQUAL( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( &aes_ctx, invalid_mode, 16,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( &aes_ctx,
|
||||
invalid_mode, 16,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
out, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cbc( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
out, in, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( NULL,
|
||||
valid_mode, 16,
|
||||
mbedtls_aes_xts_context xts_ctx;
|
||||
|
||||
TEST_EQUAL( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( &xts_ctx, invalid_mode, 16,
|
||||
in, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( &xts_ctx,
|
||||
invalid_mode, 16,
|
||||
in, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( &xts_ctx,
|
||||
valid_mode, 16,
|
||||
NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( &xts_ctx,
|
||||
valid_mode, 16,
|
||||
in, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_xts( &xts_ctx,
|
||||
valid_mode, 16,
|
||||
in, in, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_XTS */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( NULL,
|
||||
valid_mode, 16,
|
||||
&size, out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx,
|
||||
invalid_mode, 16,
|
||||
&size, out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
NULL, out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
&size, NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
&size, out, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
&size, out, in, NULL ) );
|
||||
size_t size;
|
||||
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( NULL,
|
||||
valid_mode, 16,
|
||||
TEST_EQUAL( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb128( &aes_ctx, invalid_mode, 16,
|
||||
&size, out, in, out ) );
|
||||
TEST_EQUAL( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( &aes_ctx, invalid_mode, 16,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( &aes_ctx,
|
||||
invalid_mode, 16,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
out, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_cfb8( &aes_ctx,
|
||||
valid_mode, 16,
|
||||
out, in, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ofb( NULL, 16,
|
||||
&size, out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ofb( &aes_ctx, 16,
|
||||
NULL, out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ofb( &aes_ctx, 16,
|
||||
&size, NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ofb( &aes_ctx, 16,
|
||||
&size, out, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ofb( &aes_ctx, 16,
|
||||
&size, out, in, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_OFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( NULL, 16, &size, out,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( &aes_ctx, 16, NULL, out,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, NULL,
|
||||
out, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
|
||||
NULL, in, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
|
||||
out, NULL, out ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
|
||||
mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
|
||||
out, in, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -569,12 +413,6 @@ void aes_misc_params( )
|
||||
size_t size;
|
||||
#endif
|
||||
|
||||
/* These calls accept NULL */
|
||||
TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
TEST_VALID_PARAM( mbedtls_aes_xts_free( NULL ) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT,
|
||||
15,
|
||||
@ -609,6 +447,14 @@ void aes_misc_params( )
|
||||
TEST_ASSERT( mbedtls_aes_crypt_ofb( &aes_ctx, 16, &size, out, in, out )
|
||||
== MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following line needs to be added to make the code compilable
|
||||
* when all the conditions above will be not define in a specific
|
||||
* choice of features.
|
||||
*/
|
||||
TEST_ASSERT( 1 );
|
||||
/* TODO: It will be removed when the whole test will be reworked */
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -10,8 +10,8 @@ aes_encrypt_cbc:"000000000000000000000000000000000000000000000000000000000000000
|
||||
AES-256-CBC Decrypt (Invalid input length)
|
||||
aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c74":"":MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
|
||||
|
||||
AES - Optional Parameter Validation (MBEDTLS_CHECK_PARAMS)
|
||||
aes_check_params:
|
||||
AES - Mode Parameter Validation
|
||||
aes_invalid_mode:
|
||||
|
||||
AES - Mandatory Parameter Validation and Valid Parameters
|
||||
aes_misc_params:
|
||||
|
@ -1,6 +1,3 @@
|
||||
ARIA - Valid parameters
|
||||
aria_valid_param:
|
||||
|
||||
ARIA - Invalid parameters
|
||||
aria_invalid_param:
|
||||
|
||||
|
@ -16,18 +16,10 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void aria_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_aria_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void aria_invalid_param( )
|
||||
{
|
||||
mbedtls_aria_context ctx;
|
||||
unsigned char key[128 / 8] = { 0 };
|
||||
unsigned char input[MBEDTLS_ARIA_BLOCKSIZE] = { 0 };
|
||||
unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] = { 0 };
|
||||
unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE] = { 0 };
|
||||
@ -35,78 +27,22 @@ void aria_invalid_param( )
|
||||
|
||||
((void) iv_off);
|
||||
((void) iv);
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_aria_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_setkey_enc( NULL, key,
|
||||
sizeof( key ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_setkey_enc( &ctx, NULL,
|
||||
sizeof( key ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_setkey_dec( NULL, key,
|
||||
sizeof( key ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_setkey_dec( &ctx, NULL,
|
||||
sizeof( key ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ecb( NULL, input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ecb( &ctx, NULL, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ecb( &ctx, input, NULL ) );
|
||||
((void) ctx);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cbc( NULL,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cbc( &ctx,
|
||||
42 /* invalid mode */,
|
||||
sizeof( input ),
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cbc( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
NULL,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cbc( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
iv,
|
||||
NULL,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cbc( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
iv,
|
||||
input,
|
||||
NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( NULL,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( &ctx,
|
||||
42, /* invalid mode */
|
||||
sizeof( input ),
|
||||
@ -114,91 +50,8 @@ void aria_invalid_param( )
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
NULL,
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
NULL,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
NULL,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_cfb128( &ctx,
|
||||
MBEDTLS_ARIA_ENCRYPT,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
input,
|
||||
NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( NULL,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( &ctx,
|
||||
sizeof( input ),
|
||||
NULL,
|
||||
iv,
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( &ctx,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
NULL,
|
||||
iv,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( &ctx,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
NULL,
|
||||
input,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( &ctx,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
iv,
|
||||
NULL,
|
||||
output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA,
|
||||
mbedtls_aria_crypt_ctr( &ctx,
|
||||
sizeof( input ),
|
||||
&iv_off,
|
||||
iv,
|
||||
iv,
|
||||
input,
|
||||
NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
BLOWFISH - Valid parameters
|
||||
blowfish_valid_param:
|
||||
|
||||
BLOWFISH - Invalid parameters
|
||||
blowfish_invalid_param:
|
||||
|
||||
|
@ -7,159 +7,37 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void blowfish_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_blowfish_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void blowfish_invalid_param( )
|
||||
{
|
||||
mbedtls_blowfish_context ctx;
|
||||
unsigned char buf[16] = { 0 };
|
||||
size_t const valid_keylength = sizeof( buf ) * 8;
|
||||
size_t valid_mode = MBEDTLS_BLOWFISH_ENCRYPT;
|
||||
size_t invalid_mode = 42;
|
||||
size_t off;
|
||||
((void) off);
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_blowfish_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_blowfish_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_setkey( NULL,
|
||||
buf,
|
||||
valid_keylength ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_setkey( &ctx,
|
||||
NULL,
|
||||
valid_keylength ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ecb( NULL,
|
||||
valid_mode,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ecb( &ctx,
|
||||
invalid_mode,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ecb( &ctx,
|
||||
valid_mode,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ecb( &ctx,
|
||||
valid_mode,
|
||||
buf, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cbc( NULL,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cbc( &ctx,
|
||||
invalid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
NULL, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( NULL,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( &ctx,
|
||||
invalid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
NULL, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, NULL,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_cfb64( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( NULL,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
NULL,
|
||||
buf, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
NULL, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, NULL,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA,
|
||||
mbedtls_blowfish_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,3 @@
|
||||
Camellia - Valid parameters
|
||||
camellia_valid_param:
|
||||
|
||||
Camellia - Invalid parameters
|
||||
camellia_invalid_param:
|
||||
|
||||
|
@ -7,167 +7,37 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void camellia_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_camellia_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void camellia_invalid_param( )
|
||||
{
|
||||
mbedtls_camellia_context ctx;
|
||||
unsigned char buf[16] = { 0 };
|
||||
const size_t valid_keybits = 128;
|
||||
const int invalid_mode = 42;
|
||||
const int valid_mode = MBEDTLS_CAMELLIA_ENCRYPT;
|
||||
size_t off;
|
||||
((void) off);
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_camellia_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_setkey_enc( NULL,
|
||||
buf,
|
||||
valid_keybits ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_setkey_enc( &ctx,
|
||||
NULL,
|
||||
valid_keybits ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_setkey_dec( NULL,
|
||||
buf,
|
||||
valid_keybits ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_setkey_dec( &ctx,
|
||||
NULL,
|
||||
valid_keybits ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ecb( NULL,
|
||||
valid_mode,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ecb( &ctx,
|
||||
invalid_mode,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ecb( &ctx,
|
||||
valid_mode,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ecb( &ctx,
|
||||
valid_mode,
|
||||
buf, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cbc( NULL,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cbc( &ctx,
|
||||
invalid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
NULL, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cbc( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
buf, buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( NULL,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||
invalid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
NULL, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, NULL,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_cfb128( &ctx,
|
||||
valid_mode,
|
||||
sizeof( buf ),
|
||||
&off, buf,
|
||||
buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( NULL,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
NULL,
|
||||
buf, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
NULL, buf,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, NULL,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
|
||||
mbedtls_camellia_crypt_ctr( &ctx,
|
||||
sizeof( buf ),
|
||||
&off,
|
||||
buf, buf,
|
||||
buf, NULL ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
CCM self test
|
||||
mbedtls_ccm_self_test:
|
||||
|
||||
CCM - Invalid parameters
|
||||
ccm_invalid_param:
|
||||
|
||||
CCM - Valid parameters
|
||||
ccm_valid_param:
|
||||
|
||||
CCM init #1 AES-128: OK
|
||||
depends_on:MBEDTLS_AES_C
|
||||
mbedtls_ccm_setkey:MBEDTLS_CIPHER_ID_AES:128:0
|
||||
|
@ -291,216 +291,3 @@ exit:
|
||||
mbedtls_ccm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void ccm_invalid_param( )
|
||||
{
|
||||
struct mbedtls_ccm_context ctx;
|
||||
unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
mbedtls_cipher_id_t valid_cipher = MBEDTLS_CIPHER_ID_AES;
|
||||
int valid_len = sizeof(valid_buffer);
|
||||
int valid_bitlen = valid_len * 8;
|
||||
|
||||
mbedtls_ccm_init( &ctx );
|
||||
|
||||
/* mbedtls_ccm_init() */
|
||||
TEST_INVALID_PARAM( mbedtls_ccm_init( NULL ) );
|
||||
|
||||
/* mbedtls_ccm_setkey() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_setkey( NULL, valid_cipher, valid_buffer, valid_bitlen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_setkey( &ctx, valid_cipher, NULL, valid_bitlen ) );
|
||||
|
||||
/* mbedtls_ccm_encrypt_and_tag() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( &ctx, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
NULL, valid_len ) );
|
||||
|
||||
/* mbedtls_ccm_star_encrypt_and_tag() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
NULL, valid_len ) );
|
||||
|
||||
/* mbedtls_ccm_auth_decrypt() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( &ctx, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
NULL, valid_len ) );
|
||||
|
||||
/* mbedtls_ccm_star_auth_decrypt() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( &ctx, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL,
|
||||
valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CCM_BAD_INPUT,
|
||||
mbedtls_ccm_star_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
NULL, valid_len ) );
|
||||
|
||||
exit:
|
||||
mbedtls_ccm_free( &ctx );
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ccm_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_ccm_free( NULL ) );
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -22,8 +22,5 @@ chacha20_crypt:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0
|
||||
ChaCha20 RFC 7539 Test Vector #3 (Decrypt)
|
||||
chacha20_crypt:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000000000000000002":42:"62e6347f95ed87a45ffae7426f27a1df5fb69110044c0d73118effa95b01e5cf166d3df2d721caf9b21e5fb14c616871fd84c54f9d65b283196c7fe4f60553ebf39c6402c42234e32a356b3e764312a61a5532055716ead6962568f87d3f3f7704c6a8d1bcd1bf4d50d6154b6da731b187b58dfd728afa36757a797ac188d1":"2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e"
|
||||
|
||||
ChaCha20 Paremeter Validation
|
||||
chacha20_bad_params:
|
||||
|
||||
ChaCha20 Selftest
|
||||
chacha20_self_test:
|
||||
|
@ -66,52 +66,6 @@ void chacha20_crypt( data_t *key_str,
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void chacha20_bad_params()
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char nonce[12];
|
||||
unsigned char src[1];
|
||||
unsigned char dst[1];
|
||||
uint32_t counter = 0;
|
||||
size_t len = sizeof( src );
|
||||
mbedtls_chacha20_context ctx;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_chacha20_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_chacha20_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_setkey( NULL, key ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_setkey( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_starts( NULL, nonce, counter ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_starts( &ctx, NULL, counter ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_update( NULL, 0, src, dst ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_update( &ctx, len, NULL, dst ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_update( &ctx, len, src, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_crypt( NULL, nonce, counter, 0, src, dst ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_crypt( key, NULL, counter, 0, src, dst ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_crypt( key, nonce, counter, len, NULL, dst ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA,
|
||||
mbedtls_chacha20_crypt( key, nonce, counter, len, src, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
|
||||
void chacha20_self_test()
|
||||
{
|
||||
|
@ -19,9 +19,6 @@ mbedtls_chachapoly_dec:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc
|
||||
ChaCha20-Poly1305 State Flow
|
||||
chachapoly_state:
|
||||
|
||||
ChaCha20-Poly1305 Parameter Validation
|
||||
chachapoly_bad_params:
|
||||
|
||||
ChaCha20-Poly1305 Selftest
|
||||
depends_on:MBEDTLS_SELF_TEST
|
||||
chachapoly_selftest:
|
||||
|
@ -66,137 +66,6 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void chachapoly_bad_params()
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char nonce[12];
|
||||
unsigned char aad[1];
|
||||
unsigned char input[1];
|
||||
unsigned char output[1];
|
||||
unsigned char mac[16];
|
||||
size_t input_len = sizeof( input );
|
||||
size_t aad_len = sizeof( aad );
|
||||
mbedtls_chachapoly_context ctx;
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( nonce, 0x00, sizeof( nonce ) );
|
||||
memset( aad, 0x00, sizeof( aad ) );
|
||||
memset( input, 0x00, sizeof( input ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( mac, 0x00, sizeof( mac ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_chachapoly_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_chachapoly_free( NULL ) );
|
||||
|
||||
/* setkey */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_setkey( NULL, key ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_setkey( &ctx, NULL ) );
|
||||
|
||||
/* encrypt_and_tag */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( NULL,
|
||||
0, nonce,
|
||||
aad, 0,
|
||||
input, output, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
0, NULL,
|
||||
aad, 0,
|
||||
input, output, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
0, nonce,
|
||||
NULL, aad_len,
|
||||
input, output, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
input_len, nonce,
|
||||
aad, 0,
|
||||
NULL, output, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
input_len, nonce,
|
||||
aad, 0,
|
||||
input, NULL, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
0, nonce,
|
||||
aad, 0,
|
||||
input, output, NULL ) );
|
||||
|
||||
/* auth_decrypt */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( NULL,
|
||||
0, nonce,
|
||||
aad, 0,
|
||||
mac, input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
0, NULL,
|
||||
aad, 0,
|
||||
mac, input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
0, nonce,
|
||||
NULL, aad_len,
|
||||
mac, input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
0, nonce,
|
||||
aad, 0,
|
||||
NULL, input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
input_len, nonce,
|
||||
aad, 0,
|
||||
mac, NULL, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
input_len, nonce,
|
||||
aad, 0,
|
||||
mac, input, NULL ) );
|
||||
|
||||
/* starts */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_starts( NULL, nonce,
|
||||
MBEDTLS_CHACHAPOLY_ENCRYPT ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_starts( &ctx, NULL,
|
||||
MBEDTLS_CHACHAPOLY_ENCRYPT ) );
|
||||
|
||||
/* update_aad */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_update_aad( NULL, aad,
|
||||
aad_len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_update_aad( &ctx, NULL,
|
||||
aad_len ) );
|
||||
|
||||
/* update */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_update( NULL, input_len,
|
||||
input, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_update( &ctx, input_len,
|
||||
NULL, output ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_update( &ctx, input_len,
|
||||
input, NULL ) );
|
||||
|
||||
/* finish */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_finish( NULL, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_chachapoly_finish( &ctx, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void chachapoly_state()
|
||||
{
|
||||
|
@ -207,327 +207,27 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void cipher_invalid_param_conditional( )
|
||||
{
|
||||
mbedtls_cipher_context_t valid_ctx;
|
||||
|
||||
mbedtls_operation_t valid_operation = MBEDTLS_ENCRYPT;
|
||||
mbedtls_operation_t invalid_operation = 100;
|
||||
mbedtls_cipher_padding_t valid_mode = MBEDTLS_PADDING_ZEROS;
|
||||
unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
|
||||
int valid_size = sizeof(valid_buffer);
|
||||
int valid_bitlen = valid_size * 8;
|
||||
const mbedtls_cipher_info_t *valid_info = mbedtls_cipher_info_from_type(
|
||||
*( mbedtls_cipher_list() ) );
|
||||
|
||||
size_t size_t_var;
|
||||
|
||||
(void)valid_mode; /* In some configurations this is unused */
|
||||
|
||||
/* mbedtls_cipher_init() */
|
||||
TEST_VALID_PARAM( mbedtls_cipher_init( &valid_ctx ) );
|
||||
TEST_INVALID_PARAM( mbedtls_cipher_init( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_setup() */
|
||||
TEST_VALID_PARAM( mbedtls_cipher_setup( &valid_ctx, valid_info ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_setup( NULL, valid_info ) );
|
||||
|
||||
/* mbedtls_cipher_get_block_size() */
|
||||
TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_block_size( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_cipher_mode() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_MODE_NONE,
|
||||
mbedtls_cipher_get_cipher_mode( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_iv_size() */
|
||||
TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_iv_size( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_type() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_CIPHER_NONE,
|
||||
mbedtls_cipher_get_type( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_name() */
|
||||
TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_name( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_key_bitlen() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_KEY_LENGTH_NONE,
|
||||
mbedtls_cipher_get_key_bitlen( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_get_operation() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_OPERATION_NONE,
|
||||
mbedtls_cipher_get_operation( NULL ) );
|
||||
|
||||
/* mbedtls_cipher_setkey() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_setkey( NULL,
|
||||
valid_buffer,
|
||||
valid_bitlen,
|
||||
valid_operation ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_setkey( &valid_ctx,
|
||||
NULL,
|
||||
valid_bitlen,
|
||||
valid_operation ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
TEST_EQUAL(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_setkey( &valid_ctx,
|
||||
valid_buffer,
|
||||
valid_bitlen,
|
||||
invalid_operation ) );
|
||||
|
||||
/* mbedtls_cipher_set_iv() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_set_iv( NULL,
|
||||
valid_buffer,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_set_iv( &valid_ctx,
|
||||
NULL,
|
||||
valid_size ) );
|
||||
|
||||
/* mbedtls_cipher_reset() */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_reset( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
|
||||
/* mbedtls_cipher_update_ad() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update_ad( NULL,
|
||||
valid_buffer,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update_ad( &valid_ctx,
|
||||
NULL,
|
||||
valid_size ) );
|
||||
#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
|
||||
/* mbedtls_cipher_set_padding_mode() */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_set_padding_mode( NULL, valid_mode ) );
|
||||
#endif
|
||||
|
||||
/* mbedtls_cipher_update() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update( NULL,
|
||||
valid_buffer,
|
||||
valid_size,
|
||||
valid_buffer,
|
||||
&size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update( &valid_ctx,
|
||||
NULL, valid_size,
|
||||
valid_buffer,
|
||||
&size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
NULL,
|
||||
&size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_update( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer,
|
||||
NULL ) );
|
||||
|
||||
/* mbedtls_cipher_finish() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_finish( NULL,
|
||||
valid_buffer,
|
||||
&size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_finish( &valid_ctx,
|
||||
NULL,
|
||||
&size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_finish( &valid_ctx,
|
||||
valid_buffer,
|
||||
NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
|
||||
/* mbedtls_cipher_write_tag() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_write_tag( NULL,
|
||||
valid_buffer,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_write_tag( &valid_ctx,
|
||||
NULL,
|
||||
valid_size ) );
|
||||
|
||||
/* mbedtls_cipher_check_tag() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_check_tag( NULL,
|
||||
valid_buffer,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_check_tag( &valid_ctx,
|
||||
NULL,
|
||||
valid_size ) );
|
||||
#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */
|
||||
|
||||
/* mbedtls_cipher_crypt() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_crypt( NULL,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, &size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_crypt( &valid_ctx,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, &size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_crypt( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size,
|
||||
valid_buffer, &size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_crypt( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
NULL, &size_t_var ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_crypt( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_AEAD) || defined(MBEDTLS_NIST_KW_C)
|
||||
/* mbedtls_cipher_auth_encrypt_ext */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( NULL,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( &valid_ctx,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_encrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, NULL,
|
||||
valid_size ) );
|
||||
|
||||
/* mbedtls_cipher_auth_decrypt_ext */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( NULL,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( &valid_ctx,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size,
|
||||
valid_buffer, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
NULL, valid_size, &size_t_var,
|
||||
valid_size ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
|
||||
mbedtls_cipher_auth_decrypt_ext( &valid_ctx,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size,
|
||||
valid_buffer, valid_size, NULL,
|
||||
valid_size ) );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_AEAD || MBEDTLS_NIST_KW_C */
|
||||
|
||||
/* mbedtls_cipher_free() */
|
||||
TEST_VALID_PARAM( mbedtls_cipher_free( NULL ) );
|
||||
exit:
|
||||
TEST_VALID_PARAM( mbedtls_cipher_free( &valid_ctx ) );
|
||||
;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
Diffie-Hellman full exchange: tiny x_size
|
||||
dhm_do_dhm:10:"93450983094850938450983409623":1:10:"9345098304850938450983409622":0
|
||||
|
||||
Diffie-Hellman parameter validation
|
||||
dhm_invalid_params:
|
||||
|
||||
Diffie-Hellman full exchange: 5-bit, x_size=3
|
||||
dhm_do_dhm:10:"23":3:10:"5":0
|
||||
|
||||
|
@ -70,113 +70,6 @@ exit:
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void dhm_invalid_params( )
|
||||
{
|
||||
mbedtls_dhm_context ctx;
|
||||
unsigned char buf[42] = { 0 };
|
||||
unsigned char *buf_null = NULL;
|
||||
mbedtls_mpi X;
|
||||
size_t const buflen = sizeof( buf );
|
||||
size_t len;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_dhm_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_dhm_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( NULL,
|
||||
(unsigned char**) &buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx, &buf_null, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx,
|
||||
(unsigned char**) &buf,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( NULL, buflen,
|
||||
buf, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
NULL, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
buf, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
buf, &len,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( &ctx, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( &ctx, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_public( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_public( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( NULL, buflen,
|
||||
buf, buflen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, buflen,
|
||||
NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, buflen,
|
||||
buf, buflen,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( NULL, buf, buflen, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, NULL, buflen, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, buf, buflen, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhm( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhm( &ctx, NULL, buflen ) );
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhmfile( NULL, "" ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhmfile( &ctx, NULL ) );
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void dhm_do_dhm( int radix_P, char *input_P, int x_size,
|
||||
int radix_G, char *input_G, int result )
|
||||
|
@ -1,6 +1,3 @@
|
||||
ECDH - Valid parameters
|
||||
ecdh_valid_param:
|
||||
|
||||
ECDH - Invalid parameters
|
||||
ecdh_invalid_param:
|
||||
|
||||
|
@ -43,141 +43,17 @@ exit:
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ecdh_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_ecdh_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void ecdh_invalid_param( )
|
||||
{
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecdh_context ctx;
|
||||
mbedtls_mpi m;
|
||||
mbedtls_ecp_point P;
|
||||
mbedtls_ecp_keypair kp;
|
||||
size_t olen;
|
||||
unsigned char buf[42] = { 0 };
|
||||
const unsigned char *buf_null = NULL;
|
||||
size_t const buflen = sizeof( buf );
|
||||
int invalid_side = 42;
|
||||
mbedtls_ecp_group_id valid_grp = MBEDTLS_ECP_DP_SECP192R1;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_ecdh_init( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_INVALID_PARAM( mbedtls_ecdh_enable_restart( NULL ) );
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( NULL, &m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, NULL, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, &m, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, &m, &P,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( NULL, &m, &P, &m,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, NULL, &P, &m,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, &m, NULL, &m,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, &m, &P, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_setup( NULL, valid_grp ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_params( NULL,
|
||||
(const unsigned char**) &buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_params( &ctx, &buf_null,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_params( &ctx, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_params( &ctx,
|
||||
(const unsigned char**) &buf,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_get_params( NULL, &kp,
|
||||
MBEDTLS_ECDH_OURS ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_get_params( &ctx, NULL,
|
||||
MBEDTLS_ECDH_OURS ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_get_params( &ctx, &kp,
|
||||
invalid_side ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_public( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_public( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,3 @@
|
||||
ECDSA Parameter validation
|
||||
ecdsa_invalid_param:
|
||||
|
||||
ECDSA primitive hash zero #1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
ecdsa_prim_zero:MBEDTLS_ECP_DP_SECP192R1
|
||||
|
@ -7,203 +7,6 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void ecdsa_invalid_param( )
|
||||
{
|
||||
mbedtls_ecdsa_context ctx;
|
||||
mbedtls_ecp_keypair key;
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP192R1;
|
||||
mbedtls_ecp_point P;
|
||||
mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256;
|
||||
mbedtls_mpi m;
|
||||
size_t slen;
|
||||
unsigned char buf[42] = { 0 };
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_ecdsa_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecdsa_free( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_INVALID_PARAM( mbedtls_ecdsa_restart_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecdsa_restart_free( NULL ) );
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( NULL, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, NULL, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, NULL, &m,
|
||||
buf, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, NULL,
|
||||
buf, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||
NULL, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
NULL, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( NULL, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, NULL, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, NULL, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, NULL,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, &m,
|
||||
NULL, sizeof( buf ),
|
||||
valid_md,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_verify( NULL,
|
||||
buf, sizeof( buf ),
|
||||
&P, &m, &m ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_verify( &grp,
|
||||
NULL, sizeof( buf ),
|
||||
&P, &m, &m ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_verify( &grp,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &m, &m ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_verify( &grp,
|
||||
buf, sizeof( buf ),
|
||||
&P, NULL, &m ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_verify( &grp,
|
||||
buf, sizeof( buf ),
|
||||
&P, &m, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( NULL, valid_md, buf, sizeof( buf ),
|
||||
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, NULL, sizeof( buf ),
|
||||
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||
NULL, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||
buf, NULL, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( NULL, valid_md, buf,
|
||||
sizeof( buf ), buf, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, NULL,
|
||||
sizeof( buf ), buf, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||
sizeof( buf ), NULL, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||
sizeof( buf ), buf, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature( NULL,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature( &ctx,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature( &ctx,
|
||||
buf, sizeof( buf ),
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature_restartable( NULL,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ),
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ),
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
buf, sizeof( buf ),
|
||||
NULL, sizeof( buf ),
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_genkey( NULL, valid_group,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_genkey( &ctx, valid_group,
|
||||
NULL, NULL ) );
|
||||
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_from_keypair( NULL, &key ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_from_keypair( &ctx, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ecdsa_prim_zero( int id )
|
||||
{
|
||||
|
@ -98,100 +98,22 @@ cleanup:
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void ecjpake_invalid_param( )
|
||||
{
|
||||
mbedtls_ecjpake_context ctx;
|
||||
unsigned char buf[42] = { 0 };
|
||||
size_t olen;
|
||||
size_t const len = sizeof( buf );
|
||||
mbedtls_ecjpake_role valid_role = MBEDTLS_ECJPAKE_SERVER;
|
||||
mbedtls_ecjpake_role invalid_role = (mbedtls_ecjpake_role) 42;
|
||||
mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256;
|
||||
mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP256R1;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_ecjpake_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecjpake_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( NULL,
|
||||
valid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( &ctx,
|
||||
invalid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( &ctx,
|
||||
valid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_check( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_one( NULL,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_one( &ctx,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_two( NULL,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_two( &ctx,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
@ -1,6 +1,3 @@
|
||||
ECP valid params
|
||||
ecp_valid_param:
|
||||
|
||||
ECP invalid params
|
||||
ecp_invalid_param:
|
||||
|
||||
|
@ -23,347 +23,26 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ecp_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_ecp_group_free( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecp_keypair_free( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecp_point_free( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_VALID_PARAM( mbedtls_ecp_restart_free( NULL ) );
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void ecp_invalid_param( )
|
||||
{
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_keypair kp;
|
||||
mbedtls_ecp_point P;
|
||||
mbedtls_mpi m;
|
||||
const char *x = "deadbeef";
|
||||
int valid_fmt = MBEDTLS_ECP_PF_UNCOMPRESSED;
|
||||
int invalid_fmt = 42;
|
||||
size_t olen;
|
||||
unsigned char buf[42] = { 0 };
|
||||
const unsigned char *null_buf = NULL;
|
||||
mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP192R1;
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
mbedtls_ecp_restart_ctx restart_ctx;
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_ecp_point_init( NULL ) );
|
||||
TEST_INVALID_PARAM( mbedtls_ecp_keypair_init( NULL ) );
|
||||
TEST_INVALID_PARAM( mbedtls_ecp_group_init( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_INVALID_PARAM( mbedtls_ecp_restart_init( NULL ) );
|
||||
TEST_INVALID_PARAM( mbedtls_ecp_check_budget( NULL, &restart_ctx, 42 ) );
|
||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_copy( NULL, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_copy( &P, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_group_copy( NULL, &grp ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_group_copy( &grp, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( NULL,
|
||||
&m,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( &grp,
|
||||
NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( &grp,
|
||||
&m,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_set_zero( NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_is_zero( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_cmp( NULL, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_cmp( &P, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_string( NULL, 2,
|
||||
x, x ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_string( &P, 2,
|
||||
NULL, x ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_string( &P, 2,
|
||||
x, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_write_binary( NULL, &P,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_write_binary( &grp, NULL,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_write_binary( &grp, &P,
|
||||
invalid_fmt,
|
||||
&olen,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_write_binary( &grp, &P,
|
||||
valid_fmt,
|
||||
NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_write_binary( &grp, &P,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_binary( NULL, &P, buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_binary( &grp, NULL, buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_point_read_binary( &grp, &P, NULL,
|
||||
sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_point( NULL, &P,
|
||||
(const unsigned char **) &buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_point( &grp, NULL,
|
||||
(const unsigned char **) &buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_point( &grp, &P, &null_buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_point( &grp, &P, NULL,
|
||||
sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_point( NULL, &P,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_point( &grp, NULL,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_point( &grp, &P,
|
||||
invalid_fmt,
|
||||
&olen,
|
||||
buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_point( &grp, &P,
|
||||
valid_fmt,
|
||||
NULL,
|
||||
buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_point( &grp, &P,
|
||||
valid_fmt,
|
||||
&olen,
|
||||
NULL,
|
||||
sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_group_load( NULL, valid_group ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group( NULL,
|
||||
(const unsigned char **) &buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group( &grp, NULL,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group( &grp, &null_buf,
|
||||
sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group_id( NULL,
|
||||
(const unsigned char **) &buf,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group_id( &valid_group, NULL,
|
||||
sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_read_group_id( &valid_group,
|
||||
&null_buf,
|
||||
sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_group( NULL, &olen,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_group( &grp, NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_tls_write_group( &grp, &olen,
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( NULL, &P, &m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, NULL, &m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, &P, NULL, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, &P, &m, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( NULL, &P, &m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, NULL, &m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, &P, NULL, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, &P, &m, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( NULL, &P, &m, &P,
|
||||
&m, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( &grp, NULL, &m, &P,
|
||||
&m, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( &grp, &P, NULL, &P,
|
||||
&m, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( &grp, &P, &m, NULL,
|
||||
&m, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( &grp, &P, &m, &P,
|
||||
NULL, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( &grp, &P, &m, &P,
|
||||
&m, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( NULL, &P, &m, &P,
|
||||
&m, &P, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( &grp, NULL, &m, &P,
|
||||
&m, &P, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( &grp, &P, NULL, &P,
|
||||
&m, &P, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( &grp, &P, &m, NULL,
|
||||
&m, &P, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( &grp, &P, &m, &P,
|
||||
NULL, &P, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd_restartable( &grp, &P, &m, &P,
|
||||
&m, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_pubkey( NULL, &P ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_pubkey( &grp, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_pub_priv( NULL, &kp ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_pub_priv( &kp, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_privkey( NULL, &m ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_check_privkey( &grp, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( NULL, &P, &m, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, NULL, &m, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, NULL, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, &P, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( NULL,
|
||||
&m, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
NULL, &P,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
&m, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
&m, &P,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_key( valid_group, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_key( valid_group, &kp,
|
||||
NULL, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
@ -181,178 +181,26 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:NOT_DEFINED */
|
||||
void gcm_invalid_param( )
|
||||
{
|
||||
mbedtls_gcm_context ctx;
|
||||
unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
mbedtls_cipher_id_t valid_cipher = MBEDTLS_CIPHER_ID_AES;
|
||||
int valid_mode = MBEDTLS_GCM_ENCRYPT;
|
||||
int valid_len = sizeof(valid_buffer);
|
||||
int valid_bitlen = 128, invalid_bitlen = 1;
|
||||
size_t olen;
|
||||
int invalid_bitlen = 1;
|
||||
|
||||
mbedtls_gcm_init( &ctx );
|
||||
|
||||
/* mbedtls_gcm_init() */
|
||||
TEST_INVALID_PARAM( mbedtls_gcm_init( NULL ) );
|
||||
|
||||
/* mbedtls_gcm_setkey */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_setkey( NULL, valid_cipher, valid_buffer, valid_bitlen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_setkey( &ctx, valid_cipher, NULL, valid_bitlen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
TEST_EQUAL(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_setkey( &ctx, valid_cipher, valid_buffer, invalid_bitlen ) );
|
||||
|
||||
/* mbedtls_gcm_crypt_and_tag() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( NULL, valid_mode, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_len, valid_buffer ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_len, valid_buffer ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_len, valid_buffer ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer,
|
||||
valid_len, valid_buffer ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL,
|
||||
valid_len, valid_buffer ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer,
|
||||
valid_len, NULL ) );
|
||||
|
||||
/* mbedtls_gcm_auth_decrypt() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( &ctx, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_buffer) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_len,
|
||||
valid_buffer, valid_buffer) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
NULL, valid_buffer) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_auth_decrypt( &ctx, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, valid_len,
|
||||
valid_buffer, NULL) );
|
||||
|
||||
/* mbedtls_gcm_starts() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_starts( NULL, valid_mode,
|
||||
valid_buffer, valid_len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_starts( &ctx, valid_mode,
|
||||
NULL, valid_len ) );
|
||||
|
||||
/* mbedtls_gcm_update_ad() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_update_ad( &ctx,
|
||||
NULL, valid_len ) );
|
||||
|
||||
/* mbedtls_gcm_update() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_update( NULL, valid_buffer, valid_len,
|
||||
valid_buffer, valid_len, &olen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_update( &ctx, NULL, valid_len,
|
||||
valid_buffer, valid_len, &olen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_update( &ctx, valid_buffer, valid_len,
|
||||
NULL, valid_len, &olen ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_update( &ctx, valid_buffer, valid_len,
|
||||
valid_buffer, valid_len, NULL ) );
|
||||
|
||||
/* mbedtls_gcm_finish() */
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_finish( NULL, NULL, 0, valid_buffer, valid_len ) );
|
||||
TEST_INVALID_PARAM_RET(
|
||||
MBEDTLS_ERR_GCM_BAD_INPUT,
|
||||
mbedtls_gcm_finish( &ctx, NULL, 0, NULL, valid_len ) );
|
||||
|
||||
exit:
|
||||
mbedtls_gcm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void gcm_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_gcm_free( NULL ) );
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
|
||||
void gcm_selftest( )
|
||||
{
|
||||
|
@ -1,5 +1,2 @@
|
||||
GCM - Invalid parameters
|
||||
gcm_invalid_param:
|
||||
|
||||
GCM - Valid parameters
|
||||
gcm_valid_param:
|
||||
|
@ -1,9 +1,3 @@
|
||||
MPI - Valid parameters
|
||||
mpi_valid_param:
|
||||
|
||||
MPI - Invalid parameters
|
||||
mpi_invalid_param:
|
||||
|
||||
Arguments with no value
|
||||
mpi_null:
|
||||
|
||||
|
@ -115,221 +115,6 @@ static int is_significantly_above_a_power_of_2( data_t *bytes )
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_mpi_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void mpi_invalid_param( )
|
||||
{
|
||||
mbedtls_mpi X;
|
||||
const char *s_in = "00101000101010";
|
||||
char s_out[16] = { 0 };
|
||||
unsigned char u_out[16] = { 0 };
|
||||
unsigned char u_in[16] = { 0 };
|
||||
size_t olen;
|
||||
mbedtls_mpi_uint mpi_uint;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_mpi_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_grow( NULL, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_copy( NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_copy( &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_mpi_swap( NULL, &X ) );
|
||||
TEST_INVALID_PARAM( mbedtls_mpi_swap( &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_safe_cond_assign( NULL, &X, 0 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_safe_cond_assign( &X, NULL, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_safe_cond_swap( NULL, &X, 0 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_safe_cond_swap( &X, NULL, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_lset( NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_get_bit( NULL, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_set_bit( NULL, 42, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_string( NULL, 2, s_in ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_string( &X, 2, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_string( NULL, 2,
|
||||
s_out, sizeof( s_out ),
|
||||
&olen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_string( &X, 2,
|
||||
NULL, sizeof( s_out ),
|
||||
&olen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_string( &X, 2,
|
||||
s_out, sizeof( s_out ),
|
||||
NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_file( NULL, 2, stdin ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_file( &X, 2, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_file( "", NULL, 2, NULL ) );
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_binary( NULL, u_in,
|
||||
sizeof( u_in ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_read_binary( &X, NULL,
|
||||
sizeof( u_in ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_binary( NULL, u_out,
|
||||
sizeof( u_out ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_write_binary( &X, NULL,
|
||||
sizeof( u_out ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_shift_l( NULL, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_shift_r( NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_cmp_abs( NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_cmp_abs( &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_cmp_mpi( NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_cmp_mpi( &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_cmp_int( NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_abs( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_abs( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_abs( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_abs( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_abs( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_abs( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_mpi( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_mpi( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_mpi( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_mpi( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_mpi( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_mpi( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_int( NULL, &X, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_add_int( &X, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_int( NULL, &X, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_sub_int( &X, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mul_mpi( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mul_mpi( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mul_mpi( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mul_int( NULL, &X, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mul_int( &X, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_div_mpi( &X, &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_div_mpi( &X, &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_div_int( &X, &X, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( 0, mbedtls_mpi_lsb( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mod_mpi( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mod_mpi( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mod_mpi( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mod_int( NULL, &X, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_mod_int( &mpi_uint, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_exp_mod( NULL, &X, &X, &X, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_exp_mod( &X, NULL, &X, &X, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_exp_mod( &X, &X, NULL, &X, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_exp_mod( &X, &X, &X, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_fill_random( NULL, 42,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_fill_random( &X, 42, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_gcd( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_gcd( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_gcd( &X, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_inv_mod( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_inv_mod( &X, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_inv_mod( &X, &X, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_null( )
|
||||
{
|
||||
|
@ -1,6 +1,3 @@
|
||||
PK invalid parameters
|
||||
invalid_parameters:
|
||||
|
||||
PK valid parameters
|
||||
valid_parameters:
|
||||
|
||||
|
@ -211,12 +211,6 @@ void valid_parameters( )
|
||||
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
TEST_VALID_PARAM( mbedtls_pk_free( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_VALID_PARAM( mbedtls_pk_restart_free( NULL ) );
|
||||
#endif
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &pk, NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
@ -323,275 +317,6 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void invalid_parameters( )
|
||||
{
|
||||
size_t len;
|
||||
unsigned char *null_buf = NULL;
|
||||
unsigned char buf[1];
|
||||
unsigned char *p = buf;
|
||||
char str[1] = {0};
|
||||
mbedtls_pk_context pk;
|
||||
mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256;
|
||||
void *options = buf;
|
||||
|
||||
(void) null_buf;
|
||||
(void) p;
|
||||
(void) str;
|
||||
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_pk_init( NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
TEST_INVALID_PARAM( mbedtls_pk_restart_init( NULL ) );
|
||||
#endif
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_setup( NULL, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_setup_rsa_alt( NULL, buf,
|
||||
NULL, NULL, NULL ) );
|
||||
#endif
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_restartable( NULL,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ),
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_restartable( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ),
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_restartable( &pk,
|
||||
valid_md,
|
||||
NULL, 0,
|
||||
buf, sizeof( buf ),
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_restartable( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
NULL, sizeof( buf ),
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify( NULL,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify( &pk,
|
||||
valid_md,
|
||||
NULL, 0,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options,
|
||||
NULL,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options,
|
||||
&pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options,
|
||||
&pk,
|
||||
valid_md,
|
||||
NULL, 0,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options,
|
||||
&pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk, valid_md, NULL, 0, buf, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
NULL, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk, valid_md, NULL, 0, buf, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ), NULL, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_check_pair( NULL, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_check_pair( &pk, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_debug( NULL, NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_PK_PARSE_C)
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_load_file( NULL, &p, &len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_load_file( str, NULL, &len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_load_file( str, &p, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_keyfile( NULL, str, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_keyfile( &pk, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_public_keyfile( NULL, str ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_public_keyfile( &pk, NULL ) );
|
||||
#endif
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_subpubkey( NULL, buf, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_subpubkey( &null_buf, buf, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_subpubkey( &p, NULL, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_subpubkey( &p, buf, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_key( NULL,
|
||||
buf, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_key( &pk,
|
||||
NULL, sizeof( buf ),
|
||||
buf, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_public_key( NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_parse_public_key( &pk,
|
||||
NULL, sizeof( buf ) ) );
|
||||
#endif /* MBEDTLS_PK_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_PK_WRITE_C)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey( NULL, p, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey( &null_buf, p, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey( &p, NULL, &pk ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey( &p, p, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey_der( NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey_der( &pk,
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_key_der( NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_key_der( &pk,
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
#if defined(MBEDTLS_PEM_WRITE_C)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey_pem( NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_pubkey_pem( &pk,
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_key_pem( NULL,
|
||||
buf, sizeof( buf ) ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_write_key_pem( &pk,
|
||||
NULL, sizeof( buf ) ) );
|
||||
#endif /* MBEDTLS_PEM_WRITE_C */
|
||||
|
||||
#endif /* MBEDTLS_PK_WRITE_C */
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void pk_utils( int type, int parameter, int bitlen, int len, char * name )
|
||||
{
|
||||
|
@ -34,9 +34,6 @@ mbedtls_poly1305:"01000000000000000400000000000000000000000000000000000000000000
|
||||
Poly1305 RFC 7539 Test Vector #11
|
||||
mbedtls_poly1305:"0100000000000000040000000000000000000000000000000000000000000000":"13000000000000000000000000000000":"e33594d7505e43b900000000000000003394d7505e4379cd010000000000000000000000000000000000000000000000"
|
||||
|
||||
Poly1305 Parameter validation
|
||||
poly1305_bad_params:
|
||||
|
||||
Poly1305 Selftest
|
||||
depends_on:MBEDTLS_SELF_TEST
|
||||
poly1305_selftest:
|
||||
|
@ -79,45 +79,6 @@ void mbedtls_poly1305( data_t *key, data_t *expected_mac, data_t *src_str )
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void poly1305_bad_params()
|
||||
{
|
||||
unsigned char src[1];
|
||||
unsigned char key[32];
|
||||
unsigned char mac[16];
|
||||
size_t src_len = sizeof( src );
|
||||
mbedtls_poly1305_context ctx;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_poly1305_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_poly1305_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_starts( NULL, key ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_starts( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_update( NULL, src, 0 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_update( &ctx, NULL, src_len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_finish( NULL, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_finish( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_mac( NULL, src, 0, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_mac( key, NULL, src_len, mac ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA,
|
||||
mbedtls_poly1305_mac( key, src, 0, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
|
||||
void poly1305_selftest()
|
||||
{
|
||||
|
@ -1,6 +1,3 @@
|
||||
RSA parameter validation
|
||||
rsa_invalid_param:
|
||||
|
||||
RSA init-free-free
|
||||
rsa_init_free:0
|
||||
|
||||
|
@ -17,352 +17,6 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void rsa_invalid_param( )
|
||||
{
|
||||
mbedtls_rsa_context ctx;
|
||||
const int valid_padding = MBEDTLS_RSA_PKCS_V21;
|
||||
const int invalid_padding = 42;
|
||||
unsigned char buf[42] = { 0 };
|
||||
size_t olen;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_rsa_init( NULL, valid_padding, 0 ) );
|
||||
TEST_INVALID_PARAM( mbedtls_rsa_init( &ctx, invalid_padding, 0 ) );
|
||||
TEST_VALID_PARAM( mbedtls_rsa_free( NULL ) );
|
||||
|
||||
/* No more variants because only the first argument must be non-NULL. */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_import( NULL, NULL, NULL,
|
||||
NULL, NULL, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_import_raw( NULL,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_complete( NULL ) );
|
||||
|
||||
/* No more variants because only the first argument must be non-NULL. */
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_export( NULL, NULL, NULL,
|
||||
NULL, NULL, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_export_raw( NULL,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
NULL, 0 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_export_crt( NULL, NULL, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_rsa_set_padding( NULL,
|
||||
valid_padding, 0 ) );
|
||||
TEST_INVALID_PARAM( mbedtls_rsa_set_padding( &ctx,
|
||||
invalid_padding, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_gen_key( NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, 0, 0 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_gen_key( &ctx, NULL,
|
||||
NULL, 0, 0 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_check_pubkey( NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_check_privkey( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_check_pub_priv( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_check_pub_priv( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_public( NULL, buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_public( &ctx, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_public( &ctx, buf, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_private( NULL, NULL, NULL,
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_private( &ctx, NULL, NULL,
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_private( &ctx, NULL, NULL,
|
||||
buf, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( NULL, NULL, NULL,
|
||||
sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL,
|
||||
sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL,
|
||||
sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_encrypt( NULL, NULL,
|
||||
NULL, sizeof( buf ),
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, NULL,
|
||||
NULL, sizeof( buf ),
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, NULL,
|
||||
NULL, sizeof( buf ),
|
||||
buf, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_encrypt( NULL, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL,
|
||||
NULL, sizeof( buf ),
|
||||
sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_decrypt( NULL, NULL, NULL,
|
||||
&olen,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL,
|
||||
NULL,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL,
|
||||
&olen,
|
||||
NULL, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL,
|
||||
&olen,
|
||||
buf, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_decrypt( NULL, NULL,
|
||||
NULL, &olen,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL,
|
||||
NULL, NULL,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL,
|
||||
NULL, &olen,
|
||||
NULL, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL,
|
||||
NULL, &olen,
|
||||
buf, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_decrypt( NULL, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
&olen,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL,
|
||||
NULL, sizeof( buf ),
|
||||
NULL,
|
||||
buf, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
&olen,
|
||||
NULL, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL,
|
||||
buf, sizeof( buf ),
|
||||
&olen,
|
||||
buf, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_sign( NULL, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_sign( NULL, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign( NULL, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign_ext( NULL, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
MBEDTLS_RSA_SALT_LEN_ANY,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign_ext( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), NULL,
|
||||
MBEDTLS_RSA_SALT_LEN_ANY,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign_ext( &ctx, NULL, NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
MBEDTLS_RSA_SALT_LEN_ANY,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_sign_ext( &ctx, NULL, NULL,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
MBEDTLS_RSA_SALT_LEN_ANY,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_verify( NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_verify( &ctx,
|
||||
0, sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_verify( &ctx,
|
||||
0, sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_verify( &ctx,
|
||||
MBEDTLS_MD_SHA1, 0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_verify( NULL,
|
||||
0, sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx,
|
||||
0, sizeof( buf ),
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx,
|
||||
0, sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify( NULL,
|
||||
0, sizeof( buf ),
|
||||
buf, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify( &ctx,
|
||||
0, sizeof( buf ),
|
||||
NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify( &ctx,
|
||||
0, sizeof( buf ),
|
||||
buf, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify( &ctx,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify_ext( NULL,
|
||||
0, sizeof( buf ),
|
||||
buf,
|
||||
0, 0,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify_ext( &ctx,
|
||||
0, sizeof( buf ),
|
||||
NULL, 0, 0,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify_ext( &ctx,
|
||||
0, sizeof( buf ),
|
||||
buf, 0, 0,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_rsassa_pss_verify_ext( &ctx,
|
||||
MBEDTLS_MD_SHA1,
|
||||
0, NULL,
|
||||
0, 0,
|
||||
buf ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_copy( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_copy( &ctx, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void rsa_init_free( int reinit )
|
||||
{
|
||||
|
@ -1,9 +1,3 @@
|
||||
SHA-1 - Valid parameters
|
||||
sha1_valid_param:
|
||||
|
||||
SHA-1 - Invalid parameters
|
||||
sha1_invalid_param:
|
||||
|
||||
# Test the operation of SHA-1 and SHA-2
|
||||
SHA-1 Test Vector NIST CAVS #1
|
||||
depends_on:MBEDTLS_SHA1_C
|
||||
@ -45,9 +39,6 @@ SHA-1 Test Vector NIST CAVS #10
|
||||
depends_on:MBEDTLS_SHA1_C
|
||||
mbedtls_sha1:"8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff":"11863b483809ef88413ca9b0084ac4a5390640af"
|
||||
|
||||
SHA-256 Valid parameters
|
||||
sha256_valid_param:
|
||||
|
||||
SHA-256 Invalid parameters
|
||||
sha256_invalid_param:
|
||||
|
||||
@ -110,9 +101,6 @@ mbedtls_sha256:"8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e
|
||||
SHA-512 Invalid parameters
|
||||
sha512_invalid_param:
|
||||
|
||||
SHA-512 Valid parameters
|
||||
sha512_valid_param:
|
||||
|
||||
SHA-384 Test Vector NIST CAVS #1
|
||||
depends_on:MBEDTLS_SHA384_C
|
||||
sha384:"":"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"
|
||||
|
@ -4,53 +4,6 @@
|
||||
#include "mbedtls/sha512.h"
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */
|
||||
void sha1_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_sha1_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void sha1_invalid_param( )
|
||||
{
|
||||
mbedtls_sha1_context ctx;
|
||||
unsigned char buf[64] = { 0 };
|
||||
size_t const buflen = sizeof( buf );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha1_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha1_clone( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM( mbedtls_sha1_clone( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_starts_ret( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_update_ret( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_update_ret( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_finish_ret( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_finish_ret( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha1_process( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha1_process( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_ret( NULL, buflen, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA,
|
||||
mbedtls_sha1_ret( buf, buflen, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */
|
||||
void mbedtls_sha1( data_t * src_str, data_t * hash )
|
||||
{
|
||||
@ -65,14 +18,7 @@ void mbedtls_sha1( data_t * src_str, data_t * hash )
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
|
||||
void sha256_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_sha256_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:NOT_DEFINED */
|
||||
void sha256_invalid_param( )
|
||||
{
|
||||
mbedtls_sha256_context ctx;
|
||||
@ -81,38 +27,10 @@ void sha256_invalid_param( )
|
||||
int valid_type = 0;
|
||||
int invalid_type = 42;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha256_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha256_clone( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM( mbedtls_sha256_clone( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_starts_ret( NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_starts_ret( &ctx, invalid_type ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_update_ret( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_update_ret( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_finish_ret( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_finish_ret( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha256_process( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha256_process( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_ret( NULL, buflen,
|
||||
buf, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_ret( buf, buflen,
|
||||
NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA,
|
||||
mbedtls_sha256_ret( buf, buflen,
|
||||
buf, invalid_type ) );
|
||||
|
||||
@ -149,14 +67,7 @@ void mbedtls_sha256( data_t * src_str, data_t * hash )
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
|
||||
void sha512_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_sha512_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:NOT_DEFINED */
|
||||
void sha512_invalid_param( )
|
||||
{
|
||||
mbedtls_sha512_context ctx;
|
||||
@ -165,38 +76,10 @@ void sha512_invalid_param( )
|
||||
int valid_type = 0;
|
||||
int invalid_type = 42;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_clone( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_clone( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_starts_ret( NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_starts_ret( &ctx, invalid_type ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_update_ret( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_update_ret( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_finish_ret( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_finish_ret( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha512_process( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha512_process( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( NULL, buflen,
|
||||
buf, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( buf, buflen,
|
||||
NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
TEST_EQUAL( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( buf, buflen,
|
||||
buf, invalid_type ) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user