mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Split out mbedtls_ecp_mod_p448_raw()
Switch testing over to using the generic raw functions. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
@@ -1356,6 +1356,13 @@ void ecp_mod_p_generic_raw(int curve_id,
|
||||
curve_bits = 255;
|
||||
curve_func = &mbedtls_ecp_mod_p255_raw;
|
||||
break;
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
|
||||
case MBEDTLS_ECP_DP_CURVE448:
|
||||
limbs = 2 * limbs_N;
|
||||
curve_bits = 448;
|
||||
curve_func = &mbedtls_ecp_mod_p448_raw;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
mbedtls_test_fail("Unsupported curve_id", __LINE__, __FILE__);
|
||||
@@ -1384,45 +1391,6 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS:MBEDTLS_ECP_DP_CURVE448_ENABLED */
|
||||
void ecp_mod_p448(char *input_N,
|
||||
char *input_X,
|
||||
char *result)
|
||||
{
|
||||
mbedtls_mpi X;
|
||||
mbedtls_mpi N;
|
||||
mbedtls_mpi res;
|
||||
|
||||
mbedtls_mpi_init(&X);
|
||||
mbedtls_mpi_init(&N);
|
||||
mbedtls_mpi_init(&res);
|
||||
|
||||
TEST_EQUAL(mbedtls_test_read_mpi(&X, input_X), 0);
|
||||
TEST_EQUAL(mbedtls_test_read_mpi(&N, input_N), 0);
|
||||
TEST_EQUAL(mbedtls_test_read_mpi(&res, result), 0);
|
||||
|
||||
TEST_ASSERT(mbedtls_mpi_core_uint_le_mpi(0, X.p, X.n));
|
||||
TEST_ASSERT(mbedtls_mpi_core_uint_le_mpi(0, N.p, N.n));
|
||||
TEST_ASSERT(mbedtls_mpi_core_uint_le_mpi(0, res.p, res.n));
|
||||
|
||||
size_t limbs = N.n;
|
||||
size_t bytes = limbs * sizeof(mbedtls_mpi_uint);
|
||||
|
||||
TEST_LE_U(X.n, 2 * limbs);
|
||||
TEST_EQUAL(res.n, limbs);
|
||||
|
||||
TEST_EQUAL(mbedtls_ecp_mod_p448(X.p, X.n), 0);
|
||||
TEST_EQUAL(mbedtls_mpi_mod_mpi(&X, &X, &N), 0);
|
||||
TEST_LE_U(mbedtls_mpi_core_bitlen(X.p, X.n), 448);
|
||||
ASSERT_COMPARE(X.p, bytes, res.p, bytes);
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free(&X);
|
||||
mbedtls_mpi_free(&N);
|
||||
mbedtls_mpi_free(&res);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */
|
||||
void ecp_mod_setup(char *input_A, int id, int ctype, int iret)
|
||||
{
|
||||
|
Reference in New Issue
Block a user