Introduce MD handle type

As has been previously done for ciphersuites, this commit introduces
a zero-cost abstraction layer around the type

  mbedtls_md_info const *

whose valid values represent implementations of message digest algorithms.

Access to a particular digest implementation can be requested by name or
digest ID through the API mbedtls_md_info_from_xxx(), which either returns
a valid implementation or NULL, representing failure.

This commit replaces such uses of `mbedtls_md_info const *` by an abstract
type `mbedtls_md_handle_t` whose valid values represent digest implementations,
and which has a designated invalid value MBEDTLS_MD_INVALID_HANDLE.

The purpose of this abstraction layer is to pave the way for builds which
support precisely one digest algorithm. In this case, mbedtls_md_handle_t
can be implemented as a two-valued type, with one value representing the
invalid handle, and the unique valid value representing the unique enabled
digest.
diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c
index a5acf5b..8d671ab 100644
--- a/programs/aes/crypt_and_hash.c
+++ b/programs/aes/crypt_and_hash.c
@@ -100,7 +100,7 @@
     unsigned char diff;
 
     const mbedtls_cipher_info_t *cipher_info;
-    const mbedtls_md_info_t *md_info;
+    mbedtls_md_handle_t md_info;
     mbedtls_cipher_context_t cipher_ctx;
     mbedtls_md_context_t md_ctx;
 #if defined(_WIN32_WCE)
@@ -192,7 +192,7 @@
     }
 
     md_info = mbedtls_md_info_from_string( argv[5] );
-    if( md_info == NULL )
+    if( md_info == MBEDTLS_MD_INVALID_HANDLE )
     {
         mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[5] );
         goto exit;
diff --git a/programs/hash/generic_sum.c b/programs/hash/generic_sum.c
index 709a149..ed5357f 100644
--- a/programs/hash/generic_sum.c
+++ b/programs/hash/generic_sum.c
@@ -53,7 +53,7 @@
 #else
 
 
-static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum )
+static int generic_wrapper( mbedtls_md_handle_t md_info, char *filename, unsigned char *sum )
 {
     int ret = mbedtls_md_file( md_info, filename, sum );
 
@@ -66,7 +66,7 @@
     return( ret );
 }
 
-static int generic_print( const mbedtls_md_info_t *md_info, char *filename )
+static int generic_print( mbedtls_md_handle_t md_info, char *filename )
 {
     int i;
     unsigned char sum[MBEDTLS_MD_MAX_SIZE];
@@ -81,7 +81,7 @@
     return( 0 );
 }
 
-static int generic_check( const mbedtls_md_info_t *md_info, char *filename )
+static int generic_check( mbedtls_md_handle_t md_info, char *filename )
 {
     int i;
     size_t n;
@@ -177,7 +177,7 @@
 {
     int ret = 1, i;
     int exit_code = MBEDTLS_EXIT_FAILURE;
-    const mbedtls_md_info_t *md_info;
+    mbedtls_md_handle_t md_info;
     mbedtls_md_context_t md_ctx;
 
     mbedtls_md_init( &md_ctx );
@@ -210,7 +210,7 @@
      * Read the MD from the command line
      */
     md_info = mbedtls_md_info_from_string( argv[1] );
-    if( md_info == NULL )
+    if( md_info == MBEDTLS_MD_INVALID_HANDLE )
     {
         mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] );
         return( exit_code );
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index 2b86566..88e3290 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -693,13 +693,16 @@
     if( todo.hmac_drbg )
     {
         mbedtls_hmac_drbg_context hmac_drbg;
-        const mbedtls_md_info_t *md_info;
+        mbedtls_md_handle_t md_info;
 
         mbedtls_hmac_drbg_init( &hmac_drbg );
 
 #if defined(MBEDTLS_SHA1_C)
-        if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) == NULL )
+        if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) ==
+            MBEDTLS_MD_INVALID_HANDLE )
+        {
             mbedtls_exit(1);
+        }
 
         if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
             mbedtls_exit(1);
@@ -715,8 +718,11 @@
 #endif
 
 #if defined(MBEDTLS_SHA256_C)
-        if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ) ) == NULL )
+        if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ) ) ==
+            MBEDTLS_MD_INVALID_HANDLE )
+        {
             mbedtls_exit(1);
+        }
 
         if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
             mbedtls_exit(1);