Add tests for little endian core I/O

Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function
index c3e9572..34710c4 100644
--- a/tests/suites/test_suite_mpi.function
+++ b/tests/suites/test_suite_mpi.function
@@ -259,6 +259,65 @@
 /* END_CASE */
 
 /* BEGIN_CASE */
+void mbedtls_mpi_core_io_le( data_t *input, int nb_int, int nx_64_int, int iret,
+                             int oret )
+{
+    #define BMAX 1024
+    unsigned char buf[BMAX];
+    #define XMAX BMAX / sizeof( mbedtls_mpi_uint )
+    mbedtls_mpi_uint X[XMAX];
+    size_t nx, nb;
+    int ret;
+
+    if( iret != 0 )
+        TEST_ASSERT( oret == 0 );
+
+    TEST_ASSERT( 0 <= nb_int );
+    nb = nb_int;
+    TEST_ASSERT( nb <= BMAX );
+
+    TEST_ASSERT( 0 <= nx_64_int );
+    nx = nx_64_int;
+    /* nx_64_int is the number of 64 bit limbs, if we have 32 bit limbs we need
+     * to double the number of limbs to have the same size. */
+    if( sizeof( mbedtls_mpi_uint ) == 4 )
+        nx *= 2;
+    TEST_ASSERT( nx <= XMAX );
+
+    ret =  mbedtls_mpi_core_read_le( X, nx, input->x, input->len );
+    TEST_ASSERT( ret == iret );
+
+    if( iret == 0 )
+    {
+        ret =  mbedtls_mpi_core_write_le( X, nx, buf, nb );
+        TEST_ASSERT( ret == oret );
+    }
+
+    if( ( iret == 0 ) && ( oret == 0 ) )
+    {
+        if( nb > input->len )
+        {
+            TEST_ASSERT( memcmp( buf, input->x, input->len ) == 0 );
+            for( size_t i = input->len; i < nb; i++ )
+                TEST_ASSERT( buf[i] == 0 );
+        }
+        else
+        {
+            TEST_ASSERT( memcmp( input->x, buf, nb ) == 0 );
+            for( size_t i = nb; i < input->len; i++ )
+                TEST_ASSERT( input->x[i] == 0 );
+        }
+    }
+
+exit:
+    ;
+
+    #undef BMAX
+    #undef XMAX
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
 void mbedtls_mpi_read_binary_le( data_t * buf, char * input_A )
 {
     mbedtls_mpi X;