mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 13:20:21 +00:00
rsa: add positive test cases for getter functions
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
8a7ed6951d
commit
15d3df7aec
@ -32,6 +32,9 @@ void pkcs1_rsaes_v15_encrypt(int mod, char *input_N,
|
||||
MBEDTLS_RSA_PKCS_V15, hash) == 0);
|
||||
memset(output, 0x00, sizeof(output));
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0);
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&E, input_E) == 0);
|
||||
TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0);
|
||||
@ -77,6 +80,9 @@ void pkcs1_rsaes_v15_decrypt(int mod, char *input_P, char *input_Q,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V15, hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
memset(output, 0x00, sizeof(output));
|
||||
memset(&rnd_info, 0, sizeof(mbedtls_test_rnd_pseudo_info));
|
||||
|
||||
@ -281,6 +287,9 @@ void pkcs1_rsassa_v15_sign(int mod, char *input_P,
|
||||
|
||||
memset(output, 0x00, sizeof(output));
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&P, input_P) == 0);
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&Q, input_Q) == 0);
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0);
|
||||
@ -322,6 +331,9 @@ void pkcs1_rsassa_v15_verify(int mod, char *input_N, char *input_E,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V15, hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0);
|
||||
TEST_ASSERT(mbedtls_test_read_mpi(&E, input_E) == 0);
|
||||
TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0);
|
||||
|
@ -29,6 +29,9 @@ void pkcs1_rsaes_oaep_encrypt(int mod, data_t *input_N, data_t *input_E,
|
||||
MBEDTLS_RSA_PKCS_V21, hash) == 0);
|
||||
memset(output, 0x00, sizeof(output));
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V21);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0);
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&E, input_E->x, input_E->len) == 0);
|
||||
TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0);
|
||||
@ -73,6 +76,9 @@ void pkcs1_rsaes_oaep_decrypt(int mod, data_t *input_P, data_t *input_Q,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V21, hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V21);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
memset(output, 0x00, sizeof(output));
|
||||
memset(&rnd_info, 0, sizeof(mbedtls_test_rnd_pseudo_info));
|
||||
|
||||
@ -134,6 +140,9 @@ void pkcs1_rsassa_pss_sign(int mod, data_t *input_P, data_t *input_Q,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V21, hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V21);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
memset(output, 0x00, sizeof(output));
|
||||
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&P, input_P->x, input_P->len) == 0);
|
||||
@ -187,6 +196,9 @@ void pkcs1_rsassa_pss_verify(int mod, data_t *input_N, data_t *input_E,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V21, hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V21);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0);
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&E, input_E->x, input_E->len) == 0);
|
||||
|
||||
@ -220,6 +232,9 @@ void pkcs1_rsassa_pss_verify_ext(int mod, data_t *input_N, data_t *input_E,
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V21, ctx_hash) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == MBEDTLS_RSA_PKCS_V21);
|
||||
TEST_ASSERT(mbedtls_rsa_get_md_alg(&ctx) == ctx_hash);
|
||||
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0);
|
||||
TEST_ASSERT(mbedtls_mpi_read_binary(&E, input_E->x, input_E->len) == 0);
|
||||
|
||||
|
@ -21,9 +21,6 @@ void rsa_invalid_param()
|
||||
|
||||
mbedtls_rsa_init(&ctx);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_get_padding_mode(&ctx), MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_EQUAL(mbedtls_rsa_get_md_alg(&ctx), MBEDTLS_MD_NONE);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_set_padding(&ctx,
|
||||
invalid_padding,
|
||||
MBEDTLS_MD_NONE),
|
||||
|
Loading…
x
Reference in New Issue
Block a user