test_suite_ecp: Added ecp_mod_p384_raw() test case.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
parent
6fb105fb2e
commit
619385d8bc
1 changed files with 43 additions and 0 deletions
|
@ -1430,6 +1430,49 @@ exit:
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */
|
||||
void ecp_mod_p384_raw(char *input_N,
|
||||
char *input_X,
|
||||
char *result)
|
||||
{
|
||||
mbedtls_mpi_uint *X = NULL;
|
||||
mbedtls_mpi_uint *N = NULL;
|
||||
mbedtls_mpi_uint *res = NULL;
|
||||
size_t limbs_X;
|
||||
size_t limbs_N;
|
||||
size_t limbs_res;
|
||||
|
||||
mbedtls_mpi_mod_modulus m;
|
||||
mbedtls_mpi_mod_modulus_init(&m);
|
||||
|
||||
TEST_EQUAL(mbedtls_test_read_mpi_core(&X, &limbs_X, input_X), 0);
|
||||
TEST_EQUAL(mbedtls_test_read_mpi_core(&N, &limbs_N, input_N), 0);
|
||||
TEST_EQUAL(mbedtls_test_read_mpi_core(&res, &limbs_res, result), 0);
|
||||
|
||||
size_t limbs = limbs_N;
|
||||
size_t bytes = limbs * sizeof(mbedtls_mpi_uint);
|
||||
|
||||
TEST_EQUAL(limbs_X, (766 / biL) + 1);
|
||||
TEST_EQUAL(limbs_res, limbs);
|
||||
|
||||
TEST_EQUAL(mbedtls_mpi_mod_modulus_setup(
|
||||
&m, N, limbs,
|
||||
MBEDTLS_MPI_MOD_REP_MONTGOMERY), 0);
|
||||
|
||||
TEST_EQUAL(mbedtls_ecp_mod_p384_raw(X, limbs_X), 0);
|
||||
TEST_LE_U(mbedtls_mpi_core_bitlen(X, limbs_X), 384);
|
||||
mbedtls_mpi_mod_raw_fix_quasi_reduction(X, &m);
|
||||
ASSERT_COMPARE(X, bytes, res, bytes);
|
||||
|
||||
exit:
|
||||
mbedtls_free(X);
|
||||
mbedtls_free(res);
|
||||
|
||||
mbedtls_mpi_mod_modulus_free(&m);
|
||||
mbedtls_free(N);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */
|
||||
void ecp_mod_p521_raw(char *input_N,
|
||||
char *input_X,
|
||||
|
|
Loading…
Reference in a new issue