Add new checks in rsa_invalid_param test

This new checks covers previous commits

Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
This commit is contained in:
Tuvshinzaya Erdenekhuu 2022-07-26 10:09:24 +01:00
parent 6a473b2f17
commit 7e2e2a9762

View file

@ -16,6 +16,9 @@ void rsa_invalid_param( )
mbedtls_rsa_context ctx;
const int invalid_padding = 42;
const int invalid_hash_id = 0xff;
const mbedtls_md_type_t md_alg_none = MBEDTLS_MD_NONE;
unsigned char buf[] = {0x00,0x01,0x02,0x03,0x04,0x05};
size_t buf_len = sizeof( buf );
mbedtls_rsa_init( &ctx );
@ -29,6 +32,17 @@ void rsa_invalid_param( )
invalid_hash_id ),
MBEDTLS_ERR_RSA_INVALID_PADDING );
TEST_EQUAL( mbedtls_rsa_pkcs1_sign(&ctx, NULL,
NULL, md_alg_none,
buf_len,
NULL, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
TEST_EQUAL( mbedtls_rsa_pkcs1_verify(&ctx, md_alg_none,
buf_len,
NULL, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
#if !defined(MBEDTLS_PKCS1_V15)
TEST_EQUAL( mbedtls_rsa_set_padding( &ctx,
MBEDTLS_RSA_PKCS_V15,
@ -36,6 +50,20 @@ void rsa_invalid_param( )
MBEDTLS_ERR_RSA_INVALID_PADDING );
#endif
#if defined( MBEDTLS_PKCS1_V15 )
TEST_EQUAL( mbedtls_rsa_rsassa_pkcs1_v15_sign(&ctx, NULL,
NULL, md_alg_none,
buf_len,
NULL, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
TEST_EQUAL( mbedtls_rsa_rsassa_pkcs1_v15_verify(&ctx, md_alg_none,
buf_len,
NULL, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
#endif
#if !defined(MBEDTLS_PKCS1_V21)
TEST_EQUAL( mbedtls_rsa_set_padding( &ctx,
MBEDTLS_RSA_PKCS_V21,
@ -43,6 +71,26 @@ void rsa_invalid_param( )
MBEDTLS_ERR_RSA_INVALID_PADDING );
#endif
#if defined(MBEDTLS_PKCS1_V21)
TEST_EQUAL( mbedtls_rsa_rsassa_pss_sign_ext(&ctx, NULL, NULL,
md_alg_none, buf_len,
NULL, buf_len,
buf ),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
TEST_EQUAL( mbedtls_rsa_rsassa_pss_verify_ext(&ctx, md_alg_none,
buf_len, NULL,
md_alg_none,
buf_len, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
TEST_EQUAL( mbedtls_rsa_rsassa_pss_verify(&ctx, md_alg_none,
buf_len,
NULL, buf),
MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
#endif
exit:
mbedtls_rsa_free( &ctx );
}