mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-16 04:20:49 +00:00
Add test code for big endian write/read
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
This commit is contained in:
parent
da5cf4896e
commit
254f94bb43
@ -1591,6 +1591,9 @@ void ecp_mod_read_write(char *input_A, int id, int ctype)
|
||||
|
||||
bytes = limbs * ciL;
|
||||
ASSERT_ALLOC(bufx, limbs);
|
||||
/* Write source mod residue to a buffer, then read it back to
|
||||
* the destination mod residue, compare the two mod residues.
|
||||
* Firstly test little endian write and read */
|
||||
TEST_EQUAL(0, mbedtls_mpi_mod_write(&rA, &m, (unsigned char *) bufx,
|
||||
bytes,
|
||||
MBEDTLS_MPI_MOD_EXT_REP_LE));
|
||||
@ -1602,6 +1605,20 @@ void ecp_mod_read_write(char *input_A, int id, int ctype)
|
||||
TEST_EQUAL(limbs, rX.limbs);
|
||||
ASSERT_COMPARE(rA.p, bytes, rX.p, bytes);
|
||||
|
||||
memset(bufx, 0x00, bytes);
|
||||
memset(rX_raw, 0x00, bytes);
|
||||
/* Then test big endian write and read */
|
||||
TEST_EQUAL(0, mbedtls_mpi_mod_write(&rA, &m, (unsigned char *) bufx,
|
||||
bytes,
|
||||
MBEDTLS_MPI_MOD_EXT_REP_BE));
|
||||
|
||||
TEST_EQUAL(0, mbedtls_mpi_mod_read(&rX, &m, (unsigned char *) bufx,
|
||||
bytes,
|
||||
MBEDTLS_MPI_MOD_EXT_REP_BE));
|
||||
|
||||
TEST_EQUAL(limbs, rX.limbs);
|
||||
ASSERT_COMPARE(rA.p, bytes, rX.p, bytes);
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_mod_modulus_free(&m);
|
||||
mbedtls_mpi_mod_residue_release(&rA);
|
||||
|
Loading…
x
Reference in New Issue
Block a user