Introduce psa_key_handle_is_null inline function

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 85d9df4..5d9b34e 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1300,7 +1300,7 @@
     psa_se_drv_table_entry_t *driver;
 #endif /* MBEDTLS_PSA_CRYPTO_SE_C */
 
-    if( handle == 0 )
+    if( psa_key_handle_is_null( handle ) )
         return( PSA_SUCCESS );
 
     status = psa_get_key_slot( handle, &slot );
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index dacd7f6..6303473 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -81,7 +81,8 @@
     /* 0 is not a valid handle under any circumstance. This
      * implementation provides slots number 1 to N where N is the
      * number of available slots. */
-    if( handle == 0 || handle > ARRAY_LENGTH( global_data.key_slots ) )
+    if( psa_key_handle_is_null( handle ) || 
+        ( handle > ARRAY_LENGTH( global_data.key_slots ) ) )
         return( PSA_ERROR_INVALID_HANDLE );
     slot = &global_data.key_slots[handle - 1];
 
@@ -261,7 +262,7 @@
     psa_status_t status;
     psa_key_slot_t *slot;
 
-    if( handle == 0 )
+    if( psa_key_handle_is_null( handle ) )
         return( PSA_SUCCESS );
 
     status = psa_get_key_slot( handle, &slot );
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 9494c65..391e93c 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -63,7 +63,7 @@
         return( 1 );
 
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    if( conf->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( conf->psk_opaque ) )
         return( 1 );
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
 
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 070a591..03dc2d4 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -157,7 +157,7 @@
         return( 1 );
 
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    if( conf->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( conf->psk_opaque ) )
         return( 1 );
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
 
@@ -172,13 +172,13 @@
         /* If we've used a callback to select the PSK,
          * the static configuration is irrelevant. */
 
-        if( ssl->handshake->psk_opaque != 0 )
+        if( ! psa_key_handle_is_null( ssl->handshake->psk_opaque ) )
             return( 1 );
 
         return( 0 );
     }
 
-    if( ssl->conf->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( ssl->conf->psk_opaque ) )
         return( 1 );
 
     return( 0 );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 6144851..d74e40c 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -466,7 +466,7 @@
         if( status != PSA_SUCCESS )
             return( status );
 
-        if( slot == 0 )
+        if( psa_key_handle_is_null( slot ) )
         {
             status = psa_key_derivation_input_bytes(
                 derivation, PSA_KEY_DERIVATION_INPUT_SECRET,
@@ -563,7 +563,7 @@
         return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
     }
 
-    if( master_slot != 0 )
+    if( ! psa_key_handle_is_null( master_slot ) )
         status = psa_destroy_key( master_slot );
     if( status != PSA_SUCCESS )
         return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
@@ -707,13 +707,13 @@
     {
         /* If we've used a callback to select the PSK,
          * the static configuration is irrelevant. */
-        if( ssl->handshake->psk_opaque != 0 )
+        if( ! psa_key_handle_is_null( ssl->handshake->psk_opaque ) )
             return( 1 );
 
         return( 0 );
     }
 
-    if( ssl->conf->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( ssl->conf->psk_opaque ) )
         return( 1 );
 
     return( 0 );
@@ -4344,7 +4344,7 @@
 {
     /* Remove reference to existing PSK, if any. */
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    if( conf->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( conf->psk_opaque ) )
     {
         /* The maintenance of the PSK key slot is the
          * user's responsibility. */
@@ -4432,7 +4432,7 @@
 static void ssl_remove_psk( mbedtls_ssl_context *ssl )
 {
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
-    if( ssl->handshake->psk_opaque != 0 )
+    if( ! psa_key_handle_is_null( ssl->handshake->psk_opaque ) )
     {
         ssl->handshake->psk_opaque = PSA_KEY_HANDLE_INIT;
     }
@@ -4478,7 +4478,7 @@
     ssl_conf_remove_psk( conf );
 
     /* Check and set opaque PSK */
-    if( psk_slot == 0 )
+    if( psa_key_handle_is_null( psk_slot ) )
         return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
     conf->psk_opaque = psk_slot;
 
@@ -4494,7 +4494,8 @@
 int mbedtls_ssl_set_hs_psk_opaque( mbedtls_ssl_context *ssl,
                                    psa_key_handle_t psk_slot )
 {
-    if( psk_slot == 0 || ssl->handshake == NULL )
+    if( ( psa_key_handle_is_null( psk_slot ) ) ||
+        ( ssl->handshake == NULL ) )
         return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
 
     ssl_remove_psk( ssl );