Added new tests in pk_invalid_param

Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
This commit is contained in:
Tuvshinzaya Erdenekhuu 2022-08-30 13:15:55 +01:00
parent ed99ed34f3
commit 0050b918f0

View File

@ -303,7 +303,6 @@ exit:
void pk_invalid_param()
{
mbedtls_pk_context ctx;
mbedtls_md_type_t md_alg_none = MBEDTLS_MD_NONE;
mbedtls_pk_type_t pk_type = 0;
unsigned char buf[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
size_t buf_size = sizeof( buf );
@ -311,21 +310,37 @@ void pk_invalid_param()
mbedtls_pk_init( &ctx );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_verify_restartable( &ctx, md_alg_none,
mbedtls_pk_verify_restartable( &ctx, MBEDTLS_MD_NONE,
NULL, buf_size,
buf, buf_size,
NULL ) );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_verify_restartable( &ctx, MBEDTLS_MD_SHA256,
NULL, 0,
buf, buf_size,
NULL ) );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_verify_ext( pk_type, NULL,
&ctx, md_alg_none,
&ctx, MBEDTLS_MD_NONE,
NULL, buf_size,
buf, buf_size ) );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_sign_restartable( &ctx, md_alg_none,
mbedtls_pk_verify_ext( pk_type, NULL,
&ctx, MBEDTLS_MD_SHA256,
NULL, 0,
buf, buf_size ) );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_sign_restartable( &ctx, MBEDTLS_MD_NONE,
NULL, buf_size,
buf, buf_size, &buf_size,
NULL, NULL,
NULL ) );
TEST_EQUAL( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
mbedtls_pk_sign_restartable( &ctx, MBEDTLS_MD_SHA256,
NULL, 0,
buf, buf_size, &buf_size,
NULL, NULL,
NULL ) );
exit:
mbedtls_pk_free( &ctx );
}