mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-27 15:40:02 +00:00
test_suite_rsa.function: add tests
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
12cb39661c
commit
097147540d
@ -7,6 +7,46 @@ rsa_init_free:0
|
||||
RSA init-free-init-free
|
||||
rsa_init_free:1
|
||||
|
||||
RSA retrieves context with PKCS#1 v1.5 and None MD
|
||||
depends_on:MBEDTLS_PKCS1_V15
|
||||
# MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_NONE
|
||||
rsa_ctx_param_validation:0:0
|
||||
|
||||
RSA retrieves context with PKCS#1 v1.5 and MD5
|
||||
depends_on:MBEDTLS_PKCS1_V15:MBEDTLS_HAS_ALG_MD5_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_MD5
|
||||
rsa_ctx_param_validation:0:1
|
||||
|
||||
RSA retrieves context with PKCS#1 v1.5 and SHA-256
|
||||
depends_on:MBEDTLS_PKCS1_V15:MBEDTLS_HAS_ALG_SHA_256_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256
|
||||
rsa_ctx_param_validation:0:4
|
||||
|
||||
RSA retrieves context with PKCS#1 v1.5 and RIPEMD-160
|
||||
depends_on:MBEDTLS_PKCS1_V15:MBEDTLS_HAS_ALG_RIPEMD160_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_RIPEMD160
|
||||
rsa_ctx_param_validation:0:7
|
||||
|
||||
RSA retrieves context with PKCS#1 v2.1 and SHA1
|
||||
depends_on:MBEDTLS_PKCS1_V21:MBEDTLS_HAS_ALG_SHA_1_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V21:MBEDTLS_MD_SHA1
|
||||
rsa_ctx_param_validation:1:2
|
||||
|
||||
RSA retrieves context with PKCS#1 v2.1 and SHA224
|
||||
depends_on:MBEDTLS_PKCS1_V21:MBEDTLS_HAS_ALG_SHA_224_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V21:MBEDTLS_MD_SHA224
|
||||
rsa_ctx_param_validation:1:3
|
||||
|
||||
RSA retrieves context with PKCS#1 v2.1 and SHA384
|
||||
depends_on:MBEDTLS_PKCS1_V21:MBEDTLS_HAS_ALG_SHA_384_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V21:MBEDTLS_MD_SHA384
|
||||
rsa_ctx_param_validation:1:5
|
||||
|
||||
RSA retrieves context with PKCS#1 v2.1 and SHA512
|
||||
depends_on:MBEDTLS_PKCS1_V21:MBEDTLS_HAS_ALG_SHA_512_VIA_LOWLEVEL_OR_PSA
|
||||
# MBEDTLS_RSA_PKCS_V21:MBEDTLS_MD_SHA512
|
||||
rsa_ctx_param_validation:1:6
|
||||
|
||||
RSA PKCS1 Verify v1.5 CAVS #1
|
||||
depends_on:MBEDTLS_HAS_ALG_SHA_1_VIA_LOWLEVEL_OR_PSA:MBEDTLS_PKCS1_V15
|
||||
# Good padding but wrong hash
|
||||
|
@ -26,11 +26,17 @@ void rsa_invalid_param()
|
||||
MBEDTLS_MD_NONE),
|
||||
MBEDTLS_ERR_RSA_INVALID_PADDING);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_get_padding_mode(&ctx), MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_EQUAL(mbedtls_rsa_get_hash_id(&ctx), MBEDTLS_MD_NONE);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_set_padding(&ctx,
|
||||
MBEDTLS_RSA_PKCS_V21,
|
||||
invalid_hash_id),
|
||||
MBEDTLS_ERR_RSA_INVALID_PADDING);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_get_padding_mode(&ctx), MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_EQUAL(mbedtls_rsa_get_hash_id(&ctx), MBEDTLS_MD_NONE);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_pkcs1_sign(&ctx, NULL,
|
||||
NULL, MBEDTLS_MD_NONE,
|
||||
buf_len,
|
||||
@ -58,6 +64,9 @@ void rsa_invalid_param()
|
||||
MBEDTLS_RSA_PKCS_V15,
|
||||
MBEDTLS_MD_NONE),
|
||||
MBEDTLS_ERR_RSA_INVALID_PADDING);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_get_padding_mode(&ctx), MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_EQUAL(mbedtls_rsa_get_hash_id(&ctx), MBEDTLS_MD_NONE);
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS1_V15)
|
||||
@ -91,6 +100,9 @@ void rsa_invalid_param()
|
||||
MBEDTLS_RSA_PKCS_V21,
|
||||
MBEDTLS_MD_NONE),
|
||||
MBEDTLS_ERR_RSA_INVALID_PADDING);
|
||||
|
||||
TEST_EQUAL(mbedtls_rsa_get_padding_mode(&ctx), MBEDTLS_RSA_PKCS_V15);
|
||||
TEST_EQUAL(mbedtls_rsa_get_hash_id(&ctx), MBEDTLS_MD_NONE);
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS1_V21)
|
||||
@ -158,6 +170,25 @@ void rsa_init_free(int reinit)
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void rsa_ctx_param_validation(int padding_mode, int hash_id)
|
||||
{
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
mbedtls_rsa_init(&ctx);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_set_padding(&ctx,
|
||||
padding_mode,
|
||||
hash_id) == 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_rsa_get_padding_mode(&ctx) == padding_mode);
|
||||
TEST_ASSERT(mbedtls_rsa_get_hash_id(&ctx) == hash_id);
|
||||
|
||||
exit:
|
||||
mbedtls_rsa_free(&ctx);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_rsa_pkcs1_sign(data_t *message_str, int padding_mode,
|
||||
int digest, int mod, char *input_P,
|
||||
|
Loading…
x
Reference in New Issue
Block a user