Inline mpi_core_clear()

This used to resize MPIs in the legacy interface, which is not
needed/possible as the new interface has fixed size MPIs.

Inlining this function makes the code easier to read and maintain, while
there is no obvious drawback to it.

Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index ee71e3f..1929c17 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -75,20 +75,6 @@
     return( ( i * biL ) + j );
 }
 
-/* Check X to have at least n limbs and set it to 0. */
-static int mpi_core_clear( mbedtls_mpi_uint *X,
-                           size_t nx,
-                           size_t limbs )
-{
-    if( nx < limbs )
-        return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
-
-    if( X != NULL )
-        memset( X, 0, nx * ciL );
-
-    return( 0 );
-}
-
 /* Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint
  * into the storage form used by mbedtls_mpi. */
 static mbedtls_mpi_uint mpi_bigendian_to_host_c( mbedtls_mpi_uint x )
@@ -190,18 +176,19 @@
                               const unsigned char *buf,
                               size_t buflen )
 {
-    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
     size_t i;
     size_t const limbs = CHARS_TO_LIMBS( buflen );
 
-    /* Ensure that target MPI has at least the necessary number of limbs */
-    MBEDTLS_MPI_CHK( mpi_core_clear( X, nx, limbs ) );
+    if( nx < limbs )
+        return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
+
+    if( X != NULL )
+        memset( X, 0, nx * ciL );
 
     for( i = 0; i < buflen; i++ )
         X[i / ciL] |= ((mbedtls_mpi_uint) buf[i]) << ((i % ciL) << 3);
 
-cleanup:
-    return( ret );
+    return( 0 );
 }
 
 /*
@@ -215,13 +202,15 @@
                               const unsigned char *buf,
                               size_t buflen )
 {
-    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
     size_t const limbs = CHARS_TO_LIMBS( buflen );
     size_t overhead;
     unsigned char *Xp;
 
-    /* Ensure that target MPI has at least the necessary number of limbs */
-    MBEDTLS_MPI_CHK( mpi_core_clear( X, nx, limbs ) );
+    if( nx < limbs )
+        return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
+
+    if( X != NULL )
+        memset( X, 0, nx * ciL );
 
     overhead = ( nx * ciL ) - buflen;
 
@@ -235,8 +224,7 @@
         mbedtls_mpi_core_bigendian_to_host( X, nx );
     }
 
-cleanup:
-    return( ret );
+    return( 0 );
 }
 
 /*